parser.go: added recover from panic in parser.Parse()
This commit is contained in:
parent
610e2df5f5
commit
edd90054d7
10
parser.go
10
parser.go
@ -382,6 +382,16 @@ func (parser *parser) parseItem(scanner *scanner, ctx parserContext, termSymbols
|
||||
}
|
||||
|
||||
func (parser *parser) Parse(scanner *scanner, termSymbols ...Symbol) (tree *ast, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if errVal, ok := r.(error); ok {
|
||||
err = errVal
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
err = errors.New("unexpected error while parsing the expression")
|
||||
}
|
||||
}()
|
||||
termSymbols = append(termSymbols, SymEos)
|
||||
return parser.parseGeneral(scanner, allowMultiExpr, termSymbols...)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user