[antlr-interest] How does the two rules differ in a tree parser ?

Subhobroto Sinha subhobrotosinha at rediffmail.com
Sat Jul 9 23:47:16 PDT 2005


  
In a treeparser, what does this mean (in english, verbosely if possible):

declarator : #(varName : ID {std::cout<<"\n variable name : " << varName->getText();} (fixedArraySize)*) ;

and why does it behave differently from :

declarator : varName : ID {std::cout<<"\n variable name : " << varName->getText();} (fixedArraySize)* ;

The 'declarator' rule will parse AST like :

intArray 5

or

mulDimArray 3 4 5 6 7 8

So if we add this rule defn. :

fixedArraySize : positiveIntConst : INT {std::cout<<"\n array subscript : " << positiveIntConst->getText();};

then , parsing the first AST will display :

variable name : intArray
array subscript : 5

and parsing the second AST will display :

variable name : mulDimArray
array subscript : 3
array subscript : 4
array subscript : 5
array subscript : 6
array subscript : 7
array subscript : 8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050710/e3217f0f/attachment.html


More information about the antlr-interest mailing list