[antlr-interest] Problem: part of AST gets lost in limbo
Ulrich Hobelmann
u.hobelmann at web.de
Thu Jun 8 08:07:24 PDT 2006
Hi, I'm using the Antlr Java 1.5 grammar + tree parser, working nicely.
My problem: in one instance now a part of the parsed AST gets lost
between the parser and tree parser. The tree parser only receives
part of the expression; the rest is simply lost.
This happens in the java15.g file in the production
"compoundStatement", which I modified as follows:
compoundStatement!
: lc:LCURLY! //^ {#lc.setType(SLIST);}
// include the (possibly-empty) list of statements
sts:(statement)*
rc:RCURLY!
{
/* wrap the line numbers as an IDENT string and smuggle
them through ;-) */
#compoundStatement =
#(#[SLIST,"SLIST"],
#[IDENT,Integer.toString(lc.getLine())],
#[IDENT,Integer.toString(rc.getLine())],
sts);
}
;
I also put a println() inside the "sts:(statement)*" to ensure that
it works, and indeed it prints several lines as it should. Now the
part of the tree parser seems to not receive the "sts" part:
slist { ... return and variable decls ... }
: #( SLIST l1:IDENT l2:IDENT (e1=stat
{
System.out.println("STATEMENT");
}
)*)
//#( SLIST (stat)*)
;
For some reason the list of statements exists in the parser, but in
the tree parser STATEMENT doesn't print even once. I can only think
that there must be something wrong with my expression in the parser
"compoundStatement", but other expressions seem to be written the
same way, with no problem at all...
Any ideas?
Regards,
Ulrich
More information about the antlr-interest
mailing list