MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / parse

Function parse

tools/alive_parser.cpp:1427–1473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1425}
1426
1427vector<Transform> parse(string_view buf) {
1428 vector<Transform> ret;
1429
1430 yylex_init(buf);
1431
1432 while (!tokenizer.empty()) {
1433 auto &t = ret.emplace_back();
1434 sym_num = struct_num = 0;
1435 parse_src = true;
1436
1437 parse_name(t);
1438 parse_pre(t);
1439 parse_fn(t.src);
1440 parse_arrow();
1441
1442 // copy inputs from src to target
1443 decltype(identifiers) identifiers_tgt;
1444 for (auto &val : t.src.getInputs()) {
1445 auto &name = val.getName();
1446 if (dynamic_cast<const Input*>(&val)) {
1447 auto input = make_unique<Input>(val.getType(), string(name));
1448 identifiers_tgt.emplace(name, input.get());
1449 t.tgt.addInput(std::move(input));
1450 } else {
1451 assert(dynamic_cast<const ConstantInput*>(&val));
1452 auto input = make_unique<ConstantInput>(val.getType(), string(name));
1453 identifiers_tgt.emplace(name, input.get());
1454 t.tgt.addInput(std::move(input));
1455 }
1456 }
1457 identifiers_src = std::move(identifiers);
1458 identifiers = std::move(identifiers_tgt);
1459
1460 parse_src = false;
1461 parse_fn(t.tgt);
1462
1463 // copy any missing instruction in tgt from src
1464 for (auto &[name, val] : identifiers_src) {
1465 get_or_copy_instr(name);
1466 }
1467
1468 identifiers.clear();
1469 identifiers_src.clear();
1470 }
1471
1472 return ret;
1473}
1474
1475
1476parser_initializer::parser_initializer() {

Callers 1

mainFunction · 0.70

Calls 9

parse_nameFunction · 0.85
parse_preFunction · 0.85
parse_fnFunction · 0.85
parse_arrowFunction · 0.85
getInputsMethod · 0.80
addInputMethod · 0.80
emptyMethod · 0.45
getMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected