[antlr-interest] question about example 'ANTLR masquerading as SED'
Terence Parr
parrt at jguru.com
Sun Dec 22 23:12:02 PST 2002
On Sunday, December 22, 2002, at 03:42 PM, corno at dds.nl wrote:
> Hi all,
>
> The following example is from the reference manual.
>
> class T extends Lexer;
> options {
> k=2;
> filter=IGNORE;
> charVocabulary = '\3'..'\177';
> }
>
> protected
> IGNORE
> : ( "\r\n" | '\r' | '\n' )
> {newline(); System.out.println("");}
> | c:. {System.out.print(c);}
> ;
>
>
> but it gives a warning about nondeterminism. However, when I comment
> out the
> last code block (behind c:.), there's no warning, which seems strange
> to me as
> it does not alter the logic (or does it).
It alters the logic because if you remove it takes out the alt that
says "match anything (else)". "anything" matches the newline stuff
also so it's ambiguous. You can shut off the warning if you want
though with a subrule option. Or, just ignore the warning ;)
Terence
> Can anybody tell me:
> a) Why this is
> b) If this can be ignored
> c) If not, how this can be solved
>
> TIA,
>
> Corno
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list