PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall
| 8372 | |
| 8373 | // PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall |
| 8374 | xpath_ast_node* parse_primary_expression() |
| 8375 | { |
| 8376 | switch (_lexer.current()) |
| 8377 | { |
| 8378 | case lex_var_ref: |
| 8379 | { |
| 8380 | xpath_lexer_string name = _lexer.contents(); |
| 8381 | |
| 8382 | if (!_variables) |
| 8383 | throw_error("Unknown variable: variable set is not provided"); |
| 8384 | |
| 8385 | xpath_variable* var = get_variable(_variables, name.begin, name.end); |
| 8386 | |
| 8387 | if (!var) |
| 8388 | throw_error("Unknown variable: variable set does not contain the given name"); |
| 8389 | |
| 8390 | _lexer.next(); |
| 8391 | |
| 8392 | return new (alloc_node()) xpath_ast_node(ast_variable, var->type(), var); |
| 8393 | } |
| 8394 | |
| 8395 | case lex_open_brace: |
| 8396 | { |
| 8397 | _lexer.next(); |
| 8398 | |
| 8399 | xpath_ast_node* n = parse_expression(); |
| 8400 | |
| 8401 | if (_lexer.current() != lex_close_brace) |
| 8402 | throw_error("Unmatched braces"); |
| 8403 | |
| 8404 | _lexer.next(); |
| 8405 | |
| 8406 | return n; |
| 8407 | } |
| 8408 | |
| 8409 | case lex_quoted_string: |
| 8410 | { |
| 8411 | const char_t* value = alloc_string(_lexer.contents()); |
| 8412 | |
| 8413 | xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_string_constant, xpath_type_string, value); |
| 8414 | _lexer.next(); |
| 8415 | |
| 8416 | return n; |
| 8417 | } |
| 8418 | |
| 8419 | case lex_number: |
| 8420 | { |
| 8421 | double value = 0; |
| 8422 | |
| 8423 | if (!convert_string_to_number(_lexer.contents().begin, _lexer.contents().end, &value)) |
| 8424 | throw_error_oom(); |
| 8425 | |
| 8426 | xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value); |
| 8427 | _lexer.next(); |
| 8428 | |
| 8429 | return n; |
| 8430 | } |
| 8431 |
nothing calls this directly
no test coverage detected