[antlr-interest] Eliminate characters in TOKEN

Rampon Jerome ramponjerome at yahoo.fr
Wed Nov 23 01:54:40 PST 2011



Hi,


I tried to eliminate some space character in some complex tokens

but got issues with v3 (I think was ok with v2)


Following reduced rules are ok to retrieve my token ID

start
:      id=ID EOF
       { System.out.println("text is: " + $id.text); }
;

ID
:      ('a'..'z'|'A'..'Z')((' ')?('a'..'z'|'A'..'Z'|'0'..'1'))
;
but if I try to add ! after ' ' to eliminate it from returned token text

ID
:      ('a'..'z'|'A'..'Z')((' '!)?('a'..'z'|'A'..'Z'|'0'..'1'))
;
it complained on output option to be AST.
If I add it in my grammar options if complains and still return error
It seems it automatically adds if not there but later on still return error ???

Is that normal ?
Any simple way to bypass rather than a later replaceAll. I would prefer to keep
it target independent 


Thanks

Jerome


More information about the antlr-interest mailing list