parseVariantFieldName consumes one VARIANT path field name, which may be a bare identifier or a double-quoted string. Returns the name and advances past it.
()
| 456 | // a bare identifier or a double-quoted string. Returns the name and |
| 457 | // advances past it. |
| 458 | func (p *Parser) parseVariantFieldName() (string, error) { |
| 459 | tok := p.currentToken.Token |
| 460 | switch { |
| 461 | case p.isIdentifier(), p.isType(models.TokenTypeDoubleQuotedString): |
| 462 | name := tok.Value |
| 463 | p.advance() |
| 464 | return name, nil |
| 465 | case p.isType(models.TokenTypeKeyword): |
| 466 | // Keywords may appear as field names (e.g. TYPE, VALUE, STATUS). |
| 467 | name := tok.Value |
| 468 | p.advance() |
| 469 | return name, nil |
| 470 | } |
| 471 | return "", p.expectedError("field name after `:` or `.`") |
| 472 | } |
no test coverage detected