[antlr-interest] Re: Lexer non-determinism

seaswar <sje at sigma-inc.com> sje at sigma-inc.com
Sun Dec 22 13:52:16 PST 2002


The behaviour is the same using 2.7.2. I still get the warning. I 
expected the predicate to hush the warning. The code generated looks 
right but it insists on generating the warning for k=2 but not for 
k=3.

The java grammar has k=4. Thus no warning is generated.

Suresh

--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at j...> 
wrote:
> 
> On Sunday, December 22, 2002, at 08:19  AM, seaswar <sje at s...> 
> wrote:
> 
> > I posted this on the jGuru forum but got no reply. Perhaps I'll 
have
> > better luck here.
> >
> > I don't understand why the following is ambiguous for k=2 but 
notfor
> > k=3. I checked the generated code (java, antlr 2.7.1) and it looks
> > right. So I turned of the warning. But I would still like to
> > understand why there is a warning in the first place. No warning 
is
> > generated for k=3.
> >
> > class TestLexer extends Lexer;
> >
> > options { k = 2; }
> >
> > MULTI_LINE_COMMENT
> >     :    "/*"
> >          (    { LA(2) != '/' }? '*'
> >          |    ( "\r\n" | '\n') { newline(); }
> >          |   ~( '*' | '\r' | '\n')
> >          )*
> >          "*/" { $setType(Token.SKIP); }
> >     ;
> >
> > ANTLR Parser Generator   Version 2.7.1   1989-2000 jGuru.com
> > com/qsi/parser/test/test9.g:7: warning: lexical nondeterminism 
upon
> > com/qsi/parser/test/test9.g:7:  k==1:'*'
> > com/qsi/parser/test/test9.g:7:  k==2:'/'
> > com/qsi/parser/test/test9.g:7:  between alt 1 and exit branch of 
block
> 
> The predicate should hush the warning I think; perhaps 2.7.2 does.  
> Anyway, check the java grammar to see what it does.
> 
> Thanks,
> Terence
> --
> 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