[antlr-interest] cgram and SEMI! usage

jenlhunt2003 steam at tapisinc.com
Thu Jan 29 10:45:24 PST 2004


When I run a simple one line program:

double d;

through StdCParser and GnuCTreeParser displaying the nodes in the tree parser I get:

...

   < initDecl()
  < initDeclList()
<AST>: unexpected AST node: <ASTNULL>
 < declaration()
<externalDef()

This appears to occur because in StdCParser.g we have:

declaration
        { ANTLR_USE_NAMESPACE(antlr)RefAST /*AST*/ ds1 = NULL; }
        :       ds:declSpecifiers       { ds1 = astFactory->dupList(#ds); }
                (                       
                    initDeclList[ds1]
                )?
                SEMI!
                                        { ## = #( #[NDeclaration], ##); }
        ;

Whereas in GnuCTreeParser.g we have:

declaration
        :       #( NDeclaration
                    declSpecifiers
                    (                   
                        initDeclList
                    )?
                    ( SEMI )+
                )
        ;

*************************

If I take out the ! after SEMI in the Parser .g file I don't get the error.
It would appear that the tree parser is expecting a SEMI AST, but the parser 
is not generating one.  Some other tree parser code that I've examined omits 
things like SEMI, so I'd appreciate some insight here.

Thank you in advance,

Henry








 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list