[refactoring] allow nil parser.errHandlerFunc

This commit is contained in:
Vadym Slizov 2020-07-04 18:04:12 +03:00
parent 476e84229d
commit 84fe08869d
2 changed files with 8 additions and 0 deletions

View File

@ -36,6 +36,10 @@ func (p *Parser) Lex(lval *yySymType) int {
} }
func (p *Parser) Error(msg string) { func (p *Parser) Error(msg string) {
if p.errHandlerFunc == nil {
return
}
var pos = p.currentToken.Position var pos = p.currentToken.Position
p.errHandlerFunc(errors.NewError(msg, &pos)) p.errHandlerFunc(errors.NewError(msg, &pos))
} }

View File

@ -35,6 +35,10 @@ func (p *Parser) Lex(lval *yySymType) int {
} }
func (p *Parser) Error(msg string) { func (p *Parser) Error(msg string) {
if p.errHandlerFunc == nil {
return
}
var pos = p.currentToken.Position var pos = p.currentToken.Position
p.errHandlerFunc(errors.NewError(msg, &pos)) p.errHandlerFunc(errors.NewError(msg, &pos))
} }