[antlr-interest] Help converting a parser grammar to a tree grammar
Jim Idle
jimi at temporal-wave.com
Mon Dec 1 17:02:42 PST 2008
On Tue, 2008-12-02 at 00:27 +0000, Diligent Warrior wrote:
> Hello everyone,
>
> I'm working on a grammar for a Java-like language and I'm stuck at
> this one part. I'm looking to write the tree grammar from this parser
> grammar:
>
> callExpression
> : (primary -> primary) (s=selector -> ^(CALL $callExpression
> $s))*
> ;
>
> The code would look like:
>
> nodeObject.getLeft().getValue();
>
> And the tree would look like:
>
> ( CALL ( CALL nodeObject getLeft ) getValue )
>
> ...or in other words:
>
> ( CALL ( CALL primary selector ) selector )
>
> Theoretically, the tree should be as deep as it needs to be.
callExpression
: primary
| selector
| ^(CALL callExpression callExpression)
;
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081201/e7cf98b8/attachment.html
More information about the antlr-interest
mailing list