I have this simple grammar
grammar Monto;
import util;
documento: .*? monto .+;
monto: SYMBOL INT+;
SYMBOL: '$';
And when I run that I get this error:
line 1:0 mismatched input '<EOF>'
I added EOF to my main rule but it does not works, I tried with this
documento: .*? monto .+ EOF;
or this
documento: .*? monto .+? EOF;
The curious is when I run that from cmd(ANTLR4 tool) it works
EDITED
I'm using ANLTR 4.7.1 and this is how I create the lexers and parsers
public GrammarModule(String text) {
CharStream input = CharStreams.fromString(text);
demandantesLexer = new DemandantesLexer(input);
demandantesParser = new DemandantesParser(new CommonTokenStream(demandantesLexer));
demandadosLexer = new DemandadosLexer(input);
demandadosParser = new DemandadosParser(new CommonTokenStream(demandadosLexer));
direccionLexer = new DireccionLexer(input);
direccionParser = new DireccionParser(new CommonTokenStream(direccionLexer));
fechaLexer = new FechaLexer(input);
fechaParser = new FechaParser(new CommonTokenStream(fechaLexer));
montoLexer = new MontoLexer(input);
montoParser = new MontoParser(new CommonTokenStream(montoLexer));
numCuentaLexer = new NumCuentaLexer(input);
numCuentaParser = new NumCuentaParser(new CommonTokenStream(numCuentaLexer));
oficioLexer = new OficioLexer(input);
oficioParser = new OficioParser(new CommonTokenStream(oficioLexer));
referenciaLexer = new ReferenciaLexer(input);
referenciaParser = new ReferenciaParser(new CommonTokenStream(referenciaLexer));
}
Invoking the parsers
fechaParser.documento().fecha().getText();
montoParser.documento().monto().getText();
so on...