[antlr-interest] Strange bug in ANTLR version higher than 3.1.2

FranklinChen at cmu.edu FranklinChen at cmu.edu
Wed Nov 4 17:20:22 PST 2009


> Hi Franklin,
> 
> You didn't say exactly what the bug was. That said, here's my feedback,
> lots of it just my opinion not rules:
> 
> * Replace your call to {skip();} with {$channel = HIDDEN;}
> * Replace ^(PHO[i, "pho"] $i) with just PHO[i, "pho"]. When you
> construct the PHO token from i, it takes on the text and the token
> start/stop positions of i, so the child node is redundant.
> * In your @after blocks, if you reference a parameter like it, you
> should use $it instead of just it.
> * I think TIER[c.tree.getToken(), "TIER"] should be
> TIER[$c.tree.getToken(), "TIER"]
> * I'm pretty sure mainTier can initialize the wordList like this:
> mainTier returns [ArrayList<CommonTree> wordList = new
> ArrayList<CommonTree>()] and then leave out the @init block.
> * When you're using a tree parser, try to move as much logic as possible
> to the tree parser instead of the parser. If possible, you should shoot
> for having a parser with no actions, parameters, or @init{} @after{}
> blocks (obviously this is not always possible). If you meet this goal,
> then your parser will work with any target without any changes.

My tree parser worked fine with ANTLR 3.1.1 and 3.1.2, just failed
mysteriously with ANTLR 3.1.3 and 3.2.

-- 
Franklin


More information about the antlr-interest mailing list