Own error reporting

19 views
Skip to first unread message

Andy

unread,
Apr 10, 2023, 3:07:43 PM4/10/23
to antlr-discussion
I want change error reporting behavior , because I want parse many files,
i want obtain:
- summary silent report, maybe stop after first error and return is error is in file

or

- add to report full path of tested file, to help my IDE go to error

Andy

unread,
Apr 10, 2023, 4:11:09 PM4/10/23
to antlr-discussion
I made:
std::ifstream ifs(filename);
ANTLRInputStream input(ifs);
C90Lexer lexer(&input);
auto errListener = lexer.getErrorListenerDispatch();
errListener.removeErrorListeners();
//errListener.addErrorListener(&FileErrorListener::INSTANCE);
CommonTokenStream tokens(&lexer);

C90Parser parser(&tokens);
errListener = parser.getErrorListenerDispatch();
errListener.removeErrorListeners();
//errListener.addErrorListener(&FileErrorListener::INSTANCE);
tree::ParseTree* tree = parser.compilationUnit();

but is old listener

Andy

unread,
Apr 10, 2023, 4:13:53 PM4/10/23
to antlr-discussion
Ok, must be reference
auto& lexErrListener = lexer.getErrorListenerDispatch();
lexErrListener.removeErrorListeners();

auto& parsErrListener = parser.getErrorListenerDispatch();
parsErrListener.removeErrorListeners();
Reply all
Reply to author
Forward
0 new messages