[antlr-interest] ANTLR generating invalid Java

Oren Ben-Kiki oren at ben-kiki.org
Fri Aug 8 13:32:52 PDT 2008


It _almost_ works.

The problem is that even with @synpredicate { true }, ANTLR ignores
@init/@after actions for rules inside syntactic predicates; it inlines
("hoists"?) the rule without them. It does preserve the semantic
predicates in such rules, but in my case these semantic predicates can
not function without the supporting @init action :-(

Is there a way to force @init/@after actions to be executed even when
backtracking>0 ?

On an unrelated note - is it possible to completely disable WS?

Thanks,

    Oren.

On Thu, Aug 7, 2008 at 8:13 PM, Oren Ben-Kiki <oren at ben-kiki.org> wrote:
> Scopes, as of themselves, don't solve my problem. I had to throw in
> @synpredicate { true } so I'd be able to perform actions to update the
> variables even when inside a syntactic predicate, and of course
> protect the "real" actions manually with if (backtracking == 0). I
> ended up using a global stack for the parameter in question - this way
> I don't need to know which "parent" rule set it, and most of the time
> it is passed unchanged anyway so I can just not touch the stack.
> Pretty it ain't, but it works. I think.


More information about the antlr-interest mailing list