[antlr-interest] Stangeness in example java grammar

Sander Mägi sander at aqris.com
Tue Mar 12 09:16:01 PST 2002


Hi

Example java grammar had (an unintentional?) strangness:

Can anybody please say if it was intentional and what were the reasons?

The 'try' rule
<RULE>
tryBlock
 : "try"^ compoundStatement
  (handler)*
  ( "finally"^ compoundStatement )?
 ;
</RULE>

When finally is present, then finally is set as a root node and try is it's child.

Perhaps more logical would be?
<RULE>
tryBlock
 : "try"^ compoundStatement
  (handler)*
  ( finallyHandler )?
 ;

finallyHandler
 : "finally"^ compoundStatement
 ;
</RULE>

br,
Sander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20020312/b8f716ad/attachment.html


More information about the antlr-interest mailing list