[antlr-interest] Rewriting into nested AST nodes without recursive rule invocation

jeroen.v.schagen at gmail.com jeroen.v.schagen at gmail.com
Thu Aug 27 01:34:36 PDT 2009


Hello,

I am attempting to convert my production 'markupChain' into a nested  
hierchy of nodes. This allows me to always skip the remainder of my chain  
using a single wildcard symbol, regardless of my position in the chain.  
I've done just that in the grammar demonstrated below, however this grammar  
is not LL(*) due to recursive rule invocation.. meaning I have to enable  
backtracking.

markupChain: expression ';'
-> ^( MARKUP_CHAIN expression )
| statement
-> ^( MARKUP_CHAIN statement )
| embedding ';'
-> ^( MARKUP_CHAIN embedding )
| markup markupChain
-> ^( MARKUP_CHAIN markup markupChain )
| ';' ;

I've made the grammar LL(*) as follows:

markupChain: markup* ( ';' | expression ';' | embedding ';' | statement )

However, I am unable to specify a rewrite rule that allows me to retain my  
origional AST hierchy. Any help would be greatly appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090827/ba6e69c1/attachment.html 


More information about the antlr-interest mailing list