Below is a simple ANTLR grammar:
grammar EXAMPLE;
document
: Name+ EOF ;
Name
: 'k'+ ;
The generated antlr parser accepts any string that contains substring 'k'.
However, I want the parser to accept only strings that conform to the grammar. that is, strings that contain characters other than 'k' should trigger an error.
Is there a way to ensure that?
I tried modifying the grammar. And testing with different inputs. But no fix worked.
Fubar: .;. The parser will now keep track of the error.