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

Method kill_brackets

sources/compiler/parser.cpp:29–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28namespace cs {
29 void compiler_type::kill_brackets(std::deque<token_base *> &tokens, std::size_t
30 line_num)
31 {
32 std::deque<token_base *> oldt;
33 std::swap(tokens, oldt);
34 tokens.clear();
35 bool insert_vardef = false;
36 bool insert_varchk = false;
37 bool expected_fdef = false;
38 bool expected_fcall = false;
39 bool expected_lambda = false;
40 for (auto oldt_it = oldt.begin(); oldt_it != oldt.end(); ++oldt_it) {
41 token_base *ptr = *oldt_it;
42 switch (ptr->get_type()) {
43 default:
44 break;
45 case token_types::action:
46 expected_fcall = false;
47 switch (static_cast<token_action *>(ptr)->get_action()) {
48 default:
49 break;
50 case action_types::import_: {
51 // Look Ahead
52 bool found_as = false;
53 for (auto it = oldt_it + 1; it != oldt.end(); ++it) {
54 token_base *token = *it;
55 if (token->get_type() == token_types::endline)
56 break;
57 if (token->get_type() == token_types::action &&
58 static_cast<token_action *>(token)->get_action() == action_types::as_) {
59 found_as = true;
60 break;
61 }
62 }
63 tokens.push_back(ptr);
64 if (!found_as) {
65 insert_vardef = true;
66 tokens.push_back(new token_signal(signal_types::vardef_));
67 }
68 continue;
69 }
70 case action_types::as_:
71 tokens.push_back(ptr);
72 tokens.push_back(new token_signal(signal_types::vardef_));
73 continue;
74 case action_types::var_:
75 insert_varchk = true;
76 tokens.push_back(ptr);
77 tokens.push_back(new token_signal(signal_types::varchk_));
78 continue;
79 case action_types::constant_:
80 insert_varchk = true;
81 tokens.push_back(ptr);
82 tokens.push_back(new token_signal(signal_types::varchk_));
83 continue;
84 case action_types::for_:
85 tokens.push_back(ptr);
86 tokens.push_back(new token_signal(signal_types::varprt_));

Callers

nothing calls this directly

Calls 9

compile_errorClass · 0.85
get_actionMethod · 0.80
sizeMethod · 0.80
get_signalMethod · 0.80
swapFunction · 0.50
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
get_typeMethod · 0.45

Tested by

no test coverage detected