Forked gval and upgraded to 1.2.2

This commit is contained in:
Peter Grlica
2024-06-13 10:53:44 +02:00
parent fbacfdd121
commit 944c2bcfcd
7 changed files with 12 additions and 183 deletions
+1 -1
View File
@@ -225,7 +225,7 @@ func (*Parser) callEvaluable(fullname string, fun Evaluable, args ...Evaluable)
f, err := fun(c, v)
if err != nil {
return nil, fmt.Errorf("could not call function: %v", err)
return nil, fmt.Errorf("could not call function: %w", err)
}
defer func() {
+2 -2
View File
@@ -69,7 +69,7 @@ func (l Language) NewEvaluableWithContext(c context.Context, expression string)
}
if err != nil {
pos := p.scanner.Pos()
return nil, fmt.Errorf("parsing error: %s - %d:%d %s", p.scanner.Position, pos.Line, pos.Column, err)
return nil, fmt.Errorf("parsing error: %s - %d:%d %w", p.scanner.Position, pos.Line, pos.Column, err)
}
return eval, nil
@@ -88,7 +88,7 @@ func (l Language) EvaluateWithContext(c context.Context, expression string, para
}
v, err := eval(c, parameter)
if err != nil {
return nil, fmt.Errorf("can not evaluate %s: %v", expression, err)
return nil, fmt.Errorf("can not evaluate %s: %w", expression, err)
}
return v, nil
}
+1 -1
View File
@@ -79,7 +79,7 @@ func (p *Parser) parse(c context.Context) (Evaluable, error) {
func parseString(c context.Context, p *Parser) (Evaluable, error) {
s, err := strconv.Unquote(p.TokenText())
if err != nil {
return nil, fmt.Errorf("could not parse string: %s", err)
return nil, fmt.Errorf("could not parse string: %w", err)
}
return p.Const(s), nil
}
+1 -1
View File
@@ -78,7 +78,7 @@ func (p *Parser) isCamouflaged() bool {
// Do not call Rewind() on a camouflaged Parser
func (p *Parser) Camouflage(unit string, expected ...rune) {
if p.isCamouflaged() {
panic(fmt.Errorf("can only Camouflage() after Scan(): %v", p.camouflage))
panic(fmt.Errorf("can only Camouflage() after Scan(): %w", p.camouflage))
}
p.camouflage = p.Expected(unit, expected...)
}