MCPcopy Create free account
hub / github.com/MyGUI/mygui / parse_primary_expression

Method parse_primary_expression

UnitTests/TestApp/pugixml.cpp:9793–9892  ·  view source on GitHub ↗

PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall

Source from the content-addressed store, hash-verified

9791
9792 // PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall
9793 xpath_ast_node* parse_primary_expression()
9794 {
9795 switch (_lexer.current())
9796 {
9797 case lex_var_ref:
9798 {
9799 xpath_lexer_string name = _lexer.contents();
9800
9801 if (!_variables)
9802 throw_error("Unknown variable: variable set is not provided");
9803
9804 xpath_variable* var = get_variable(_variables, name.begin, name.end);
9805
9806 if (!var)
9807 throw_error("Unknown variable: variable set does not contain the given name");
9808
9809 _lexer.next();
9810
9811 return new (alloc_node()) xpath_ast_node(ast_variable, var->type(), var);
9812 }
9813
9814 case lex_open_brace:
9815 {
9816 _lexer.next();
9817
9818 xpath_ast_node* n = parse_expression();
9819
9820 if (_lexer.current() != lex_close_brace)
9821 throw_error("Unmatched braces");
9822
9823 _lexer.next();
9824
9825 return n;
9826 }
9827
9828 case lex_quoted_string:
9829 {
9830 const char_t* value = alloc_string(_lexer.contents());
9831
9832 xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_string_constant, xpath_type_string, value);
9833 _lexer.next();
9834
9835 return n;
9836 }
9837
9838 case lex_number:
9839 {
9840 double value = 0;
9841
9842 if (!convert_string_to_number(_lexer.contents().begin, _lexer.contents().end, &value))
9843 throw_error_oom();
9844
9845 xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value);
9846 _lexer.next();
9847
9848 return n;
9849 }
9850

Callers

nothing calls this directly

Calls 5

convert_string_to_numberFunction · 0.70
currentMethod · 0.45
nextMethod · 0.45
typeMethod · 0.45
set_nextMethod · 0.45

Tested by

no test coverage detected