Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: tools/lexer_generator/code_generator.jinja

Issue 136793025: Experimental lexer: track one-byteness on the fly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: cancel changes in ex scanner cc Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/lexer/experimental-scanner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {%- if encoding == 'utf16'-%}
109 next_.is_onebyte = true;
110 {%- endif -%}
108 goto state_entry_0; 111 goto state_entry_0;
109 {% elif type == 'skip_and_terminate' %} 112 {% elif type == 'skip_and_terminate' %}
110 RESET_START(); 113 RESET_START();
111 --start_; 114 --start_;
112 {{dispatch_match_action('terminate', None)}} 115 {{dispatch_match_action('terminate', None)}}
113 {% elif type == 'line_terminator' %} 116 {% elif type == 'line_terminator' %}
114 RESET_START(); 117 RESET_START();
118 {%- if encoding == 'utf16'-%}
119 next_.is_onebyte = true;
120 {%- endif -%}
115 has_line_terminator_before_next_ = true; 121 has_line_terminator_before_next_ = true;
116 goto state_entry_0; 122 goto state_entry_0;
117 {% elif type == 'token' %} 123 {% elif type == 'token' %}
118 DO_TOKEN(Token::{{value}}) 124 DO_TOKEN(Token::{{value}})
119 return; 125 return;
120 {% elif type == 'goto_start' %} 126 {% elif type == 'goto_start' %}
121 goto state_entry_{{value[0]}}; 127 goto state_entry_{{value[0]}};
122 {% elif type == 'store_token_and_goto' %} 128 {% elif type == 'store_token_and_goto' %}
123 stored_token = Token::{{value[0]}}; 129 stored_token = Token::{{value[0]}};
124 goto after_entry_code_{{value[1]}}; 130 goto after_entry_code_{{value[1]}};
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 {% endfor -%} 263 {% endfor -%}
258 264
259 {%- for key, transition_state_id in state['deferred_transitions'] %} 265 {%- for key, transition_state_id in state['deferred_transitions'] %}
260 if ({{do_key(key)}}) { // deferred transition 266 if ({{do_key(key)}}) { // deferred transition
261 {{ do_transition(transition_state_id) }} 267 {{ do_transition(transition_state_id) }}
262 } 268 }
263 {% endfor -%} 269 {% endfor -%}
264 270
265 {%- if state['long_char_transitions'] -%} 271 {%- if state['long_char_transitions'] -%}
266 if ({{long_char_check()}}) { 272 if ({{long_char_check()}}) {
273 next_.is_onebyte = false;
267 {{long_char_create()}} 274 {{long_char_create()}}
268 {%- for key, transition_state_id in state['long_char_transitions'] %} 275 {%- for key, transition_state_id in state['long_char_transitions'] %}
269 if ({{do_key(key)}}) { // long_char transition 276 if ({{do_key(key)}}) { // long_char transition
270 {{ do_transition(transition_state_id) }} 277 {{ do_transition(transition_state_id) }}
271 } 278 }
272 {% endfor -%} 279 {% endfor -%}
273 } 280 }
274 {%- endif-%} 281 {%- endif-%}
275 282
276 {%- set match_action = state.match_action -%} 283 {%- set match_action = state.match_action -%}
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 #define CRASH() { } 323 #define CRASH() { }
317 #endif 324 #endif
318 325
319 namespace v8 { 326 namespace v8 {
320 namespace internal { 327 namespace internal {
321 template<> 328 template<>
322 void ExperimentalScanner<{{char_type}}>::Scan() { 329 void ExperimentalScanner<{{char_type}}>::Scan() {
323 330
324 // Setup environment. 331 // Setup environment.
325 next_.has_escapes = false; 332 next_.has_escapes = false;
333 next_.is_onebyte = true;
326 Token::Value stored_token; 334 Token::Value stored_token;
327 const {{char_type}} * marker; 335 const {{char_type}} * marker;
328 {{char_type}} primary_char; 336 {{char_type}} primary_char;
329 337
330 {# first node is start node #} 338 {# first node is start node #}
331 {% for dfa_state in dfa_states -%} 339 {% for dfa_state in dfa_states -%}
332 {%- if not dfa_state['inline'] %} 340 {%- if not dfa_state['inline'] %}
333 {{ do_dfa_state([dfa_state['node_number']]) }} 341 {{ do_dfa_state([dfa_state['node_number']]) }}
334 {%- endif -%} 342 {%- endif -%}
335 {%- endfor %} 343 {%- endfor %}
(...skipping 10 matching lines...) Expand all
346 // force use of stored_token 354 // force use of stored_token
347 stored_token = Token::ILLEGAL; 355 stored_token = Token::ILLEGAL;
348 // force use of marker 356 // force use of marker
349 marker = NULL; 357 marker = NULL;
350 // force use of state_entry_0 358 // force use of state_entry_0
351 goto state_entry_0; 359 goto state_entry_0;
352 } 360 }
353 } 361 }
354 } } 362 } }
355 363
OLDNEW
« no previous file with comments | « src/lexer/experimental-scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698