Creating Date and Time in ANTLR

Creating Date and Time in Antler
Creating Date and Time in Antler

This is an example of how to make a “Calender”.

grammer time;

// parser:
start : DATE TIME* EOF;

// Lexer:

DATE : DAy '.' MONTH '.' ;

fragment
DAY : '0'?[1-9] | [1-2][0-9] | '3'[0-1] ;

fragment
MONTH: '0'? [1-9] | '1' [0-2];

TIME : [0-9]+ '\n';

INT : '-'? [0-9]+ ;
INTv2 : '-'? DIGIT+ ;

fragment
DIGIT : [0-9];

FLOAT : '-'? DIGIT+ ('.'DIGIT+)? ('E' DIGIT+)? ;

IDENT : [a-zA-Z_][a-zA-Z_0-9]* ;

COMMENT : '//' ~[\n]* '\n' -> skip ;
WHITESPACE : [ \t\n] -> skip;