()
| 392 | } |
| 393 | |
| 394 | private parseVariableValue(): LiteralValue { |
| 395 | const token = this.peek(); |
| 396 | |
| 397 | switch (token.type) { |
| 398 | case TokenType.STRING: |
| 399 | return this.parseStringLiteral(); |
| 400 | case TokenType.NUMBER: |
| 401 | return this.parseNumberLiteral(); |
| 402 | case TokenType.IDENTIFIER: |
| 403 | return this.parseIdentifierLiteral(); |
| 404 | case TokenType.LEFT_PAREN: |
| 405 | return this.parseTupleLiteral(); |
| 406 | default: |
| 407 | throw new ParserError( |
| 408 | `Invalid variable value: ${token.value}. Variables can only contain literal values (strings, numbers, identifiers, or tuples)`, |
| 409 | token.position |
| 410 | ); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | private parseElement(): ElementNode { |
| 415 | const nameToken = this.consume( |
no test coverage detected