I am completely new to ANTLR and EBNF grammars, so this is probably the main problem that I just don't understand.
I have a rule, for example:
version_line : WS? 'VERS' WS? '=' WS? '1.0' WS? EOL ;
WS : ' '+ ;
EOL : '\r' | '\n' | '\r\n' | '\n\r' ;
which matches the statement in my source file that looks like this (with an extra space):
VERSION = 1.0
With the rule form above, I get a successful match, although I get an exception with this form:
version_line : WS? 'VERS' WS? '=' WS? '1' '.0' WS? EOL ;
or this form:
version_line : WS? 'VERS' WS? '=' WS? DIGIT '.0' WS? EOL ;
DIGIT : '1' ;
Why is it different? I discovered this problem, trying to expand the rule even more, hopefully getting something like this:
version_line : WS? 'VERS' WS? '=' WS? DIGIT '.' DIGIT WS? EOL ;
DIGIT : '0'..'9' ;
source
share