[antlr-interest] I am puzzled....

Terence Parr parrt at jguru.com
Sat Aug 31 16:24:28 PDT 2002


On Saturday, August 31, 2002, at 03:52  PM, Lloyd Dupont wrote:

> why do I have an ambig warning with this lexer definition file ?
> I really don't see (and, therefore, can't fix), does anyone has an 
> idea ?
> that would be helpfull :-)
> cheers,
> Lloyd
>
> // ------------------- testGrammar.g --------------------
> class TestLexer extends Lexer;
> options {
>  k=4;
>  charVocabulary  = '\3'..'\377';
>  testLiterals=false;
> }
>
> GLTYPE
>     : "GLenum"
>     | "GLbyte"
>     | "GLshort"
>     | "GLint"
>     | "GLsizei"
>     | "GLubyte"
>     | "GLuint"
>     | "GLfloat"
>     | "GLushort"
>     | ("GLclampf")=>"GLclampf"
>     | "GLdouble"
>     | "GLclampd"
>     | "GLboolean"
>     | "GLbitfield"
>     ;
> VOID
>     : "void"
>     | "GLvoid"
>     ;

The problem is that the approximate lookahead is collapsing lookahead 
sets at each depth:

ANTLR Parser Generator   Version 2.7.2a3 (20020831-1)   1989-2002 
jGuru.com
warning: lexical nondeterminism between rules GLTYPE and VOID upon
t.g:    k==1:'G'
t.g:    k==2:'L'
t.g:    k==3:'i'
t.g:    k==4:'o'

The "GL" comes from alt 2 of VOID and "io" comes from 3rd,4th position 
of alt 1 of VOID; this collides with the collapsed sets from GLTYPE.  
Including VOID into GLTYPE gets rid of the warning ;)

BTW, yes that 2.7.2a3 timestamp says today.  I'm working on ANTLR 
finally!  Woohoo!

Ter


 

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



More information about the antlr-interest mailing list