[antlr-interest] What does " The following alternatives can never be matched" mean
qinglangee
zcqingdao at 163.com
Tue Dec 1 21:19:52 PST 2009
Gavin Lambert wrote:
>
> The problem is that both the function and var rules have a common
> left prefix (Letter+); the only distinguishing feature is whether
> it's followed by a comma or not. So when you're saying that
> "command" can consist of either "function" or "var", it's not
> possible to define static lookahead to disambiguate that case.
>
> You can either force explicit lookahead (this doesn't always
> work):
> command : ( (function) => function
> | var
> )+
> ;
>
> Or refactor the rules to eliminate the ambiguity:
> command : ( Letter+ ','? )+ ;
>
> Note however that since you're hiding whitespace in the lexer, the
> input "HELLO" and "HE L LO" will be treated as
> identical. This may or may not be what you want.
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
Thanks for your kindness.
I am freshman on antlr. And I donot very clear about the syntax of antlr
lexer,
could sb. advise some document, like the useage of => in the advice above.
The only useful thing I can find is the
http://www.antlr.org/wiki/display/ST/Five+minute+Introduction Five minute
Introduction .
--
View this message in context: http://n2.nabble.com/What-does-The-following-alternatives-can-never-be-matched-mean-tp4097824p4098099.html
Sent from the ANTLR mailing list archive at Nabble.com.
More information about the antlr-interest
mailing list