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

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

Issue 135853012: Experimental parser: remove unnecessary reads (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: 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 | « no previous file | 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 {% endmacro -%} 198 {% endmacro -%}
199 199
200 200
201 {%- macro do_dfa_state(node_number_chain) -%} 201 {%- macro do_dfa_state(node_number_chain) -%}
202 202
203 {%- set node_number = node_number_chain|first -%} 203 {%- set node_number = node_number_chain|first -%}
204 {%- set state = dfa_states[node_number] -%} 204 {%- set state = dfa_states[node_number] -%}
205 205
206 {{ write_label('state_entry', node_number_chain) }} 206 {{ write_label('state_entry', node_number_chain) }}
207 207
208 READ_CURSOR();
209
208 {% if debug_print %} 210 {% if debug_print %}
209 fprintf(stderr, 211 fprintf(stderr,
210 "state {{state.node_number}}, start %d, cursor %d\n", 212 "state {{state.node_number}}, start %d, cursor %d\n",
211 start_ - buffer_, 213 start_ - buffer_,
212 cursor_ - buffer_); 214 cursor_ - buffer_);
213 {% endif -%} 215 {% endif -%}
214 216
215 {%- set entry_action = state.entry_action -%} 217 {%- set entry_action = state.entry_action -%}
216 {%- if entry_action %} 218 {%- if entry_action %}
217 {{ dispatch_entry_action(entry_action[0], entry_action[1]) }} 219 {{ dispatch_entry_action(entry_action[0], entry_action[1]) }}
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 290
289 #define DO_TOKEN(T) { \ 291 #define DO_TOKEN(T) { \
290 next_.beg_pos = start_ - buffer_; \ 292 next_.beg_pos = start_ - buffer_; \
291 next_.end_pos = cursor_ - buffer_; \ 293 next_.end_pos = cursor_ - buffer_; \
292 next_.token = T; \ 294 next_.token = T; \
293 RESET_START(); \ 295 RESET_START(); \
294 } 296 }
295 297
296 #define FORWARD() { \ 298 #define FORWARD() { \
297 cursor_++; \ 299 cursor_++; \
298 READ_CURSOR(); \
299 } 300 }
300 301
301 #define BACKWARD(n) { \ 302 #define BACKWARD(n) { \
302 cursor_ -= n; \ 303 cursor_ -= n; \
303 READ_CURSOR(); \
304 } 304 }
305 305
306 #define READ_CURSOR() { \ 306 #define READ_CURSOR() { \
307 if (cursor_ >= buffer_end_) primary_char = 0; \ 307 if (cursor_ >= buffer_end_) primary_char = 0; \
308 else primary_char = *(cursor_); \ 308 else primary_char = *(cursor_); \
309 } 309 }
310 310
311 #ifdef DEBUG 311 #ifdef DEBUG
312 #define CRASH() { ((void(*)())0)(); } 312 #define CRASH() { ((void(*)())0)(); }
313 #else 313 #else
314 #define CRASH() { } 314 #define CRASH() { }
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 const {{char_type}} * marker;
326 {{char_type}} primary_char; 326 {{char_type}} primary_char;
327 READ_CURSOR();
328 327
329 {# first node is start node #} 328 {# first node is start node #}
330 {% for dfa_state in dfa_states -%} 329 {% for dfa_state in dfa_states -%}
331 {%- if not dfa_state['inline'] %} 330 {%- if not dfa_state['inline'] %}
332 {{ do_dfa_state([dfa_state['node_number']]) }} 331 {{ do_dfa_state([dfa_state['node_number']]) }}
333 {%- endif -%} 332 {%- endif -%}
334 {%- endfor %} 333 {%- endfor %}
335 334
336 // Execute the default action. 335 // Execute the default action.
337 default_action: 336 default_action:
338 {%- if debug_print %} 337 {%- if debug_print %}
339 fprintf(stderr, "default action\n"); 338 fprintf(stderr, "default action\n");
340 {% endif -%} 339 {% endif -%}
341 {{dispatch_match_action(default_action[0], default_action[1])}} 340 {{dispatch_match_action(default_action[0], default_action[1])}}
342 CRASH(); 341 CRASH();
343 342
344 if (false) { 343 if (false) {
345 // force use of stored_token 344 // force use of stored_token
346 stored_token = Token::ILLEGAL; 345 stored_token = Token::ILLEGAL;
347 // force use of marker 346 // force use of marker
348 marker = NULL; 347 marker = NULL;
349 // force use of state_entry_0 348 // force use of state_entry_0
350 goto state_entry_0; 349 goto state_entry_0;
351 } 350 }
352 } 351 }
353 } } 352 } }
354 353
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698