[antlr-interest] Newbie Help

Markus Stoeger spamhole at gmx.at
Wed Jan 14 13:51:06 PST 2009


Hi Mike,

I think you need someone with antlr v2 experience.. I had a quick look 
at antlr 2.7.7 but its syntax seems to be quite different so I didn't 
get far with this grammar.

You're writing the grammar for [1] right? The parse tree for 
"a*b*c/d/e/f*2" definitely looks correct in antlr 3.1.1 with k=2. It 
doesn't complain and correctly recognizes the multiplied- and 
divided-base-units followed by the modifier1.

There really should be no need for infinite lookahead in this grammar.. 
two symbols should do. Why do you think that the lookahead would have to 
span the whole /d/e/f tokens first? I don't think that's necessary. 
Anyway, I think the problem must be somewhere else since the grammar 
works fine in v3 with only two symbols of lookahead.

Max
[1] page 122, 
http://www.dmtf.org/standards/published_documents/DSP0004_2.5.0.pdf

Mike Gering schrieb:
>
> Markus,
>
> Thanks for the response. I'm stuck with 2.7.7 because our legal guys 
> have not approved us to use any version 3 releases, and I have no 
> realistic hope that they will any time soon :-(
>
> The problem with setting the lookahead depth is that no number is 
> sufficient because the (SLASH simple_name)* block comes between the 
> two problem blocks. So this example should be matched: a*b*c/d/e/f*2. 
> The lookahead has to span the /d/e/f tokens.
>
> Mike
> IBM
> (919) 732-5020



More information about the antlr-interest mailing list