MCPcopy Create free account
hub / github.com/covscript/covscript / process_token_buff

Method process_token_buff

sources/compiler/lexer.cpp:481–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479 };
480
481 void
482 compiler_type::process_token_buff(std::deque<token_base *> &tokens, std::deque<std::deque<token_base *>> &ast)
483 {
484 std::deque<token_base *> oldt, expr;
485 std::swap(tokens, oldt);
486 tokens.clear();
487 for (auto &ptr : oldt) {
488 if (ptr->get_type() == token_types::signal &&
489 static_cast<token_signal *>(ptr)->get_signal() == signal_types::endline_)
490 ptr = new token_endline(ptr->get_line_num());
491 if (ptr->get_type() == token_types::action || ptr->get_type() == token_types::endline) {
492 if (!expr.empty()) {
493 translator.match_grammar(context, expr);
494 for (auto &it : expr)
495 tokens.push_back(it);
496 expr.clear();
497 }
498 tokens.push_back(ptr);
499 }
500 else
501 expr.push_back(ptr);
502 }
503 std::deque<token_base *> tmp;
504 for (auto &ptr : tokens) {
505 tmp.push_back(ptr);
506 if (ptr != nullptr && ptr->get_type() == token_types::endline) {
507 if (tmp.size() > 1)
508 ast.push_back(tmp);
509 tmp.clear();
510 }
511 }
512 if (tmp.size() > 1)
513 ast.push_back(tmp);
514 }
515
516 void compiler_type::translate_into_tokens(const std::deque<char> &char_buff, std::deque<token_base *> &tokens,
517 charset encoding)

Callers

nothing calls this directly

Calls 8

get_signalMethod · 0.80
match_grammarMethod · 0.80
sizeMethod · 0.80
swapFunction · 0.50
clearMethod · 0.45
get_typeMethod · 0.45
get_line_numMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected