[antlr-interest] Tokens as keywords

Steve O'Hara sohara at pivotal-solutions.co.uk
Sat May 3 17:46:43 PDT 2008


I've written a grammar to unravel BASIS Find commands - these look very
similar to SQL Selects e.g.

    Find table where field='gdfdfg' order by field/ascend

All is well except when I try and parse a command that contains a token
as the table name.  For example;

    Find ascend where field='gdfdfg' order by field/ascend

This is a valid command - tables can be called practically anything.
Below is a snippet from the grammar.
Where do I look to go about fixing this?

statement :  FIND Identifier whereClause? orderByClause?;

ASC : ('asc' | 'ascend') ; 
FIND : 'find' ;
Identifier : ('a'..'z' | 'A'..'Z' | '_' | '\$') ('.' |  'a'..'z' |
'A'..'Z' | '_' | '0'..'9' | '$')* ;


Thanks,
Steve



More information about the antlr-interest mailing list