[antlr-interest] Possible bug with backtrack-generated predicate methods

franck102 franck102 at yahoo.com
Sat Nov 26 00:58:10 PST 2011


In fact the tree has been constructed by the leading (ID->ID), and that
parameter being a tree is exactly why I gave up on hoisting. I am sure it
can be made to work but getting the typing right was a pain.

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):

expr
    :    ( prefix -> prefix ) ( suffix -> /* *insert prefix as first child
of suffix and return suffix * */ ) *

prefix : ID;

suffix
    :    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 seem
painful to get right typing wise...

Franck


--
View this message in context: http://antlr.1301665.n2.nabble.com/Possible-bug-with-backtrack-generated-predicate-methods-tp7033324p7033439.html
Sent from the ANTLR mailing list archive at Nabble.com.


More information about the antlr-interest mailing list