MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / parseAtom

Method parseAtom

go/engine/expr/parser.go:272–309  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

270}
271
272func (p *parser) parseAtom() (Value, error) {
273 p.skipWhitespace()
274 if p.pos >= len(p.input) {
275 return Value{}, fmt.Errorf("unexpected end of expression")
276 }
277
278 // Parenthesized sub-expression
279 if p.input[p.pos] == '(' {
280 p.pos++
281 val, err := p.parseOr()
282 if err != nil {
283 return Value{}, err
284 }
285 p.skipWhitespace()
286 if p.pos < len(p.input) && p.input[p.pos] == ')' {
287 p.pos++
288 }
289 return val, nil
290 }
291
292 // String literal
293 if p.input[p.pos] == '"' {
294 return p.parseStringLiteral()
295 }
296
297 // Boolean literals
298 if strings.HasPrefix(p.input[p.pos:], "true") && !isIdentChar(p.safeCharAt(p.pos+4)) {
299 p.pos += 4
300 return BoolVal(true), nil
301 }
302 if strings.HasPrefix(p.input[p.pos:], "false") && !isIdentChar(p.safeCharAt(p.pos+5)) {
303 p.pos += 5
304 return BoolVal(false), nil
305 }
306
307 // Numeric literal (int or float)
308 return p.parseNumber()
309}
310
311func (p *parser) parseStringLiteral() (Value, error) {
312 p.pos++ // skip opening "

Callers 1

parseUnaryMethod · 0.95

Calls 7

skipWhitespaceMethod · 0.95
parseOrMethod · 0.95
parseStringLiteralMethod · 0.95
safeCharAtMethod · 0.95
parseNumberMethod · 0.95
isIdentCharFunction · 0.85
BoolValFunction · 0.85

Tested by

no test coverage detected