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

Method parse_gfactor

erpcgen/src/cpptemplate/cpptempl.cpp:1328–1388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1326}
1327
1328data_ptr ExprParser::parse_gfactor()
1329{
1330 data_ptr ldata = parse_afactor();
1331
1332 token_type_t tokType = m_tok->get_type();
1333 if (tokType == token_type_t::GT_TOKEN || tokType == token_type_t::GE_TOKEN || tokType == token_type_t::LT_TOKEN || tokType == token_type_t::LE_TOKEN)
1334 {
1335 m_tok.next();
1336
1337 data_ptr rdata = parse_afactor();
1338
1339 std::shared_ptr<DataInt> li = std::dynamic_pointer_cast<DataInt>(ldata.get());
1340 std::shared_ptr<DataInt> ri = std::dynamic_pointer_cast<DataInt>(rdata.get());
1341
1342 if (li && ri)
1343 {
1344 int l = li->getint();
1345 int r = ri->getint();
1346 switch (tokType)
1347 {
1348 case token_type_t::GT_TOKEN:
1349 ldata = (l > r);
1350 break;
1351 case token_type_t::GE_TOKEN:
1352 ldata = (l >= r);
1353 break;
1354 case token_type_t::LT_TOKEN:
1355 ldata = (l < r);
1356 break;
1357 case token_type_t::LE_TOKEN:
1358 ldata = (l <= r);
1359 break;
1360 default:
1361 break;
1362 }
1363 }
1364 else
1365 {
1366 std::string lhs = ldata->getvalue();
1367 std::string rhs = rdata->getvalue();
1368 switch (tokType)
1369 {
1370 case token_type_t::GT_TOKEN:
1371 ldata = (lhs > rhs);
1372 break;
1373 case token_type_t::GE_TOKEN:
1374 ldata = (lhs >= rhs);
1375 break;
1376 case token_type_t::LT_TOKEN:
1377 ldata = (lhs < rhs);
1378 break;
1379 case token_type_t::LE_TOKEN:
1380 ldata = (lhs <= rhs);
1381 break;
1382 default:
1383 break;
1384 }
1385 }

Callers

nothing calls this directly

Calls 5

get_typeMethod · 0.80
getintMethod · 0.80
getvalueMethod · 0.80
nextMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected