[antlr-interest] Re: simple question

lloyd_from_far ld at galador.net
Tue Oct 28 21:00:03 PST 2003


that one is better, but still generate 65 lines of warning ...

IDENTIFIER: 
	NAME ( SPACE  | ANYNAME ) * 
	{ setText(getText().Trim()); }
	;
	
protected NAME options { testLiterals=true; } :
	'a' .. 'z' ( 'a' .. 'z' | '0' .. '9' | '_' | '$' | '#' 
| '.' ) +
	;
protected ANYNAME options { testLiterals=true; } :
	( 'a' .. 'z' | '0' .. '9' | '_' | '$' | '#' | '.' ) +
	;
protected SPACE: (' ') + ;

WS  :   (   SPACE
        |   '\t'
        |   '\r' '\n' { newline(); }
        |   '\n'      { newline(); }
        |   '\r'      { newline(); }
        )
        {$setType(Token.SKIP);} //ignore this token
    ;

--- In antlr-interest at yahoogroups.com, "lloyd_from_far" <ld at g...> 
wrote:
> OK, I think I had an answer which is unambiguous.
> or so so thought, ANTLR is firing me heaps of meaningless 
ambiguity 
> warning which I don't understand.
> 
> what about that ? (lexer is case insensitive)
> 
> IDENTIFIER: 
> 	NAME (SPACE | NAME) * 
> 	{ setText(getText().Trim()); }
> 	;
> 
> protected NAME options { testLiterals=true; }:
> 	( 'a' .. 'z' | '0' .. '9' | '_' | '$' | '#' | '.' ) +
> 	;
> protected SPACE: (' ') + ;
> 
> WS  :   (   SPACE
>         |   '\t'
>         |   '\r' '\n' { newline(); }
>         |   '\n'      { newline(); }
>         |   '\r'      { newline(); }
>         )
>         {$setType(Token.SKIP);} //ignore this token
>     ;
> 
> --- In antlr-interest at yahoogroups.com, "lloyd_from_far" <ld at g...> 
> wrote:
> > given this (or change this tokens as you see fit):
> > SELECT: "SELECT" ;
> > FROM: "FROM" ;
> > NAME: options { testLiterals=true; }:
> > 	( 'a' .. 'z' );
> > SPACE: (' ') +;
> > 
> > how would you cut the following string:
> > "SELECT a field name with plenty of space FROM aTable"
> > 
> > into the 4 following Tokens:
> > 'SELECT'
> > 'a field name with plenty of space'
> > 'FROM'
> > 'aTable'


 

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




More information about the antlr-interest mailing list