()
| 270 | } |
| 271 | |
| 272 | func (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 | |
| 311 | func (p *parser) parseStringLiteral() (Value, error) { |
| 312 | p.pos++ // skip opening " |
no test coverage detected