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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/lexer_generator/code_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "lexer/even-more-experimental-scanner.h" 1 #include "lexer/even-more-experimental-scanner.h"
2 2
3 3
4 {# TODO implement CLASS checks #} 4 {# TODO implement CLASS checks #}
5 {%- macro do_key(key) -%} 5 {%- macro do_key(key) -%}
6 {%- for r in key.range_iter() -%} 6 {%- for r in key -%}
7 {%- if not loop.first %} || {% endif -%} 7 {%- if not loop.first %} || {% endif -%}
8 {%- if r[0] == 'LATIN_1' -%} 8 {%- if r[0] == 'LATIN_1' -%}
9 {%- if r[1][0] == r[1][1] -%} 9 {%- if r[1][0] == r[1][1] -%}
10 yych == {{r[1][0]}} 10 yych == {{r[1][0]}}
11 {%- elif r[1][0] == 0 -%} 11 {%- elif r[1][0] == 0 -%}
12 yych <= {{r[1][1]}} 12 yych <= {{r[1][1]}}
13 {%- elif r[1][1] == 255 -%} 13 {%- elif r[1][1] == 255 -%}
14 yych >= {{r[1][0]}} 14 yych >= {{r[1][0]}}
15 {%- else -%} 15 {%- else -%}
16 ({{r[1][0]}} <= yych && yych <= {{r[1][1]}}) 16 ({{r[1][0]}} <= yych && yych <= {{r[1][1]}})
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 {%- set entry_action = state.entry_action -%} 77 {%- set entry_action = state.entry_action -%}
78 {%- if entry_action %} 78 {%- if entry_action %}
79 {{ dispatch_action(entry_action[0], entry_action[1]) }} 79 {{ dispatch_action(entry_action[0], entry_action[1]) }}
80 {%- endif %} 80 {%- endif %}
81 81
82 {%- if debug_print %} 82 {%- if debug_print %}
83 fprintf(stderr, "char at hand is %c (%d)\n", yych, yych); 83 fprintf(stderr, "char at hand is %c (%d)\n", yych, yych);
84 {% endif -%} 84 {% endif -%}
85 85
86 {%- for key, transition_state_id in state.transitions %} 86 {%- if state['switch_transitions'] -%}
87 {%- set inline_transition = dfa_states[transition_state_id]['inline'] -%} 87 switch(yych) {
88 if ({{do_key(key)}}) { 88 {%- for key, transition_state_id in state['switch_transitions'] %}
89 FORWARD(); 89 case {{key}}:
90 {%- set inline_transition = dfa_states[transition_state_id]['inline'] %}
91 FORWARD();
90 {%- if inline_transition %} 92 {%- if inline_transition %}
91 {{ do_dfa_state(transition_state_id, True) }} 93 {{ do_dfa_state(transition_state_id, True) }}
92 {% else %} 94 {% else %}
95 goto code_{{transition_state_id}};
96 {% endif %}
97 {% endfor -%}
98 }
99 {%- endif -%}
100
101 {%- for key, transition_state_id in state.transitions %}
102 if ({{do_key(key)}}) {
103 {%- set inline_transition = dfa_states[transition_state_id]['inline'] %}
104 FORWARD();
105 {%- if inline_transition %}
106 {{ do_dfa_state(transition_state_id, True) }}
107 {% else %}
93 goto code_{{transition_state_id}}; 108 goto code_{{transition_state_id}};
94 {% endif %} 109 {% endif %}
95 } 110 }
96 {% endfor -%} 111 {% endfor -%}
97 112
98 {%- set match_action = state.match_action -%} 113 {%- set match_action = state.match_action -%}
99 114
100 {%- if match_action %} 115 {%- if match_action %}
101 {{ dispatch_action(match_action[0], match_action[1]) }} 116 {{ dispatch_action(match_action[0], match_action[1]) }}
102 goto code_start; 117 goto code_start;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 {% endif -%} 185 {% endif -%}
171 {{dispatch_action(default_action[0], default_action[1])}} 186 {{dispatch_action(default_action[0], default_action[1])}}
172 FORWARD(); 187 FORWARD();
173 goto code_start; 188 goto code_start;
174 189
175 fell_through: 190 fell_through:
176 CHECK(false); 191 CHECK(false);
177 } 192 }
178 } } 193 } }
179 194
OLDNEW
« 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