MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / parse_factor

Method parse_factor

erpcgen/src/cpptemplate/cpptempl.cpp:1237–1298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1235}
1236
1237data_ptr ExprParser::parse_factor()
1238{
1239 token_type_t tokType = m_tok->get_type();
1240 data_ptr result;
1241 switch (tokType)
1242 {
1243 case token_type_t::NOT_TOKEN:
1244 m_tok.next();
1245 result = parse_expr()->empty();
1246 break;
1247 case token_type_t::MINUS_TOKEN:
1248 m_tok.next();
1249 result = -(parse_expr()->getint());
1250 break;
1251 case token_type_t::OPEN_PAREN_TOKEN:
1252 m_tok.next();
1253 result = parse_expr();
1254 m_tok.match(token_type_t::CLOSE_PAREN_TOKEN, "expected close paren");
1255 break;
1256 case token_type_t::STRING_LITERAL_TOKEN:
1257 result = m_tok.match(token_type_t::STRING_LITERAL_TOKEN)->get_value();
1258 break;
1259 case token_type_t::TRUE_TOKEN:
1260 m_tok.next();
1261 result = true;
1262 break;
1263 case token_type_t::FALSE_TOKEN:
1264 m_tok.next();
1265 result = false;
1266 break;
1267 case token_type_t::INT_LITERAL_TOKEN: {
1268 const Token *literal = m_tok.match(token_type_t::INT_LITERAL_TOKEN, "expected int literal");
1269 return new DataInt((int)std::strtol(literal->get_value().c_str(), NULL, 0));
1270 break;
1271 }
1272 case token_type_t::KEY_PATH_TOKEN: {
1273 const Token *path = m_tok.match(token_type_t::KEY_PATH_TOKEN, "expected key path");
1274
1275 data_list params;
1276 if (m_tok->get_type() == token_type_t::OPEN_PAREN_TOKEN)
1277 {
1278 m_tok.match(token_type_t::OPEN_PAREN_TOKEN);
1279
1280 while (m_tok->get_type() != token_type_t::CLOSE_PAREN_TOKEN)
1281 {
1282 params.push_back(parse_expr());
1283
1284 if (m_tok->get_type() != token_type_t::CLOSE_PAREN_TOKEN)
1285 {
1286 m_tok.match(token_type_t::COMMA_TOKEN, "expected comma");
1287 }
1288 }
1289 m_tok.match(token_type_t::CLOSE_PAREN_TOKEN, "expected close paren");
1290 }
1291
1292 return get_var_value(path->get_value(), params);
1293 }
1294 default:

Callers

nothing calls this directly

Calls 7

TemplateExceptionClass · 0.85
get_typeMethod · 0.80
getintMethod · 0.80
matchMethod · 0.80
push_backMethod · 0.80
nextMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected