| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 {{ dispatch_entry_action(entry_action[0], entry_action[1]) }} | 230 {{ dispatch_entry_action(entry_action[0], entry_action[1]) }} |
| 231 {%- endif %} | 231 {%- endif %} |
| 232 | 232 |
| 233 {{ write_label('after_entry_code', node_number) }} | 233 {{ write_label('after_entry_code', node_number) }} |
| 234 | 234 |
| 235 {%- if debug_print %} | 235 {%- if debug_print %} |
| 236 fprintf(stderr, "char at hand is %c (%d)\n", primary_char, primary_char); | 236 fprintf(stderr, "char at hand is %c (%d)\n", primary_char, primary_char); |
| 237 {% endif -%} | 237 {% endif -%} |
| 238 | 238 |
| 239 {%- macro do_transition(jump_id) -%} | 239 {%- macro do_transition(jump_id) -%} |
| 240 {%- set transition_state_id = jump_table[jump_id][0] -%} | |
| 241 {%- set inline_transition = jump_table[jump_id][1] == 'inline' %} | |
| 242 FORWARD(); | 240 FORWARD(); |
| 243 {%- if inline_transition %} | 241 if (cursor_ < buffer_end_) { |
| 244 {{ do_dfa_state(transition_state_id) }} | 242 {%- set transition_state_id = jump_table[jump_id][0] -%} |
| 245 {% else %} | 243 {%- set inline_transition = jump_table[jump_id][1] == 'inline' %} |
| 246 {{ jump(jump_id) }} | 244 {%- if inline_transition %} |
| 247 {% endif %} | 245 {{ do_dfa_state(transition_state_id) }} |
| 246 {% else %} |
| 247 {{ jump(jump_id) }} |
| 248 {% endif %} |
| 249 } |
| 250 {% if 'eos' in state['unique_transitions'] -%} |
| 251 {{ jump(state['unique_transitions']['eos']) }} // eos handler |
| 252 {%- else -%} |
| 253 BACKWARD(1); |
| 254 {{ jump(state['jump_before_match']) }} // no eos handler |
| 255 {%- endif %} |
| 248 {%- endmacro -%} | 256 {%- endmacro -%} |
| 249 | 257 |
| 250 {%- if state['switch_transitions'] -%} | 258 {%- if state['switch_transitions'] -%} |
| 251 switch(primary_char) { | 259 switch(primary_char) { |
| 252 {%- for ranges, jump_id in state['switch_transitions'] %} | 260 {%- for ranges, jump_id in state['switch_transitions'] %} |
| 253 {%- for r in ranges -%} | 261 {%- for r in ranges -%} |
| 254 {%- for key in range(r[0], r[1] + 1) -%} | 262 {%- for key in range(r[0], r[1] + 1) -%} |
| 255 case {{key}}: | 263 case {{key}}: |
| 256 {% endfor %} | 264 {% endfor %} |
| 257 {%- endfor -%} | 265 {%- endfor -%} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 277 next_.is_onebyte = false; | 285 next_.is_onebyte = false; |
| 278 {{long_char_create()}} | 286 {{long_char_create()}} |
| 279 {%- for key, jump_id in state['long_char_transitions'] %} | 287 {%- for key, jump_id in state['long_char_transitions'] %} |
| 280 if ({{do_key(key)}}) { // long_char transition | 288 if ({{do_key(key)}}) { // long_char transition |
| 281 {{ do_transition(jump_id) }} | 289 {{ do_transition(jump_id) }} |
| 282 } | 290 } |
| 283 {% endfor -%} | 291 {% endfor -%} |
| 284 } | 292 } |
| 285 {%- endif-%} | 293 {%- endif-%} |
| 286 | 294 |
| 295 {{ write_label('before_match', node_number) }} |
| 296 |
| 287 {%- set match_action = state.match_action -%} | 297 {%- set match_action = state.match_action -%} |
| 288 | |
| 289 {%- if match_action %} | 298 {%- if match_action %} |
| 290 {{ dispatch_match_action(match_action[0], match_action[1]) }} | 299 {{ dispatch_match_action(match_action[0], match_action[1]) }} |
| 291 CRASH(); | 300 CRASH(); |
| 292 {% else %} | 301 {% else %} |
| 293 goto default_action; | 302 goto default_action; |
| 294 {%- endif %} | 303 {%- endif %} |
| 295 | 304 |
| 296 {%- endmacro %} | 305 {%- endmacro %} |
| 297 | 306 |
| 298 #include "lexer/experimental-scanner.h" | 307 #include "lexer/experimental-scanner.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 310 | 319 |
| 311 #define FORWARD() { \ | 320 #define FORWARD() { \ |
| 312 cursor_++; \ | 321 cursor_++; \ |
| 313 } | 322 } |
| 314 | 323 |
| 315 #define BACKWARD(n) { \ | 324 #define BACKWARD(n) { \ |
| 316 cursor_ -= n; \ | 325 cursor_ -= n; \ |
| 317 } | 326 } |
| 318 | 327 |
| 319 #define READ_CURSOR() { \ | 328 #define READ_CURSOR() { \ |
| 320 if (cursor_ >= buffer_end_) primary_char = 0; \ | 329 ASSERT(cursor_ < buffer_end_); \ |
| 321 else primary_char = *(cursor_); \ | 330 primary_char = *(cursor_); \ |
| 322 } | 331 } |
| 323 | 332 |
| 324 #ifdef DEBUG | 333 #ifdef DEBUG |
| 325 #define CRASH() { ((void(*)())0)(); } | 334 #define CRASH() { ((void(*)())0)(); } |
| 326 #else | 335 #else |
| 327 #define CRASH() { } | 336 #define CRASH() { } |
| 328 #endif | 337 #endif |
| 329 | 338 |
| 330 namespace v8 { | 339 namespace v8 { |
| 331 namespace internal { | 340 namespace internal { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 358 // force use of stored_token | 367 // force use of stored_token |
| 359 stored_token = Token::ILLEGAL; | 368 stored_token = Token::ILLEGAL; |
| 360 // force use of marker | 369 // force use of marker |
| 361 marker = NULL; | 370 marker = NULL; |
| 362 // force use of state_entry_0 | 371 // force use of state_entry_0 |
| 363 goto state_entry_0; | 372 goto state_entry_0; |
| 364 } | 373 } |
| 365 } | 374 } |
| 366 } } | 375 } } |
| 367 | 376 |
| OLD | NEW |