[antlr-interest] how to get the value of an identifier

Jim Idle jimi at temporal-wave.com
Tue Sep 29 08:29:00 PDT 2009


On 09/29/2009 07:54 AM, Thierry USO wrote:
> A complete example which shows my problem.
>
> --- ADL.g ---
>
> grammar ADL; // Rally Application Development Language
>
> constant_definition
> : ConstDef
> ;
>
> ConstDef
> : {System.out.println("");} CONST
> (
> (' '|'\t')* Identifier {System.out.print($Identifier.text + " ");}
> (' '|'\t')* EQUAL
> (' '|'\t')* CharString {System.out.print($CharString.text + " ");}
> (' '|'\t')* SEMICOLON
> )+
> ;
>
> CharString
> : '"' (LETTER)+ '"'
> ;
>
> CONST
> : 'CONST' {System.out.print("CONST ");}
> ;
>
>    

You need:

fragment
LETTER ....
> LETTER
> : ('a'..'z'|'A'..'Z')
> ;
>    

Jim


More information about the antlr-interest mailing list