| 27 | |
| 28 | namespace 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_)); |
nothing calls this directly
no test coverage detected