I am a newbie to antlr. I want to write a grammar to parse the below input:
commit a1b2c3d4
The grammar is given below ::
grammar commit;
file : 'commit' COMMITHASH NEWLINE;
COMMITHASH : [a-z0-9]+;
DATE : ~[\r\n]+;
NEWLINE : '\r'?'\n';
When I try parsing the above input using the grammar, it throws the below exception::
line 1:0 mismatched input 'commit a1b2c3d4' expecting 'commit'
Note : I have intentionally added the DATE token. Without the DATE token, it works fine. But I would like to know, what is happening when the DATE token is added.
I had referred the link Antlr4: Mismatched input but am not still clear about what happened.