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

Method VisitInt

parser/parser.go:763–778  ·  view source on GitHub ↗

Visit a parse tree produced by CELParser#Int.

(ctx *gen.IntContext)

Source from the content-addressed store, hash-verified

761
762// Visit a parse tree produced by CELParser#Int.
763func (p *parser) VisitInt(ctx *gen.IntContext) any {
764 text := ctx.GetTok().GetText()
765 base := 10
766 if strings.HasPrefix(text, "0x") {
767 base = 16
768 text = text[2:]
769 }
770 if ctx.GetSign() != nil {
771 text = ctx.GetSign().GetText() + text
772 }
773 i, err := strconv.ParseInt(text, base, 64)
774 if err != nil {
775 return p.reportError(ctx, "invalid int literal")
776 }
777 return p.helper.newLiteralInt(ctx, i)
778}
779
780// Visit a parse tree produced by CELParser#Uint.
781func (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