[antlr-interest] Re: Nondeterministically blind

mzukowski at bco.com mzukowski at bco.com
Mon Dec 10 08:18:11 PST 2001


The lexer doesn't know whether '''' would be two empty strings or the start
of a triple quoted string.  This is genuinely ambiguous.  Hence you need a
disambiguating syntactic predicate which says that if you see triple quotes
then match a long string.

Monty

> -----Original Message-----
> From: epovazan [mailto:epovazan at telus.net]
> Sent: Saturday, December 08, 2001 5:33 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Re: Nondeterministically blind
> 
> 
> > You didn't include the error message that I could see, but I'm 
> guessing 
> > you have a problem in that your string chars can include the quote 
> and 
> > double-quote chars, which will conflict with the start/end of the 
> > string :)
> > 
> > Good luck,
> > Terence
> 
> Wow, thank for the speedy reply!
> The error is:
> ANTLR Parser Generator   Version 2.7.1   1989-2000 jGuru.com
> PyLex.g:43: warning: lexical nondeterminism upon
> PyLex.g:43:     k==1:'"','\''
> PyLex.g:43:     k==2:'"','\''
> PyLex.g:43:     k==3:'"','\''
> PyLex.g:43:     k==4:'\u0000'..'\u00ff'
> PyLex.g:43:     between alts 1 and 2 of block
> 
> I modified the STRING_LIT rule as follows and it compiles ok:
> STRING_LIT:
>     (("'''") | ("\"\"\"")) => LONG_STRING
>     | SHORT_STRING ;
> 
> However the generated code with the warnings looks like it will 
> execute correctly too.
> 
> It's crazy ... I can do anything except not get nondeterminsm 
> warnings. Thanks for a great tool, eventually I will "get it" and the 
> rest works for me well (tree parsing is great) An in a few weeks, I 
> will have a Python grammar for your collection :)
> 
> -Ed
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list