MCPcopy Create free account
hub / github.com/NICEXAI/ghost / parseBasicLit

Function parseBasicLit

parser/expr.go:107–133  ·  view source on GitHub ↗
(expr *ast.BasicLit)

Source from the content-addressed store, hash-verified

105}
106
107func parseBasicLit(expr *ast.BasicLit) (interface{}, error) {
108 var err error
109
110 if expr.Kind.String() == "INT" {
111 var res int64
112 res, err = strconv.ParseInt(expr.Value, 10, 0)
113 if err != nil {
114 return nil, err
115 }
116 return int(res), nil
117 }
118
119 if expr.Kind.String() == "FLOAT" {
120 var res float64
121 res, err = strconv.ParseFloat(expr.Value, 0)
122 if err != nil {
123 return nil, err
124 }
125 return res, nil
126 }
127
128 if expr.Kind.String() == "STRING" {
129 return expr.Value[1 : len(expr.Value)-1], nil
130 }
131
132 return expr.Value, nil
133}

Callers 2

ParseAndExecuteExprFunction · 0.85
parseBinaryExprFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected