[antlr-interest] simple confusion

Bryan Ewbank ewbank at gmail.com
Fri Sep 9 18:30:02 PDT 2005


The nondeterminism is because, given a sequence of '\n' characters, it
is possible to match it with one LINE_TERMINATOR for the entire
sequence, or one LINE_TERMINATOR for each '\n' in the sequence.  ANTLR
uses a "longest match", so it will consume the sequence with one
LINE_TERMINATOR; however, it will also warn you about the problem in
case you didn't intend this.  The purpose of this option, and the
"greedy=true" option, are (as you surmise) to silence the warnings.

On 8/25/05, Brien Colwell <bcolwell at berkeley.edu> wrote:
> Hi all,
> 
> I am having some trouble with a seemingly simple rule.
> 
> protected
> LINE_TERMINATOR
> ... ( '\n' | ... ) +
> ;
> This rule attempts to match as many of these four characters as it can.
> ANTLR is giving strange non-determinism errors about it. Does it seem
> fundamentally flawed to anyone? Also, I have observed that the option
> set does not always silence non-determinism warnings.


More information about the antlr-interest mailing list