From 84fe08869dfa46dc7f365cbdb0b49f3fef39636e Mon Sep 17 00:00:00 2001 From: Vadym Slizov Date: Sat, 4 Jul 2020 18:04:12 +0300 Subject: [PATCH] [refactoring] allow nil parser.errHandlerFunc --- internal/php5/parser.go | 4 ++++ internal/php7/parser.go | 4 ++++ 2 files changed, 8 insertions(+) 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)) }