I want to parse few date format using following ANTLR4 grammar.
grammar Variables;
//varTable : tableNameFormat dateFormat? ;
//tableNameFormat: (ID SEPERATO
In my case it works. I am getting a correct parsetree with the input: 2016-01-01
grammar date;
dateFormat : year UNDERSCORE month UNDERSCORE today
| year
;
year : DIGIT DIGIT DIGIT DIGIT
;
month : DIGIT DIGIT
;
today : DIGIT DIGIT
;
UNDERSCORE: ('_' | '-' );
DIGIT : [0-9] ;
But I would use for month
something like (0 [1-9] | 1 [0-2])
because there are only 12 months.