MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / parse_primary_expression

Method parse_primary_expression

src/pugiXML/pugixml.cpp:9005–9105  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

9003
9004 // PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall
9005 xpath_ast_node* parse_primary_expression()
9006 {
9007 switch (_lexer.current())
9008 {
9009 case lex_var_ref:
9010 {
9011 xpath_lexer_string name = _lexer.contents();
9012
9013 if (!_variables)
9014 throw_error("Unknown variable: variable set is not provided");
9015
9016 xpath_variable* var = get_variable(_variables, name.begin, name.end);
9017
9018 if (!var)
9019 throw_error("Unknown variable: variable set does not contain the given name");
9020
9021 _lexer.next();
9022
9023 return new (alloc_node()) xpath_ast_node(ast_variable, var->type(), var);
9024 }
9025
9026 case lex_open_brace:
9027 {
9028 _lexer.next();
9029
9030 xpath_ast_node* n = parse_expression();
9031
9032 if (_lexer.current() != lex_close_brace)
9033 throw_error("Unmatched braces");
9034
9035 _lexer.next();
9036
9037 return n;
9038 }
9039
9040 case lex_quoted_string:
9041 {
9042 const char_t* value = alloc_string(_lexer.contents());
9043
9044 xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_string_constant, xpath_type_string, value);
9045 _lexer.next();
9046
9047 return n;
9048 }
9049
9050 case lex_number:
9051 {
9052 double value = 0;
9053
9054 if (!convert_string_to_number(_lexer.contents().begin, _lexer.contents().end, &value))
9055 throw_error_oom();
9056
9057 xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value);
9058 _lexer.next();
9059
9060 return n;
9061 }
9062

Callers

nothing calls this directly

Calls 5

convert_string_to_numberFunction · 0.85
currentMethod · 0.80
nextMethod · 0.80
set_nextMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected