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

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

Issue 201613002: Experimental parser: allocate substrings (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/lexer.cc ('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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 {#- match actions must all explicitly jump or return -#} 116 {#- match actions must all explicitly jump or return -#}
117 {% macro dispatch_match_action(type, args) -%} 117 {% macro dispatch_match_action(type, args) -%}
118 {% if type == 'terminate' %} 118 {% if type == 'terminate' %}
119 {{dispatch_match_action('manual_backtrack', ('1', 'EOS'))}} 119 {{dispatch_match_action('manual_backtrack', ('1', 'EOS'))}}
120 {% elif type == 'terminate_illegal' %} 120 {% elif type == 'terminate_illegal' %}
121 start_ = marker; 121 start_ = marker;
122 {{dispatch_match_action('manual_backtrack', ('1', 'ILLEGAL'))}} 122 {{dispatch_match_action('manual_backtrack', ('1', 'ILLEGAL'))}}
123 {% elif type == 'skip' %} 123 {% elif type == 'skip' %}
124 RESET_START(); 124 RESET_START();
125 {%- if encoding == 'utf16'-%} 125 {%- if encoding == 'utf16'or encoding == 'utf8' -%}
126 next_.is_onebyte = true; 126 next_.is_in_primary_range = true;
127 {%- endif -%} 127 {%- endif -%}
128 goto state_entry_0; 128 goto state_entry_0;
129 {% elif type == 'skip_and_terminate' %} 129 {% elif type == 'skip_and_terminate' %}
130 RESET_START(); 130 RESET_START();
131 --start_; 131 --start_;
132 {{dispatch_match_action('terminate', None)}} 132 {{dispatch_match_action('terminate', None)}}
133 {% elif type == 'line_terminator' %} 133 {% elif type == 'line_terminator' %}
134 RESET_START(); 134 RESET_START();
135 {%- if encoding == 'utf16'-%} 135 {%- if encoding == 'utf16'or encoding == 'utf8' -%}
136 next_.is_onebyte = true; 136 next_.is_in_primary_range = true;
137 {%- endif -%} 137 {%- endif -%}
138 has_line_terminator_before_next_ = true; 138 has_line_terminator_before_next_ = true;
139 goto state_entry_0; 139 goto state_entry_0;
140 {% elif type == 'token' %} 140 {% elif type == 'token' %}
141 DO_TOKEN(Token::{{args[0]}}) 141 DO_TOKEN(Token::{{args[0]}})
142 return; 142 return;
143 {% elif type == 'do_stored_token' %} 143 {% elif type == 'do_stored_token' %}
144 DO_TOKEN(stored_token) 144 DO_TOKEN(stored_token)
145 return; 145 return;
146 {% elif type == 'default' %} 146 {% elif type == 'default' %}
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 {%- if 'eos' in state['unique_transitions'] %} 279 {%- if 'eos' in state['unique_transitions'] %}
280 if (primary_char == 0 && cursor_ >= buffer_end_) { // eos handler 280 if (primary_char == 0 && cursor_ >= buffer_end_) { // eos handler
281 FORWARD(); 281 FORWARD();
282 {{ jump(state['unique_transitions']['eos']) }} 282 {{ jump(state['unique_transitions']['eos']) }}
283 } 283 }
284 {%- endif -%} 284 {%- endif -%}
285 285
286 {%- if state['deferred_transitions'] %} 286 {%- if state['deferred_transitions'] %}
287 if ({{long_char_check()}}) { 287 if ({{long_char_check()}}) {
288 next_.is_onebyte = false; 288 next_.is_in_primary_range = false;
289 {{long_char_create()}} 289 {{long_char_create()}}
290 {%- for key, jump_id in state['deferred_transitions'] %} 290 {%- for key, jump_id in state['deferred_transitions'] %}
291 if ({{do_key(key)}}) { // long_char transition 291 if ({{do_key(key)}}) { // long_char transition
292 {{ do_transition(jump_id) }} 292 {{ do_transition(jump_id) }}
293 } 293 }
294 {% endfor -%} 294 {% endfor -%}
295 } 295 }
296 {%- endif -%} 296 {%- endif -%}
297 297
298 {%- if state['omega_transition'] %} 298 {%- if state['omega_transition'] %}
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 #endif 348 #endif
349 349
350 350
351 namespace v8 { 351 namespace v8 {
352 namespace internal { 352 namespace internal {
353 template<> 353 template<>
354 void Lexer<{{char_type}}>::Scan() { 354 void Lexer<{{char_type}}>::Scan() {
355 355
356 // Setup environment. 356 // Setup environment.
357 next_.has_escapes = false; 357 next_.has_escapes = false;
358 next_.is_onebyte = true; 358 next_.is_in_primary_range = true;
359 Token::Value stored_token; 359 Token::Value stored_token;
360 const {{char_type}} * marker; 360 const {{char_type}} * marker;
361 {{char_type}} primary_char; 361 {{char_type}} primary_char;
362 const {{char_type}} * stored_marker; {# TODO(dcarney): complete this #} 362 const {{char_type}} * stored_marker; {# TODO(dcarney): complete this #}
363 const {{char_type}} * stored_cursor; 363 const {{char_type}} * stored_cursor;
364 const {{char_type}} * stored_start; 364 const {{char_type}} * stored_start;
365 365
366 {# first node is start node #} 366 {# first node is start node #}
367 {% for dfa_state in dfa_states -%} 367 {% for dfa_state in dfa_states -%}
368 {%- if not dfa_state['inline'] %} 368 {%- if not dfa_state['inline'] %}
(...skipping 14 matching lines...) Expand all
383 // force use of stored_token 383 // force use of stored_token
384 stored_token = Token::ILLEGAL; 384 stored_token = Token::ILLEGAL;
385 // force use of marker 385 // force use of marker
386 marker = NULL; 386 marker = NULL;
387 // force use of state_entry_0 387 // force use of state_entry_0
388 goto state_entry_0; 388 goto state_entry_0;
389 } 389 }
390 } 390 }
391 } } 391 } }
392 392
OLDNEW
« no previous file with comments | « src/lexer/lexer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698