[antlr-interest] Re: Lexical k=3
John Green
greenj at ix.netcom.com
Thu Apr 3 12:58:14 PST 2003
Oh, duh, I don't know how many times I've read the particular relevant FAQ
entry: "Can you explain more about ANTLR's tricky lexical lookahead issues
related to seeing past the end of a token definition into the start of
another?"
I don't think I've ever been bit by this before, so I guess I guess it just
never sank in. Sorry for posting before re-reading the FAQs.
John
--On 4/3/03 11:18 AM -0800 John Green wrote:
>
> This one looks like it should be easy, but I can't figure it out, and
> because of the larger context of my lexer, I haven't come up with a good
> workaround. Any pointers from this good mailing list?
>
> For k==2:'~' I don't think that it should be trying to enter *either* of
> the two rules.
>
> -----
> C:\work\antlr>java -cp /progfile/antlr antlr.Tool test.g
> ANTLR Parser Generator Version 2.7.1+ (RK devel version) 1989-2000
> jGuru.com
>
> warning: lexical nondeterminism between rules TEST_ONE and TEST_TWO upon
> test.g:0: k==1:'~'
> test.g:0: k==2:'~'
> test.g:0: k==3:<end-of-token>,'~'
> -----
>
>
> -----
> // test.g
>
> class Test extends Lexer;
> options {
> k=3;
> }
>
> TEST_ONE
> :
> ( ('~')?
> ( ' '
> | '\t'
> | '\f'
> | '\n' { newline(); }
> | '\r'
> )
> )+
> ;
>
> TEST_TWO
> : ( '\\'|'/'|'#'|'%'
> | "~\""
> | "~\'"
> )
> ( 'a'..'z'|'_'|'0'..'9'|'#'|'$'|'%'|'&'|'-'|'\\'|'/'
> | "~\""
> | "~\'"
> )+
> ;
> -----
>
>
> Thanks,
> John
>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list