[antlr-interest] how to set lookahead in v3

Markus Kuhla bace.spam at gmx.net
Wed May 2 17:34:29 PDT 2007


Hi.

I'm using antlr, v3beta7. The LL(*) algorithm determines automatically how much lookahead is necessary to choose a alternative?!

Ich have the problem, that the parser can find 1 or 2 tokens matching to an alternative of a parser rule, e.g.
next input: "NEWLINE BLANK BLANK DASH DASH ..."
the parser is currently in this rule:

text : line+;
line : NEWLINE? blanks? all_chars_but_not_dash
     | EOF;

The parser chooses the 1st alternative of line, and gives an error of course.
In the grammar is another possibility, to continue with "NEWLINE blanks? DASH" - So the parser has to go out of the line-rule, if there is a dash!


How can you realize a behavior like a real LL(*) parser, that there is enough lookahead to make a appropriate decision (leave rule line or continue with alternative1)

Thanks guys, in advance ;) !!!

-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail


More information about the antlr-interest mailing list