diff --git a/internal/php5/parser.go b/internal/php5/parser.go index 04a37f3..1fe5085 100644 --- a/internal/php5/parser.go +++ b/internal/php5/parser.go @@ -36,6 +36,10 @@ func (p *Parser) Lex(lval *yySymType) int { } func (p *Parser) Error(msg string) { + if p.errHandlerFunc == nil { + return + } + var pos = p.currentToken.Position p.errHandlerFunc(errors.NewError(msg, &pos)) } diff --git a/internal/php7/parser.go b/internal/php7/parser.go index e7aa50e..f9530cc 100644 --- a/internal/php7/parser.go +++ b/internal/php7/parser.go @@ -35,6 +35,10 @@ func (p *Parser) Lex(lval *yySymType) int { } func (p *Parser) Error(msg string) { + if p.errHandlerFunc == nil { + return + } + var pos = p.currentToken.Position p.errHandlerFunc(errors.NewError(msg, &pos)) }