| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 reinterpret_cast<const uint8_t*>(cursor_), | 189 reinterpret_cast<const uint8_t*>(cursor_), |
| 190 buffer_end_ - cursor_, | 190 buffer_end_ - cursor_, |
| 191 &bytes_read); | 191 &bytes_read); |
| 192 cursor_ += bytes_read - 1; | 192 cursor_ += bytes_read - 1; |
| 193 {%- else -%} | 193 {%- else -%} |
| 194 uncompilable code for {{encoding}} | 194 uncompilable code for {{encoding}} |
| 195 {%- endif -%} | 195 {%- endif -%} |
| 196 {%- endmacro -%} | 196 {%- endmacro -%} |
| 197 | 197 |
| 198 | 198 |
| 199 {%- macro write_label(label_name, node_number_chain) %} | 199 {%- macro write_label(label_name, node_number) %} |
| 200 {%- set node_number = node_number_chain|first -%} | |
| 201 {%- set state = dfa_states[node_number] -%} | 200 {%- set state = dfa_states[node_number] -%} |
| 202 {%- set used = state['entry_points'][label_name] -%} | 201 {%- set used = state['entry_points'][label_name] -%} |
| 203 {%- set long_label = label_name + '_' + node_number_chain|join('_') -%} | 202 {%- set long_label = label_name ~ '_' ~ node_number -%} |
| 204 {% if used -%} | 203 {% if used -%} |
| 205 {{long_label}}: | 204 {{long_label}}: |
| 206 {%- else -%} | 205 {%- else -%} |
| 207 // {{long_label}}: | 206 // {{long_label}}: |
| 208 {%- endif %} | 207 {%- endif %} |
| 209 {% endmacro -%} | 208 {% endmacro -%} |
| 210 | 209 |
| 211 | 210 |
| 212 {%- macro do_dfa_state(node_number_chain) -%} | 211 {%- macro do_dfa_state(node_number) -%} |
| 213 | 212 |
| 214 {%- set node_number = node_number_chain|first -%} | |
| 215 {%- set state = dfa_states[node_number] -%} | 213 {%- set state = dfa_states[node_number] -%} |
| 216 | 214 |
| 217 {{ write_label('state_entry', node_number_chain) }} | 215 {{ write_label('state_entry', node_number) }} |
| 218 | 216 |
| 219 {% if not state['can_elide_read'] -%} | 217 {% if not state['can_elide_read'] -%} |
| 220 READ_CURSOR(); | 218 READ_CURSOR(); |
| 221 {%- endif -%} | 219 {%- endif -%} |
| 222 | 220 |
| 223 {% if debug_print %} | 221 {% if debug_print %} |
| 224 fprintf(stderr, | 222 fprintf(stderr, |
| 225 "state {{state.node_number}}, start %d, cursor %d\n", | 223 "state {{state.node_number}}, start %d, cursor %d\n", |
| 226 start_ - buffer_, | 224 start_ - buffer_, |
| 227 cursor_ - buffer_); | 225 cursor_ - buffer_); |
| 228 {% endif -%} | 226 {% endif -%} |
| 229 | 227 |
| 230 {%- set entry_action = state.entry_action -%} | 228 {%- set entry_action = state.entry_action -%} |
| 231 {%- if entry_action %} | 229 {%- if entry_action %} |
| 232 {{ dispatch_entry_action(entry_action[0], entry_action[1]) }} | 230 {{ dispatch_entry_action(entry_action[0], entry_action[1]) }} |
| 233 {%- endif %} | 231 {%- endif %} |
| 234 | 232 |
| 235 {{ write_label('after_entry_code', node_number_chain) }} | 233 {{ write_label('after_entry_code', node_number) }} |
| 236 | 234 |
| 237 {%- if debug_print %} | 235 {%- if debug_print %} |
| 238 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); |
| 239 {% endif -%} | 237 {% endif -%} |
| 240 | 238 |
| 241 {%- macro do_transition(jump_id) -%} | 239 {%- macro do_transition(jump_id) -%} |
| 242 {%- set transition_state_id = jump_table[jump_id][0] -%} | 240 {%- set transition_state_id = jump_table[jump_id][0] -%} |
| 243 {%- set inline_transition = dfa_states[transition_state_id]['inline'] %} | 241 {%- set inline_transition = jump_table[jump_id][1] == 'inline' %} |
| 244 FORWARD(); | 242 FORWARD(); |
| 245 {%- if inline_transition %} | 243 {%- if inline_transition %} |
| 246 {{ do_dfa_state([transition_state_id] + node_number_chain) }} | 244 {{ do_dfa_state(transition_state_id) }} |
| 247 {% else %} | 245 {% else %} |
| 248 {{ jump(jump_id) }} | 246 {{ jump(jump_id) }} |
| 249 {% endif %} | 247 {% endif %} |
| 250 {%- endmacro -%} | 248 {%- endmacro -%} |
| 251 | 249 |
| 252 {%- if state['switch_transitions'] -%} | 250 {%- if state['switch_transitions'] -%} |
| 253 switch(primary_char) { | 251 switch(primary_char) { |
| 254 {%- for ranges, jump_id in state['switch_transitions'] %} | 252 {%- for ranges, jump_id in state['switch_transitions'] %} |
| 255 {%- for r in ranges -%} | 253 {%- for r in ranges -%} |
| 256 {%- for key in range(r[0], r[1] + 1) -%} | 254 {%- for key in range(r[0], r[1] + 1) -%} |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // Setup environment. | 335 // Setup environment. |
| 338 next_.has_escapes = false; | 336 next_.has_escapes = false; |
| 339 next_.is_onebyte = true; | 337 next_.is_onebyte = true; |
| 340 Token::Value stored_token; | 338 Token::Value stored_token; |
| 341 const {{char_type}} * marker; | 339 const {{char_type}} * marker; |
| 342 {{char_type}} primary_char; | 340 {{char_type}} primary_char; |
| 343 | 341 |
| 344 {# first node is start node #} | 342 {# first node is start node #} |
| 345 {% for dfa_state in dfa_states -%} | 343 {% for dfa_state in dfa_states -%} |
| 346 {%- if not dfa_state['inline'] %} | 344 {%- if not dfa_state['inline'] %} |
| 347 {{ do_dfa_state([dfa_state['node_number']]) }} | 345 {{ do_dfa_state(dfa_state['node_number']) }} |
| 348 {%- endif -%} | 346 {%- endif -%} |
| 349 {%- endfor %} | 347 {%- endfor %} |
| 350 | 348 |
| 351 // Execute the default action. | 349 // Execute the default action. |
| 352 default_action: | 350 default_action: |
| 353 {%- if debug_print %} | 351 {%- if debug_print %} |
| 354 fprintf(stderr, "default action\n"); | 352 fprintf(stderr, "default action\n"); |
| 355 {% endif -%} | 353 {% endif -%} |
| 356 {{dispatch_match_action(default_action[0], default_action[1])}} | 354 {{dispatch_match_action(default_action[0], default_action[1])}} |
| 357 CRASH(); | 355 CRASH(); |
| 358 | 356 |
| 359 if (false) { | 357 if (false) { |
| 360 // force use of stored_token | 358 // force use of stored_token |
| 361 stored_token = Token::ILLEGAL; | 359 stored_token = Token::ILLEGAL; |
| 362 // force use of marker | 360 // force use of marker |
| 363 marker = NULL; | 361 marker = NULL; |
| 364 // force use of state_entry_0 | 362 // force use of state_entry_0 |
| 365 goto state_entry_0; | 363 goto state_entry_0; |
| 366 } | 364 } |
| 367 } | 365 } |
| 368 } } | 366 } } |
| 369 | 367 |
| OLD | NEW |