[antlr-interest] problem on the grammar of identifier

John B. Brodie jbb at acm.org
Thu Oct 26 06:25:32 PDT 2006


> 2006/10/25, Zhiyong Zhang <zhiyong_zhang5 at yahoo.ie>:
>
> The identifier is supposed to in be the format of "abc.d6f" or "
> abc.current.dg47". I got ambiguity problem with the lookahead =3D3 in t=
>
> lexical grammar, it also reported problem abc.currentAbcdE. Can anybody
> give me some light?
>
> IDENTIFIER
> options {testLiterals=3Dtrue;} : ('a'.. 'z'|'A'..'Z'|'_')( 'a'..'z'|'A' ..'Z'
> |'0'..'9'|'_'| ':')*  ( (".current."| ".") ('a'..'z'|'A' ..'Z'|'0'..'9' |'_'
> |':')+)?;

class L extends Lexer;
options { k = 9; }
IDENTIFIER options {testLiterals=true;} :
        INITIAL (SUBSEQUENT)* ( "." ("current.")? (SUBSEQUENT)+ )?;
protected INITIAL : 'a'..'z'|'A'..'Z'|'_' ;
protected SUBSEQUENT : INITIAL | ':' ;


More information about the antlr-interest mailing list