MCPcopy Create free account
hub / github.com/cel-expr/cel-go / VisitInt

Method VisitInt

parser/parser.go:771–786  ·  view source on GitHub ↗

Visit a parse tree produced by CELParser#Int.

(ctx *gen.IntContext)

Source from the content-addressed store, hash-verified

769
770// Visit a parse tree produced by CELParser#Int.
771func (p *parser) VisitInt(ctx *gen.IntContext) any {
772 text := ctx.GetTok().GetText()
773 base := 10
774 if strings.HasPrefix(text, "0x") {
775 base = 16
776 text = text[2:]
777 }
778 if ctx.GetSign() != nil {
779 text = ctx.GetSign().GetText() + text
780 }
781 i, err := strconv.ParseInt(text, base, 64)
782 if err != nil {
783 return p.reportError(ctx, "invalid int literal")
784 }
785 return p.helper.newLiteralInt(ctx, i)
786}
787
788// Visit a parse tree produced by CELParser#Uint.
789func (p *parser) VisitUint(ctx *gen.UintContext) any {

Callers 1

VisitMethod · 0.95

Calls 5

reportErrorMethod · 0.95
GetTextMethod · 0.80
newLiteralIntMethod · 0.80
GetTokMethod · 0.45
GetSignMethod · 0.45

Tested by

no test coverage detected