[antlr-interest] Faster expression parsing for ANTLR

Zenzike zenzike at gmail.com
Wed Dec 17 14:51:34 PST 2008


I have just started playing with ANTLR, and it's been a pretty fun ride so far,
but I'm having troubles with a gated semantic predicate that has a
rule parameter
in it -- when it gets hoisted, the parameter goes out of scope.

I am trying to describe a language that allows arbitrary operator creation,
with a specified precedence and associativity. I thought I struck
gold when I saw Ter's wiki post [1], but sadly, it won't work
in my grammar since I need backtracking, and the

{prec[input.LA(1)]>=p}?=>

part of my grammar is getting hoisted out of context (variable p is a
rule parameter).

I'm looking into implementing Sam's way of doing this [2],
since no semantic predicates are used, but I was wondering
if there was any way of suppressing hoisting (I haven't thought
about the implications of that yet, so it might be a terrible idea).

Thanks,

zenzike

[1] http://www.antlr.org/wiki/display/~admin/2008/03/23/Faster+expression+parsing+for+ANTLR
[2] http://antlr.org/wiki/display/ANTLR3/Operator+precedence+parser


More information about the antlr-interest mailing list