[antlr-interest] Possible bug with backtrack-generated predicate methods
bkiers at gmail.com
Sat Nov 26 01:29:16 PST 2011
On Sat, Nov 26, 2011 at 9:58 AM, franck102 <franck102 at yahoo.com> wrote:
> In fact the tree has been constructed by the leading (ID->ID),
That tree only exists inside your parenthesis, AFAIK. You can't reference
it outside it (well, you can, but it will be `null`).
So here is exactly what I am trying to do, there is probably a better way
> than what I have (untested pseudo-grammer, but you should get the idea):
> : ( prefix -> prefix ) ( suffix -> /* *insert prefix as first child
> of suffix and return suffix * */ ) *
> prefix : ID;
> : DOT ID -> ^( DOT ID )
> | '[' expr ']' -> ^( INDEX expr )
> I guess I could use a scope to pass down the prefix; or have suffix return
> both the root type and a flat list and build the tree in expr; but both
> painful to get right typing wise...
Yes, it's a pain compared to simple passing the tree as a parameter, but
that's the "penalty" for turning on global backtracking .
More information about the antlr-interest