I'm writing a grammar for a moderately sized language, and I'm trying to implement time literals of the form hh:mm:ss
.
However, whenever I try to parse, for example, 12:34:56
as a timeLiteral
, I get mismatched token exceptions on the digits. Does anyone know what I might be doing wrong?
Here are the relevant rules as currently defined:
timeLiteral
: timePair COLON timePair COLON timePair -> ^(TIMELIT timePair*)
;
timePair
: DecimalDigit DecimalDigit
;
NumericLiteral
: DecimalLiteral
;
fragment DecimalLiteral
: DecimalDigit+ ('.' DecimalDigit+)?
;
fragment DecimalDigit
: ('0'..'9')
;