[antlr-interest] Parser question

Monty Zukowski monty at codetransform.com
Thu May 27 09:34:38 PDT 2004


1) Turn on tracing and make sure that everything is getting parsed. 
e.g. java antlr.Tool -traceParser grammar.g
2) Are you using toStringTree() or toStringList()?  toStringList() will 
print siblings of the root node passed in, toStringTree won't
3) If that fails then post a complete, small sample grammar with sample 
input

Monty

On May 27, 2004, at 8:34 AM, Dima Suliman wrote:

> Hello Terence,
>
> I've tried:
> statement: (equation)+;
> equation:  EQ^ expr expr;
> (the mathematical expression are in prefix form: e.g.,  + a b)
>
> It didn't work. Printing the AST you see only the first equation....
>
>
> Regards
>
> Dima
>
>
>>
>>
>> On May 27, 2004, at 4:28 AM, Dima Suliman wrote:
>>
>>> Hello,
>>>
>>> I have the parser start rule:
>>>
>>> statement: (expr EQ^ expr)+;
>>>
>>> expr is a mathematical expr. It works but when I have more than one
>>> expr,
>>> and I print the ast, the ast shows only the first one!
>>>
>>> any suggestions?
>>
>> The ^ works on the tree created for the current rule not the subrule.
>> Move the stuff in the (...)+ to another rule and then reference it. :)
>> You will find the sequence of EQ trees you want :)
>>
>> Terence
>>
>>
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
Monty Zukowski

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html



 
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