You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If underlying lexer encounters input error, it uses defaultError handling function that prints an error to stderr.
func (l*Lexer) defaultErrorf(pos token.Pos, msgstring) {
l.Error(fmt.Sprintf("%v: %v", l.File.Position(pos), msg))
}
// Error Implements yyLexer[2] by printing the msg to stderr.func (l*Lexer) Error(msgstring) {
fmt.Fprintf(os.Stderr, "%s\n", msg)
}
On a large codebase it sometimes leads to this message:
unicode (UTF-8) BOM in middle of file
There is no way to control it and this is the problem.
I'm proposing a change (example below) that will register our own error handling function that will push lex error to the high-level lexer errors list. This way, errors can propagate and be handled without stderr pollution.
You right, errors of the lexer should be saved into lexer.Errors.
Thank you for the proposal, I have used it as is.
Also, I have covered this case by the test.
If underlying lexer encounters input error, it uses defaultError handling function that prints an error to stderr.
On a large codebase it sometimes leads to this message:
There is no way to control it and this is the problem.
I'm proposing a change (example below) that will register our own error handling function that will push lex error to the high-level lexer errors list. This way, errors can propagate and be handled without stderr pollution.
The text was updated successfully, but these errors were encountered: