| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 {%- else -%} | 59 {%- else -%} |
| 60 uncompilable code for {{encoding}} {{r[0]}} {{r[1]}} | 60 uncompilable code for {{encoding}} {{r[0]}} {{r[1]}} |
| 61 {%- endif -%} | 61 {%- endif -%} |
| 62 {%- else -%} | 62 {%- else -%} |
| 63 uncompilable code for {{encoding}} {{r[0]}} {{r[1]}} | 63 uncompilable code for {{encoding}} {{r[0]}} {{r[1]}} |
| 64 {%- endif -%} | 64 {%- endif -%} |
| 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 {% macro dispatch_entry_action(type, value) -%} | 71 {% macro dispatch_entry_action(type, value) -%} |
| 71 {%- if type == 'code' %} | 72 {% if type == 'store_token' %} |
| 72 {#- TODO(dcarney): in debug mode, verify cursor doesn't change -#} | |
| 73 {{value}} | |
| 74 {% elif type == 'store_token' %} | |
| 75 stored_token = Token::{{value}}; | 73 stored_token = Token::{{value}}; |
| 76 {% elif type == 'set_marker' %} | 74 {% elif type == 'set_marker' %} |
| 77 marker_ = cursor_ - {{value}}; | 75 marker_ = cursor_ - {{value}}; |
| 78 {% elif type == 'set_has_escapes' %} | 76 {% elif type == 'set_has_escapes' %} |
| 79 next_.has_escapes = true; | 77 next_.has_escapes = true; |
| 80 {% elif type == 'octal_inside_string' %} | 78 {% elif type == 'octal_inside_string' %} |
| 81 last_octal_end_ = cursor_; | 79 last_octal_end_ = cursor_; |
| 82 next_.has_escapes = true; | 80 next_.has_escapes = true; |
| 83 {% elif type == 'line_terminator_in_multiline_comment' %} | 81 {% elif type == 'line_terminator_in_multiline_comment' %} |
| 84 has_multiline_comment_before_next_ = true; | 82 has_multiline_comment_before_next_ = true; |
| 83 {% elif type == 'check_escaped_identifier_start' %} |
| 84 if (!ValidIdentifierStart()) goto default_action; |
| 85 next_.has_escapes = true; |
| 86 {% elif type == 'check_escaped_identifier_part' %} |
| 87 if (!ValidIdentifierPart()) goto default_action; |
| 88 next_.has_escapes = true; |
| 89 {% elif type == 'if_line_terminator_backtrack' %} |
| 90 if (!has_line_terminator_before_next_) { |
| 91 {{dispatch_match_action('backtrack', value)}} |
| 92 } |
| 85 {% else %} | 93 {% else %} |
| 86 uncompilable code for {{type}} | 94 uncompilable code for {{type}} {{value}} |
| 87 {% endif -%} | 95 {% endif -%} |
| 88 {%- endmacro -%} | 96 {%- endmacro -%} |
| 89 | 97 |
| 90 | 98 |
| 91 {#- match actions must all explicitly jump or return -#} | 99 {#- match actions must all explicitly jump or return -#} |
| 92 {% macro dispatch_match_action(type, value) -%} | 100 {% macro dispatch_match_action(type, value) -%} |
| 93 {%- if type == 'code' %} | 101 {% if type == 'terminate' %} |
| 94 {{value}} | |
| 95 CRASH() | |
| 96 {% elif type == 'terminate' %} | |
| 97 DO_EOS(); | 102 DO_EOS(); |
| 98 return; | 103 return; |
| 99 {% elif type == 'terminate_illegal' %} | 104 {% elif type == 'terminate_illegal' %} |
| 100 start_ = marker_; | 105 start_ = marker_; |
| 101 BACKWARD(1); | 106 BACKWARD(1); |
| 102 DO_TOKEN(Token::ILLEGAL); | 107 DO_TOKEN(Token::ILLEGAL); |
| 103 return; | 108 return; |
| 104 {% elif type == 'skip' %} | 109 {% elif type == 'skip' %} |
| 105 SKIP(); | 110 SKIP(); |
| 106 goto state_entry_0; | 111 goto state_entry_0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 136 if (harmony_{{value[0]}}_) { | 141 if (harmony_{{value[0]}}_) { |
| 137 stored_token = Token::{{value[1]}}; | 142 stored_token = Token::{{value[1]}}; |
| 138 } else { | 143 } else { |
| 139 stored_token = Token::{{value[2]}}; | 144 stored_token = Token::{{value[2]}}; |
| 140 } | 145 } |
| 141 goto after_entry_code_{{value[3]}}; | 146 goto after_entry_code_{{value[3]}}; |
| 142 {% elif type == 'octal_number' %} | 147 {% elif type == 'octal_number' %} |
| 143 last_octal_end_ = cursor_; | 148 last_octal_end_ = cursor_; |
| 144 DO_TOKEN(Token::NUMBER); | 149 DO_TOKEN(Token::NUMBER); |
| 145 return; | 150 return; |
| 151 {% elif type == 'backtrack' %} |
| 152 BACKWARD({{value[0]}}); |
| 153 DO_TOKEN(Token::{{value[1]}}); |
| 154 return; |
| 146 {% else %} | 155 {% else %} |
| 147 uncompilable code for {{encoding}} | 156 uncompilable code for {{type}} {{value}} |
| 148 {% endif -%} | 157 {% endif -%} |
| 149 {%- endmacro -%} | 158 {%- endmacro -%} |
| 150 | 159 |
| 151 | 160 |
| 152 {%- macro long_char_check() -%} | 161 {%- macro long_char_check() -%} |
| 153 {%- if encoding == 'utf16'-%} | 162 {%- if encoding == 'utf16'-%} |
| 154 primary_char > {{upper_bound}} | 163 primary_char > {{upper_bound}} |
| 155 {%- elif encoding == 'utf8'-%} | 164 {%- elif encoding == 'utf8'-%} |
| 156 primary_char < 0 | 165 primary_char < 0 |
| 157 {%- else -%} | 166 {%- else -%} |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 {{ do_transition(transition_state_id) }} | 266 {{ do_transition(transition_state_id) }} |
| 258 } | 267 } |
| 259 {% endfor -%} | 268 {% endfor -%} |
| 260 } | 269 } |
| 261 {%- endif-%} | 270 {%- endif-%} |
| 262 | 271 |
| 263 {%- set match_action = state.match_action -%} | 272 {%- set match_action = state.match_action -%} |
| 264 | 273 |
| 265 {%- if match_action %} | 274 {%- if match_action %} |
| 266 {{ dispatch_match_action(match_action[0], match_action[1]) }} | 275 {{ dispatch_match_action(match_action[0], match_action[1]) }} |
| 267 CRASH() | 276 CRASH(); |
| 268 {% else %} | 277 {% else %} |
| 269 goto default_action; | 278 goto default_action; |
| 270 {%- endif %} | 279 {%- endif %} |
| 271 | 280 |
| 272 {%- endmacro %} | 281 {%- endmacro %} |
| 273 | 282 |
| 274 #include "lexer/experimental-scanner.h" | 283 #include "lexer/experimental-scanner.h" |
| 275 | 284 |
| 276 #define PREPARE_TOKEN() { \ | 285 #define PREPARE_TOKEN() { \ |
| 277 next_.beg_pos = start_ - buffer_; \ | 286 next_.beg_pos = start_ - buffer_; \ |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 {{ do_dfa_state([dfa_state['node_number']]) }} | 348 {{ do_dfa_state([dfa_state['node_number']]) }} |
| 340 {%- endif -%} | 349 {%- endif -%} |
| 341 {%- endfor %} | 350 {%- endfor %} |
| 342 | 351 |
| 343 // Execute the default action. | 352 // Execute the default action. |
| 344 default_action: | 353 default_action: |
| 345 {%- if debug_print %} | 354 {%- if debug_print %} |
| 346 fprintf(stderr, "default action\n"); | 355 fprintf(stderr, "default action\n"); |
| 347 {% endif -%} | 356 {% endif -%} |
| 348 {{dispatch_match_action(default_action[0], default_action[1])}} | 357 {{dispatch_match_action(default_action[0], default_action[1])}} |
| 349 CRASH() | 358 CRASH(); |
| 350 | 359 |
| 351 if (false) { | 360 if (false) { |
| 352 // force use of stored_token | 361 // force use of stored_token |
| 353 stored_token = Token::ILLEGAL; | 362 stored_token = Token::ILLEGAL; |
| 354 // force use of state_entry_0 | 363 // force use of state_entry_0 |
| 355 goto state_entry_0; | 364 goto state_entry_0; |
| 356 } | 365 } |
| 357 } | 366 } |
| 358 } } | 367 } } |
| 359 | 368 |
| OLD | NEW |