I'm new to ANRL3 and I'm trying to parse
hello.
world 123. one two.
using the grammar
INT: '0'..'9'+ ;
WORD: 'a'..'z'+ ;
SENTENCE: ('a'..'z') ('a'..'z'|' ')+ ('a'..'z');
NEWLINE: '\n' ;
expression : WORD '.' NEWLINE
WORD ' ' INT '. ' SENTENCE '.';
When doing so I get the error
problem matching token at 2:7 NoViableAltException('1'@[()+ loopback of 5:22: ( 'a' .. 'z' | ' ' )+])
I'm reading this as when the 123
is encountered it thinks it's parsing a SENTENCE token.
Note that in the SENTENCE token if the space is replaced with _
and then I modified the input to have one_two
instead then the parsing works.
Is it possible to modify this grammar so that the one two
string can be parsed as a sentence?