| OLD | NEW |
| 1 #include "lexer/even-more-experimental-scanner.h" | 1 #include "lexer/even-more-experimental-scanner.h" |
| 2 | 2 |
| 3 | 3 |
| 4 {# TODO implement CLASS checks #} | 4 {# TODO implement CLASS checks #} |
| 5 {%- macro do_key(key) -%} | 5 {%- macro do_key(key) -%} |
| 6 {%- for r in key -%} | 6 {%- for r in key -%} |
| 7 {%- if not loop.first %} || {% endif -%} | 7 {%- if not loop.first %} || {% endif -%} |
| 8 {%- if r[0] == 'LATIN_1' -%} | 8 {%- if r[0] == 'LATIN_1' -%} |
| 9 {%- if r[1][0] == r[1][1] -%} | 9 {%- if r[1][0] == r[1][1] -%} |
| 10 yych == {{r[1][0]}} | 10 yych == {{r[1][0]}} |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 {%- set entry_action = state.entry_action -%} | 77 {%- set entry_action = state.entry_action -%} |
| 78 {%- if entry_action %} | 78 {%- if entry_action %} |
| 79 {{ dispatch_action(entry_action[0], entry_action[1]) }} | 79 {{ dispatch_action(entry_action[0], entry_action[1]) }} |
| 80 {%- endif %} | 80 {%- endif %} |
| 81 | 81 |
| 82 {%- if debug_print %} | 82 {%- if debug_print %} |
| 83 fprintf(stderr, "char at hand is %c (%d)\n", yych, yych); | 83 fprintf(stderr, "char at hand is %c (%d)\n", yych, yych); |
| 84 {% endif -%} | 84 {% endif -%} |
| 85 | 85 |
| 86 {%- macro do_transition(transition_state_id) -%} |
| 87 {%- set inline_transition = dfa_states[transition_state_id]['inline'] %} |
| 88 FORWARD(); |
| 89 {%- if inline_transition %} |
| 90 {{ do_dfa_state(transition_state_id, True) }} |
| 91 {% else %} |
| 92 goto code_{{transition_state_id}}; |
| 93 {% endif %} |
| 94 {%- endmacro -%} |
| 95 |
| 86 {%- if state['switch_transitions'] -%} | 96 {%- if state['switch_transitions'] -%} |
| 87 switch(yych) { | 97 switch(yych) { |
| 88 {%- for key, transition_state_id in state['switch_transitions'] %} | 98 {%- for ranges, transition_state_id in state['switch_transitions'] %} |
| 89 case {{key}}: | 99 {%- for r in ranges -%} |
| 90 {%- set inline_transition = dfa_states[transition_state_id]['inline'] %} | 100 {%- for key in range(r[0], r[1] + 1) -%} |
| 91 FORWARD(); | 101 case {{key}}: |
| 92 {%- if inline_transition %} | 102 {% endfor %} |
| 93 {{ do_dfa_state(transition_state_id, True) }} | 103 {%- endfor -%} |
| 94 {% else %} | 104 {{ do_transition(transition_state_id) }} |
| 95 goto code_{{transition_state_id}}; | |
| 96 {% endif %} | |
| 97 {% endfor -%} | 105 {% endfor -%} |
| 98 } | 106 } |
| 99 {%- endif -%} | 107 {%- endif -%} |
| 100 | 108 |
| 101 {%- for key, transition_state_id in state.transitions %} | 109 {%- for key, transition_state_id in state.transitions %} |
| 102 if ({{do_key(key)}}) { | 110 if ({{do_key(key)}}) { |
| 103 {%- set inline_transition = dfa_states[transition_state_id]['inline'] %} | 111 {{ do_transition(transition_state_id) }} |
| 104 FORWARD(); | |
| 105 {%- if inline_transition %} | |
| 106 {{ do_dfa_state(transition_state_id, True) }} | |
| 107 {% else %} | |
| 108 goto code_{{transition_state_id}}; | |
| 109 {% endif %} | |
| 110 } | 112 } |
| 111 {% endfor -%} | 113 {% endfor -%} |
| 112 | 114 |
| 113 {%- set match_action = state.match_action -%} | 115 {%- set match_action = state.match_action -%} |
| 114 | 116 |
| 115 {%- if match_action %} | 117 {%- if match_action %} |
| 116 {{ dispatch_action(match_action[0], match_action[1]) }} | 118 {{ dispatch_action(match_action[0], match_action[1]) }} |
| 117 goto code_start; | 119 goto code_start; |
| 118 {% else %} | 120 {% else %} |
| 119 goto default_action; | 121 goto default_action; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 {% endif -%} | 187 {% endif -%} |
| 186 {{dispatch_action(default_action[0], default_action[1])}} | 188 {{dispatch_action(default_action[0], default_action[1])}} |
| 187 FORWARD(); | 189 FORWARD(); |
| 188 goto code_start; | 190 goto code_start; |
| 189 | 191 |
| 190 fell_through: | 192 fell_through: |
| 191 CHECK(false); | 193 CHECK(false); |
| 192 } | 194 } |
| 193 } } | 195 } } |
| 194 | 196 |
| OLD | NEW |