[antlr-interest] Some C target issues

Jim Idle jimi at temporal-wave.com
Tue Apr 1 14:03:39 PDT 2008


4) Yes, it isn't a file scope level section, as per the C API docs. It is for rules and if you are compiling as C++, then you can skip it and just use @init. It is only for pure C, where you cannot generally declare an initialize at the same time. 

 

Jim

 

 

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Chris Snyder
Sent: Tuesday, April 01, 2008 12:35 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Some C target issues

 

1)  worked thanks

2)  ok

3)  ok

4)  Here is the top of the tree grammar I was using. I tried placing garbage in the @declarations section and it never complains during compilation nor does the code appear in my MScriptToBlock.c or MScriptToBlock.h files.

 

//begin tree grammar

tree grammar MScriptToBlock;

options {

            tokenVocab=MScript; // reuse token types

            ASTLabelType=pANTLR3_BASE_TREE ; // $label will have type CommonTree

            language=C;

            k=2;

}

 

@header {

#include <string.h>

#include <iostream.h>

}

 

@declarations

{

  SSSIG *test=NULL;

}

 

@members {  

  TCSSLModel *m_model=NULL;

  TCString m_rootScope;

} 

 

 

//container subsystem is the subsystem containing the eml block

start[TCSSLModel *pModel, TCString pRootScope] returns [TCSSLSubsystem *rootSubsystem]

  : 

            so=script

            ;

            

....... rest of tree grammar

//end tree grammar

  _____  

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Tuesday, April 01, 2008 3:11 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Some C target issues

 

1) Set it to anything, but pANTLR3_BASE_TREE is probably best;

2) In tree grammars, you just use @includes or @headers or @members etc;

3) This is protected in the current 3.1 source;

4) I'll look at that one, but where were you using the @declarations? I have a number of parsers that rely on this, but I will check that it is still working for tree parsers. Can you post an example to save time?

 

Jim

 

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Chris Snyder
Sent: Tuesday, April 01, 2008 11:03 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Some C target issues

 

Hello,

 

1) Is there a default ASTLabelType=[?] to get rid of this warning? 

warning(152): tree grammar MScriptToBlock has no ASTLabelType option

 

2) Following the guidelines here: http://www.antlr.org/api/C/index.html, in my Tree grammar I tried changing 

 

@header {

#include <string.h>

#include <string.h>

#include <iostream.h>

}

 

To this

 

@parser::includes {

#include <string.h>

#include <iostream.h>

}

 

And I get this error:

error(143): unknown or invalid action scope for tree grammar: parser

 

@parser::header also failed with the same error

 

3) The last version of code I have from 3/13/2008 still had this warning

y:\t_vec_cots\include\antlr3\antlr3defs.h(75) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition

 

4) I tried using the @declarations section in my tree grammar and although no warnings were generated none of the code in the @declarations section was added to either the generated C or h files.

 

 

Thanks,

Chris

 

T-VEC Technologies, Inc.

 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080401/29547ee4/attachment-0001.html 


More information about the antlr-interest mailing list