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

Unified Diff: tools/lexer_generator/code_generator.jinja

Issue 73453006: Experimental parser: switch blocks (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/lexer_generator/code_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/code_generator.jinja
diff --git a/tools/lexer_generator/code_generator.jinja b/tools/lexer_generator/code_generator.jinja
index d7fa82d514498aa86f2d5773233da88a18b311aa..fb5d8ea2986f961ef10a6a0aa3d7c2c87091db14 100644
--- a/tools/lexer_generator/code_generator.jinja
+++ b/tools/lexer_generator/code_generator.jinja
@@ -3,7 +3,7 @@
{# TODO implement CLASS checks #}
{%- macro do_key(key) -%}
- {%- for r in key.range_iter() -%}
+ {%- for r in key -%}
{%- if not loop.first %} || {% endif -%}
{%- if r[0] == 'LATIN_1' -%}
{%- if r[1][0] == r[1][1] -%}
@@ -83,10 +83,25 @@
fprintf(stderr, "char at hand is %c (%d)\n", yych, yych);
{% endif -%}
+ {%- if state['switch_transitions'] -%}
+ switch(yych) {
+ {%- for key, transition_state_id in state['switch_transitions'] %}
+ case {{key}}:
+ {%- set inline_transition = dfa_states[transition_state_id]['inline'] %}
+ FORWARD();
+ {%- if inline_transition %}
+ {{ do_dfa_state(transition_state_id, True) }}
+ {% else %}
+ goto code_{{transition_state_id}};
+ {% endif %}
+ {% endfor -%}
+ }
+ {%- endif -%}
+
{%- for key, transition_state_id in state.transitions %}
- {%- set inline_transition = dfa_states[transition_state_id]['inline'] -%}
if ({{do_key(key)}}) {
- FORWARD();
+ {%- set inline_transition = dfa_states[transition_state_id]['inline'] %}
+ FORWARD();
{%- if inline_transition %}
{{ do_dfa_state(transition_state_id, True) }}
{% else %}
« no previous file with comments | « no previous file | tools/lexer_generator/code_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698