| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 {%- endfor -%} | 65 {%- endfor -%} |
| 66 {%- endmacro -%} | 66 {%- endmacro -%} |
| 67 | 67 |
| 68 | 68 |
| 69 {#- entry actions must not change the value of the cursor | 69 {#- entry actions must not change the value of the cursor |
| 70 unless they jump -#} | 70 unless they jump -#} |
| 71 {% macro dispatch_entry_action(type, value) -%} | 71 {% macro dispatch_entry_action(type, value) -%} |
| 72 {% if type == 'store_token' %} | 72 {% if type == 'store_token' %} |
| 73 stored_token = Token::{{value}}; | 73 stored_token = Token::{{value}}; |
| 74 {% elif type == 'set_marker' %} | 74 {% elif type == 'set_marker' %} |
| 75 marker_ = cursor_ - {{value}}; | 75 marker = cursor_ - {{value}}; |
| 76 {% elif type == 'set_has_escapes' %} | 76 {% elif type == 'set_has_escapes' %} |
| 77 next_.has_escapes = true; | 77 next_.has_escapes = true; |
| 78 {% elif type == 'octal_inside_string' %} | 78 {% elif type == 'octal_inside_string' %} |
| 79 last_octal_end_ = cursor_; | 79 last_octal_end_ = cursor_; |
| 80 next_.has_escapes = true; | 80 next_.has_escapes = true; |
| 81 {% elif type == 'line_terminator_in_multiline_comment' %} | 81 {% elif type == 'line_terminator_in_multiline_comment' %} |
| 82 has_multiline_comment_before_next_ = true; | 82 has_multiline_comment_before_next_ = true; |
| 83 {% elif type == 'check_escaped_identifier_start' %} | 83 {% elif type == 'check_escaped_identifier_start' %} |
| 84 if (!ValidIdentifierStart()) goto default_action; | 84 if (!ValidIdentifierStart()) goto default_action; |
| 85 next_.has_escapes = true; | 85 next_.has_escapes = true; |
| 86 {% elif type == 'check_escaped_identifier_part' %} | 86 {% elif type == 'check_escaped_identifier_part' %} |
| 87 if (!ValidIdentifierPart()) goto default_action; | 87 if (!ValidIdentifierPart()) goto default_action; |
| 88 next_.has_escapes = true; | 88 next_.has_escapes = true; |
| 89 {% elif type == 'if_line_terminator_backtrack' %} | 89 {% elif type == 'if_line_terminator_backtrack' %} |
| 90 if (!has_line_terminator_before_next_) { | 90 if (!has_line_terminator_before_next_) { |
| 91 {{dispatch_match_action('backtrack', value)}} | 91 {{dispatch_match_action('backtrack', value)}} |
| 92 } | 92 } |
| 93 {% else %} | 93 {% else %} |
| 94 uncompilable code for {{type}} {{value}} | 94 uncompilable code for {{type}} {{value}} |
| 95 {% endif -%} | 95 {% endif -%} |
| 96 {%- endmacro -%} | 96 {%- endmacro -%} |
| 97 | 97 |
| 98 | 98 |
| 99 {#- match actions must all explicitly jump or return -#} | 99 {#- match actions must all explicitly jump or return -#} |
| 100 {% macro dispatch_match_action(type, value) -%} | 100 {% macro dispatch_match_action(type, value) -%} |
| 101 {% if type == 'terminate' %} | 101 {% if type == 'terminate' %} |
| 102 {{dispatch_match_action('backtrack', ('1', 'EOS'))}} | 102 {{dispatch_match_action('backtrack', ('1', 'EOS'))}} |
| 103 {% elif type == 'terminate_illegal' %} | 103 {% elif type == 'terminate_illegal' %} |
| 104 start_ = marker_; | 104 start_ = marker; |
| 105 {{dispatch_match_action('backtrack', ('1', 'ILLEGAL'))}} | 105 {{dispatch_match_action('backtrack', ('1', 'ILLEGAL'))}} |
| 106 {% elif type == 'skip' %} | 106 {% elif type == 'skip' %} |
| 107 RESET_START(); | 107 RESET_START(); |
| 108 goto state_entry_0; | 108 goto state_entry_0; |
| 109 {% elif type == 'skip_and_terminate' %} | 109 {% elif type == 'skip_and_terminate' %} |
| 110 RESET_START(); | 110 RESET_START(); |
| 111 --start_; | 111 --start_; |
| 112 {{dispatch_match_action('terminate', None)}} | 112 {{dispatch_match_action('terminate', None)}} |
| 113 {% elif type == 'line_terminator' %} | 113 {% elif type == 'line_terminator' %} |
| 114 RESET_START(); | 114 RESET_START(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 #endif | 315 #endif |
| 316 | 316 |
| 317 namespace v8 { | 317 namespace v8 { |
| 318 namespace internal { | 318 namespace internal { |
| 319 template<> | 319 template<> |
| 320 void ExperimentalScanner<{{char_type}}>::Scan() { | 320 void ExperimentalScanner<{{char_type}}>::Scan() { |
| 321 | 321 |
| 322 // Setup environment. | 322 // Setup environment. |
| 323 next_.has_escapes = false; | 323 next_.has_escapes = false; |
| 324 Token::Value stored_token; | 324 Token::Value stored_token; |
| 325 const {{char_type}} * marker; |
| 325 {{char_type}} primary_char; | 326 {{char_type}} primary_char; |
| 326 READ_CURSOR(); | 327 READ_CURSOR(); |
| 327 | 328 |
| 328 {# first node is start node #} | 329 {# first node is start node #} |
| 329 {% for dfa_state in dfa_states -%} | 330 {% for dfa_state in dfa_states -%} |
| 330 {%- if not dfa_state['inline'] %} | 331 {%- if not dfa_state['inline'] %} |
| 331 {{ do_dfa_state([dfa_state['node_number']]) }} | 332 {{ do_dfa_state([dfa_state['node_number']]) }} |
| 332 {%- endif -%} | 333 {%- endif -%} |
| 333 {%- endfor %} | 334 {%- endfor %} |
| 334 | 335 |
| 335 // Execute the default action. | 336 // Execute the default action. |
| 336 default_action: | 337 default_action: |
| 337 {%- if debug_print %} | 338 {%- if debug_print %} |
| 338 fprintf(stderr, "default action\n"); | 339 fprintf(stderr, "default action\n"); |
| 339 {% endif -%} | 340 {% endif -%} |
| 340 {{dispatch_match_action(default_action[0], default_action[1])}} | 341 {{dispatch_match_action(default_action[0], default_action[1])}} |
| 341 CRASH(); | 342 CRASH(); |
| 342 | 343 |
| 343 if (false) { | 344 if (false) { |
| 344 // force use of stored_token | 345 // force use of stored_token |
| 345 stored_token = Token::ILLEGAL; | 346 stored_token = Token::ILLEGAL; |
| 347 // force use of marker |
| 348 marker = NULL; |
| 346 // force use of state_entry_0 | 349 // force use of state_entry_0 |
| 347 goto state_entry_0; | 350 goto state_entry_0; |
| 348 } | 351 } |
| 349 } | 352 } |
| 350 } } | 353 } } |
| 351 | 354 |
| OLD | NEW |