mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-11 18:45:36 +00:00
Update cel-go to v0.21.0
This commit is contained in:
20
vendor/github.com/google/cel-go/parser/helper.go
generated
vendored
20
vendor/github.com/google/cel-go/parser/helper.go
generated
vendored
@@ -140,15 +140,12 @@ func (p *parserHelper) id(ctx any) int64 {
|
||||
var offset ast.OffsetRange
|
||||
switch c := ctx.(type) {
|
||||
case antlr.ParserRuleContext:
|
||||
start, stop := c.GetStart(), c.GetStop()
|
||||
if stop == nil {
|
||||
stop = start
|
||||
}
|
||||
start := c.GetStart()
|
||||
offset.Start = p.sourceInfo.ComputeOffset(int32(start.GetLine()), int32(start.GetColumn()))
|
||||
offset.Stop = p.sourceInfo.ComputeOffset(int32(stop.GetLine()), int32(stop.GetColumn()))
|
||||
offset.Stop = offset.Start + int32(len(c.GetText()))
|
||||
case antlr.Token:
|
||||
offset.Start = p.sourceInfo.ComputeOffset(int32(c.GetLine()), int32(c.GetColumn()))
|
||||
offset.Stop = offset.Start
|
||||
offset.Stop = offset.Start + int32(len(c.GetText()))
|
||||
case common.Location:
|
||||
offset.Start = p.sourceInfo.ComputeOffset(int32(c.Line()), int32(c.Column()))
|
||||
offset.Stop = offset.Start
|
||||
@@ -164,10 +161,21 @@ func (p *parserHelper) id(ctx any) int64 {
|
||||
return id
|
||||
}
|
||||
|
||||
func (p *parserHelper) deleteID(id int64) {
|
||||
p.sourceInfo.ClearOffsetRange(id)
|
||||
if id == p.nextID-1 {
|
||||
p.nextID--
|
||||
}
|
||||
}
|
||||
|
||||
func (p *parserHelper) getLocation(id int64) common.Location {
|
||||
return p.sourceInfo.GetStartLocation(id)
|
||||
}
|
||||
|
||||
func (p *parserHelper) getLocationByOffset(offset int32) common.Location {
|
||||
return p.getSourceInfo().GetLocationByOffset(offset)
|
||||
}
|
||||
|
||||
// buildMacroCallArg iterates the expression and returns a new expression
|
||||
// where all macros have been replaced by their IDs in MacroCalls
|
||||
func (p *parserHelper) buildMacroCallArg(expr ast.Expr) ast.Expr {
|
||||
|
||||
8
vendor/github.com/google/cel-go/parser/macro.go
generated
vendored
8
vendor/github.com/google/cel-go/parser/macro.go
generated
vendored
@@ -382,13 +382,11 @@ func makeQuantifier(kind quantifierKind, eh ExprHelper, target ast.Expr, args []
|
||||
step = eh.NewCall(operators.LogicalOr, eh.NewAccuIdent(), args[1])
|
||||
result = eh.NewAccuIdent()
|
||||
case quantifierExistsOne:
|
||||
zeroExpr := eh.NewLiteral(types.Int(0))
|
||||
oneExpr := eh.NewLiteral(types.Int(1))
|
||||
init = zeroExpr
|
||||
init = eh.NewLiteral(types.Int(0))
|
||||
condition = eh.NewLiteral(types.True)
|
||||
step = eh.NewCall(operators.Conditional, args[1],
|
||||
eh.NewCall(operators.Add, eh.NewAccuIdent(), oneExpr), eh.NewAccuIdent())
|
||||
result = eh.NewCall(operators.Equals, eh.NewAccuIdent(), oneExpr)
|
||||
eh.NewCall(operators.Add, eh.NewAccuIdent(), eh.NewLiteral(types.Int(1))), eh.NewAccuIdent())
|
||||
result = eh.NewCall(operators.Equals, eh.NewAccuIdent(), eh.NewLiteral(types.Int(1)))
|
||||
default:
|
||||
return nil, eh.NewError(args[0].ID(), fmt.Sprintf("unrecognized quantifier '%v'", kind))
|
||||
}
|
||||
|
||||
12
vendor/github.com/google/cel-go/parser/parser.go
generated
vendored
12
vendor/github.com/google/cel-go/parser/parser.go
generated
vendored
@@ -856,7 +856,8 @@ func (p *parser) reportError(ctx any, format string, args ...any) ast.Expr {
|
||||
|
||||
// ANTLR Parse listener implementations
|
||||
func (p *parser) SyntaxError(recognizer antlr.Recognizer, offendingSymbol any, line, column int, msg string, e antlr.RecognitionException) {
|
||||
l := p.helper.source.NewLocation(line, column)
|
||||
offset := p.helper.sourceInfo.ComputeOffset(int32(line), int32(column))
|
||||
l := p.helper.getLocationByOffset(offset)
|
||||
// Hack to keep existing error messages consistent with previous versions of CEL when a reserved word
|
||||
// is used as an identifier. This behavior needs to be overhauled to provide consistent, normalized error
|
||||
// messages out of ANTLR to prevent future breaking changes related to error message content.
|
||||
@@ -916,10 +917,12 @@ func (p *parser) expandMacro(exprID int64, function string, target ast.Expr, arg
|
||||
expr, err := macro.Expander()(eh, target, args)
|
||||
// An error indicates that the macro was matched, but the arguments were not well-formed.
|
||||
if err != nil {
|
||||
if err.Location != nil {
|
||||
return p.reportError(err.Location, err.Message), true
|
||||
loc := err.Location
|
||||
if loc == nil {
|
||||
loc = p.helper.getLocation(exprID)
|
||||
}
|
||||
return p.reportError(p.helper.getLocation(exprID), err.Message), true
|
||||
p.helper.deleteID(exprID)
|
||||
return p.reportError(loc, err.Message), true
|
||||
}
|
||||
// A nil value from the macro indicates that the macro implementation decided that
|
||||
// an expansion should not be performed.
|
||||
@@ -929,6 +932,7 @@ func (p *parser) expandMacro(exprID int64, function string, target ast.Expr, arg
|
||||
if p.populateMacroCalls {
|
||||
p.helper.addMacroCall(expr.ID(), function, target, args...)
|
||||
}
|
||||
p.helper.deleteID(exprID)
|
||||
return expr, true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user