[antlr-interest] identifier with space

jbb at acm.org jbb at acm.org
Tue Oct 28 19:25:35 PST 2003


>I'm trying to read some command with identifer which might contain 
>space. 
>I tryed some thing like that 
>
>IDENTIFIER: 
>   (IDENTIFIER SPACE ANYNAME) => IDENTIFIER SPACE ANYNAME 
>   | NAME ; 
>protected NAME options { testLiterals=true; }: 
>  'a' .. 'z' ( 'a' .. 'z' | '0' .. '9' | '_' | '$' | '#' | '.' )* ; 
>protected ANYNAME options { testLiterals=true; }: 
>  ( 'a' .. 'z' | '0' .. '9' | '_' | '$' | '#' | '.' )* ; 
>
>but ANTLR generate an infinite recursion error any idea ?


I am sure I must be missing something obvious but why not use:

IDENTIFIER: 
  'a' .. 'z' ( 'a' .. 'z' | '0' .. '9' | '_' | '$' | '#' | '.' | ' ' )* ; 

I have used something similar to this with a global testLiterals=true;
option. is the local testLiterals option the problem?

Hope this helps...
	-jbb

 

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




More information about the antlr-interest mailing list