[antlr-interest] Re : Problem with tree rewriting in 3.1b2
Le Lann Jean-Christophe
jean-christophe.lelann at orange.fr
Sat Aug 2 05:43:33 PDT 2008
I have found my 'bug' (?) in the tree grammar but I need some explanations.
In MyGram.g the *entry* rule was :
program : (instruction)* EOF -> ^(PROGRAM instruction*)
while in MyGramTree.g (walker) the *entry* rule was :
program : ^(PROGRAM instruction*)
That DOES NOT work.
The correct way to write this is :
program : (PROGRAM instruction*)
i.e without "^". That seems to be the trick.
That seems to be an exception in the recipe suggested when moving from
parser grammar to tree grammar : here (at the root of the tree) the
direct copy of the right part of the parser grammar does not work (^
must be suppressed).
But I'd like to have your comments/approval on this explanation. If it
is the correct explanation then I would suggest to add some warning in
the tool (I am using antrl 3.1b2).
More information about the antlr-interest