| OLD | NEW |
| 1 #include "lexer/experimental-scanner.h" | 1 #include "lexer/experimental-scanner.h" |
| 2 | 2 |
| 3 {%- macro do_key(key) -%} | 3 {%- macro do_key(key) -%} |
| 4 {%- for r in key -%} | 4 {%- for r in key -%} |
| 5 {%- if not loop.first %} || {% endif -%} | 5 {%- if not loop.first %} || {% endif -%} |
| 6 {%- if r[0] == 'PRIMARY_RANGE' -%} | 6 {%- if r[0] == 'PRIMARY_RANGE' -%} |
| 7 {%- if r[1][0] == r[1][1] -%} | 7 {%- if r[1][0] == r[1][1] -%} |
| 8 primary_char == {{r[1][0]}} | 8 primary_char == {{r[1][0]}} |
| 9 {%- elif r[1][0] == 0 -%} | 9 {%- elif r[1][0] == 0 -%} |
| 10 primary_char <= {{r[1][1]}} | 10 primary_char <= {{r[1][1]}} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 {% elif type == 'skip' %} | 53 {% elif type == 'skip' %} |
| 54 SKIP(); | 54 SKIP(); |
| 55 {% elif type == 'skip_and_terminate' %} | 55 {% elif type == 'skip_and_terminate' %} |
| 56 SKIP(); | 56 SKIP(); |
| 57 --start_; | 57 --start_; |
| 58 {{dispatch_action('terminate', None)}} | 58 {{dispatch_action('terminate', None)}} |
| 59 {% elif type == 'line_terminator' %} | 59 {% elif type == 'line_terminator' %} |
| 60 DO_LINE_TERMINATOR(); | 60 DO_LINE_TERMINATOR(); |
| 61 {% elif type == 'token' %} | 61 {% elif type == 'token' %} |
| 62 DO_TOKEN(Token::{{value}}) | 62 DO_TOKEN(Token::{{value}}) |
| 63 {% elif type == 'goto' %} |
| 64 goto code_after_entry_{{value}}; |
| 65 {% elif type == 'store_token' %} |
| 66 stored_token = Token::{{value}}; |
| 67 {% elif type == 'do_stored_token' %} |
| 68 DO_TOKEN(stored_token) |
| 63 {% elif type == 'do_token_and_go_forward' %} | 69 {% elif type == 'do_token_and_go_forward' %} |
| 64 DO_TOKEN_AND_GO_FORWARD(Token::{{value}}) | 70 DO_TOKEN_AND_GO_FORWARD(Token::{{value}}) |
| 65 {% elif type == 'harmony_token' %} | 71 {% elif type == 'harmony_token' %} |
| 66 if (harmony_{{value[0]}}_) { | 72 if (harmony_{{value[0]}}_) { |
| 67 DO_TOKEN(Token::{{value[1][0]}}); | 73 DO_TOKEN(Token::{{value[1][0]}}); |
| 68 } else { | 74 } else { |
| 69 DO_TOKEN(Token::{{value[1][1]}}); | 75 DO_TOKEN(Token::{{value[1][1]}}); |
| 70 } | 76 } |
| 77 {% elif type == 'store_harmony_token' %} |
| 78 if (harmony_{{value[0]}}_) { |
| 79 stored_token = Token::{{value[1][0]}}; |
| 80 } else { |
| 81 stored_token = Token::{{value[1][1]}}; |
| 82 } |
| 71 {% elif type == 'set_marker' %} | 83 {% elif type == 'set_marker' %} |
| 72 marker_ = cursor_ - {{value}}; | 84 marker_ = cursor_ - {{value}}; |
| 73 {% else %} | 85 {% else %} |
| 74 uncompilable code for {{type}} | 86 uncompilable code for {{type}} |
| 75 {% endif -%} | 87 {% endif -%} |
| 76 {%- endmacro -%} | 88 {%- endmacro -%} |
| 77 | 89 |
| 78 | 90 |
| 79 {%- macro long_char_check() -%} | 91 {%- macro long_char_check() -%} |
| 80 {%- if encoding == 'utf16'-%} | 92 {%- if encoding == 'utf16'-%} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 135 |
| 124 {% if debug_print %} | 136 {% if debug_print %} |
| 125 fprintf(stderr, "state {{state.node_number}}\n"); | 137 fprintf(stderr, "state {{state.node_number}}\n"); |
| 126 {% endif -%} | 138 {% endif -%} |
| 127 | 139 |
| 128 {%- set entry_action = state.entry_action -%} | 140 {%- set entry_action = state.entry_action -%} |
| 129 {%- if entry_action %} | 141 {%- if entry_action %} |
| 130 {{ dispatch_action(entry_action[0], entry_action[1]) }} | 142 {{ dispatch_action(entry_action[0], entry_action[1]) }} |
| 131 {%- endif %} | 143 {%- endif %} |
| 132 | 144 |
| 145 {%- if state['has_goto_after_entry'] -%} |
| 146 code_after_entry_{{node_number}}: |
| 147 {%- endif %} |
| 148 |
| 133 {%- if debug_print %} | 149 {%- if debug_print %} |
| 134 fprintf(stderr, "char at hand is %c (%d)\n", primary_char, primary_char); | 150 fprintf(stderr, "char at hand is %c (%d)\n", primary_char, primary_char); |
| 135 {% endif -%} | 151 {% endif -%} |
| 136 | 152 |
| 137 {%- macro do_transition(transition_state_id) -%} | 153 {%- macro do_transition(transition_state_id) -%} |
| 138 {%- set inline_transition = dfa_states[transition_state_id]['inline'] %} | 154 {%- set inline_transition = dfa_states[transition_state_id]['inline'] %} |
| 139 FORWARD(); | 155 FORWARD(); |
| 140 {%- if inline_transition %} | 156 {%- if inline_transition %} |
| 141 {{ do_dfa_state(transition_state_id, True) }} | 157 {{ do_dfa_state(transition_state_id, True) }} |
| 142 {% else %} | 158 {% else %} |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 249 |
| 234 #define SKIP() { \ | 250 #define SKIP() { \ |
| 235 start_ = cursor_; \ | 251 start_ = cursor_; \ |
| 236 } | 252 } |
| 237 | 253 |
| 238 namespace v8 { | 254 namespace v8 { |
| 239 namespace internal { | 255 namespace internal { |
| 240 template<> | 256 template<> |
| 241 void ExperimentalScanner<{{char_type}}>::Scan() { | 257 void ExperimentalScanner<{{char_type}}>::Scan() { |
| 242 // Setup environment. | 258 // Setup environment. |
| 259 Token::Value stored_token; |
| 243 {{char_type}} primary_char; | 260 {{char_type}} primary_char; |
| 244 if (cursor_ >= buffer_end_) primary_char = 0; | 261 if (cursor_ >= buffer_end_) primary_char = 0; |
| 245 else primary_char = *(cursor_); | 262 else primary_char = *(cursor_); |
| 246 | 263 |
| 247 {# first node is start node #} | 264 {# first node is start node #} |
| 248 {% for dfa_state in dfa_states -%} | 265 {% for dfa_state in dfa_states -%} |
| 249 {%- set inline = dfa_state['inline'] -%} | 266 {%- set inline = dfa_state['inline'] -%} |
| 250 {%- if not inline %} | 267 {%- if not inline %} |
| 251 {{ do_dfa_state(dfa_state['node_number'], False) }} | 268 {{ do_dfa_state(dfa_state['node_number'], False) }} |
| 252 {%- endif -%} | 269 {%- endif -%} |
| 253 {%- endfor %} | 270 {%- endfor %} |
| 254 | 271 |
| 255 // Should never fall off the edge. | 272 // Should never fall off the edge. |
| 256 goto fell_through; | 273 goto fell_through; |
| 257 // Execute the default action. | 274 // Execute the default action. |
| 258 default_action: | 275 default_action: |
| 259 {%- if debug_print %} | 276 {%- if debug_print %} |
| 260 fprintf(stderr, "default action\n"); | 277 fprintf(stderr, "default action\n"); |
| 261 {% endif -%} | 278 {% endif -%} |
| 262 {{dispatch_action(default_action[0], default_action[1])}} | 279 {{dispatch_action(default_action[0], default_action[1])}} |
| 263 FORWARD(); | 280 FORWARD(); |
| 264 goto code_start; | 281 goto code_start; |
| 265 | 282 |
| 266 fell_through: | 283 fell_through: |
| 267 CHECK(false); | 284 ((void(*)())0)(); // crash |
| 285 // force use of stored_token |
| 286 stored_token = Token::ILLEGAL; |
| 268 } | 287 } |
| 269 } } | 288 } } |
| 270 | 289 |
| OLD | NEW |