[antlr-interest] Bad code generated for simple AST rule

Steve Bennett stevagewp at gmail.com
Wed Nov 28 03:40:37 PST 2007


A similar issue:

foo: -> BR;

This code generates code that gives an error for not throwing a
RecognitionException. This workaround seems to work:

foo: {if(false) { throw new RecognitionException(); } }-> BR;

I *think* it's meaningful to have a parser rule that takes no tokens
but generates AST nodes. For example, if a certain set of AST nodes
has to be generated according to some state, and that set has to be
called from various other rules? But maybe it would be better to do
this kind of thing in a later tree-walking step...

Steve


More information about the antlr-interest mailing list