code_junkie

Antlr: Simplest way to recognize dates and numbers?

Nov 11th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. number: (MONTH|INT);
  2.  
  3. date: month '/' day ( '/' year )? -> ^('DATE' year month day);
  4.  
  5. foo: STRING OP number -> ^(OP STRING number);
  6. STRING: ('a'..'z')+;
  7. OP: ('<'|'>');
  8.  
  9. INT: '0'..'9'+;
  10.  
  11. DATENUM: '0' '1'..'9';
  12. INT: '0' | SIGN? '1'..'9' '0'..'9'*;
  13.  
  14. date: INT '/' INT ( '/' INT )?
  15.  
  16. date: (INT | DATENUM) '/' (INT | DATENUM) ('/' (INT | DATENUM) )?
  17.  
  18. date: month=INT '/' day=INT ( year='/' INT )? { year==null ? (/* First check /*) : (/* Second check */)}
Add Comment
Please, Sign In to add comment