[antlr-interest] Re: identifier with space

lloyd_from_far ld at galador.net
Tue Oct 28 19:41:11 PST 2003


The problem is, with this grammer the string

"SELECT a field with name FROM aTable"

will be cut in 2 tokens:
'SELECT'
'a field with name FROM aTable'

where as I want 4:
'SELECT'
'a field with name'
'FROM'
'aTable'

> 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


--- In antlr-interest at yahoogroups.com, jbb at a... wrote:
> 
> >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 ?
> 
> 



 

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




More information about the antlr-interest mailing list