[antlr-interest] cgram and SEMI! usage

mzukowski at yci.com mzukowski at yci.com
Thu Jan 29 10:52:14 PST 2004


It looks like I did all my testing by combining GnuCParser and
GnuCTreeParser.  I should also test with StdCParser and GnuCTreeParser!  I'm
trying to remember why, but with Gnu C I needed to use SEMIs in the tree
more.  I would recommend changing the StdCParser as you have, by removing
the ! from the SEMIs when you see this.

Monty

-----Original Message-----
From: jenlhunt2003 [mailto:steam at tapisinc.com] 
Sent: Thursday, January 29, 2004 10:45 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] cgram and SEMI! usage

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/ 


 

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