[antlr-interest] [Antlr3 grammar] how to specify alpha token,	numeric token and mix of 	both
    Hieu Phung 
    phungngochieu at gmail.com
       
    Wed Oct 21 03:23:47 PDT 2009
    
    
  
Hi all,
My grammar has 3 kinds of tokens:
1) number: contain numeric character
2) alpha: contain alphabetic character;
3) mix: contain number and alpha and hyphen, full stop or space
For example:
1/VEC305/03MAR/PTY
=> in the above input data, 03MAR should be interpreted as a number of
length 2 followed by alpha of length 3. But VEC305 is a mix of length 6.
If I define grammar like below:
NUMBER    : ('0'..'9')+ ;
ALPHA    : ('a'..'z'|'A'..'Z')+;
MIX    : (NUMBER | ALPHA | OTHER)+;
fragment OTHER    : (' ' | '-' | '.')+;
SLANT    :    '/';
Antlr will return me VEC305 and 03MAR as two MIX tokens. Is there any way to
define tokens such that Antlr will return me number, slant, mix, slant,
number, alpha, slant, alpha for the input "1/VEC305/03MAR/PTY" ?
Thank you very much for your suggestions.
Regards,
Helen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091021/c2aac0a2/attachment.html 
    
    
More information about the antlr-interest
mailing list