My program uses the ANTLR (v4.8.0) C++ target for parsing. Now there is one machine, which I cannot access for fault-tracing, on which
line 1:0 mismatched input '<EOF>'
is reported for an input file which works fine on my machine. The error message makes me believe that ANTLR doesn’t find a single token, it’s like it was passed an empty stream. The input file is encoded with UTF8-BOM.
Both my machine and the one on which it doesn’t work runs Windows 10.
The code which loads the input stream is
antlr4::ANTLRInputStream antlrIs(inputAsUtf8);
A2lLexer lexer(&antlrIs);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
antlr4::CommonTokenStream tokens(&lexer);
// The strategy from https://groups.google.com/g/antlr-discussion/c/q-8MPVI9lrw has been tested
// and found to yield the same performance as this basic one.
XParser parser(&tokens);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
XParser::XFileContext* xFileContext = parser.xFile();
if (lexer.getNumberOfSyntaxErrors() || parser.getNumberOfSyntaxErrors())
{
throw runtime_error((string("Syntax error in ") + inputFile + ".").c_str());
}
The content of inputAsUtf8
looks fine when printed to console.
Any ideas on how to fault-trace this furher? I’m a bit stuck.
Source: Windows Questions C++