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

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

Issue 85373003: Experimental parser: cleanup naming a bit (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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_py.re ('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 #include "lexer/experimental-scanner.h" 1 #include "lexer/experimental-scanner.h"
2 2
3 {%- macro do_key(key) -%} 3 {%- macro do_key(key) -%}
4 {%- for r in key -%} 4 {%- for r in key -%}
5 {%- if not loop.first %} || {% endif -%} 5 {%- if not loop.first %} || {% endif -%}
6 {%- if r[0] == 'PRIMARY_RANGE' -%} 6 {%- if r[0] == 'PRIMARY_RANGE' -%}
7 {%- if r[1][0] == r[1][1] -%} 7 {%- if r[1][0] == r[1][1] -%}
8 primary_char == {{r[1][0]}} 8 primary_char == {{r[1][0]}}
9 {%- elif r[1][0] == 0 -%} 9 {%- elif r[1][0] == 0 -%}
10 primary_char <= {{r[1][1]}} 10 primary_char <= {{r[1][1]}}
(...skipping 27 matching lines...) Expand all
38 uncompilable code for {{encoding}} {{r[0]}} {{r[1]}} 38 uncompilable code for {{encoding}} {{r[0]}} {{r[1]}}
39 {%- endif -%} 39 {%- endif -%}
40 {%- endfor -%} 40 {%- endfor -%}
41 {%- endmacro -%} 41 {%- endmacro -%}
42 42
43 43
44 {% macro dispatch_action(type, value) -%} 44 {% macro dispatch_action(type, value) -%}
45 {%- if type == 'code' %} 45 {%- if type == 'code' %}
46 {{value}} 46 {{value}}
47 {% elif type == 'terminate' %} 47 {% elif type == 'terminate' %}
48 PUSH_EOS(); 48 DO_EOS();
49 {% elif type == 'terminate_illegal' %} 49 {% elif type == 'terminate_illegal' %}
50 start_ = marker_; BACKWARD(1); PUSH_TOKEN(Token::ILLEGAL); 50 start_ = marker_;
51 BACKWARD(1);
52 DO_TOKEN(Token::ILLEGAL);
51 {% elif type == 'skip' %} 53 {% elif type == 'skip' %}
52 SKIP(); 54 SKIP();
53 {% elif type == 'skip_and_terminate' %} 55 {% elif type == 'skip_and_terminate' %}
54 SKIP(); 56 SKIP();
55 --start_; 57 --start_;
56 {{dispatch_action('terminate', None)}} 58 {{dispatch_action('terminate', None)}}
57 {% elif type == 'push_line_terminator' %} 59 {% elif type == 'line_terminator' %}
58 PUSH_LINE_TERMINATOR(); 60 DO_LINE_TERMINATOR();
59 {% elif type == 'push_token' %} 61 {% elif type == 'token' %}
60 PUSH_TOKEN(Token::{{value}}) 62 DO_TOKEN(Token::{{value}})
61 {% elif type == 'push_token_and_go_forward' %} 63 {% elif type == 'do_token_and_go_forward' %}
62 PUSH_TOKEN_AND_GO_FORWARD(Token::{{value}}) 64 DO_TOKEN_AND_GO_FORWARD(Token::{{value}})
63 {% elif type == 'push_harmony_token' %} 65 {% elif type == 'harmony_token' %}
64 if (harmony_{{value[0]}}_) { 66 if (harmony_{{value[0]}}_) {
65 PUSH_TOKEN(Token::{{value[1][0]}}); 67 DO_TOKEN(Token::{{value[1][0]}});
66 } else { 68 } else {
67 PUSH_TOKEN(Token::{{value[1][1]}}); 69 DO_TOKEN(Token::{{value[1][1]}});
68 } 70 }
69 {% elif type == 'set_marker' %} 71 {% elif type == 'set_marker' %}
70 marker_ = cursor_ - {{value}}; 72 marker_ = cursor_ - {{value}};
71 {% else %} 73 {% else %}
72 uncompilable code for {{type}} 74 uncompilable code for {{type}}
73 {% endif -%} 75 {% endif -%}
74 {%- endmacro -%} 76 {%- endmacro -%}
75 77
76 78
77 {%- macro long_char_check() -%} 79 {%- macro long_char_check() -%}
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 184
183 {%- if match_action %} 185 {%- if match_action %}
184 {{ dispatch_action(match_action[0], match_action[1]) }} 186 {{ dispatch_action(match_action[0], match_action[1]) }}
185 goto code_start; 187 goto code_start;
186 {% else %} 188 {% else %}
187 goto default_action; 189 goto default_action;
188 {%- endif %} 190 {%- endif %}
189 191
190 {%- endmacro %} 192 {%- endmacro %}
191 193
192 #define PREPARE_PUSH_TOKEN() { \ 194 #define PREPARE_TOKEN() { \
193 next_.beg_pos = start_ - buffer_; \ 195 next_.beg_pos = start_ - buffer_; \
194 next_.end_pos = cursor_ - buffer_; \ 196 next_.end_pos = cursor_ - buffer_; \
195 start_ = cursor_; \ 197 start_ = cursor_; \
196 } 198 }
197 199
198 #define PUSH_TOKEN(T) { \ 200 #define DO_TOKEN(T) { \
199 PREPARE_PUSH_TOKEN(); \ 201 PREPARE_TOKEN(); \
200 next_.token = T; \ 202 next_.token = T; \
201 return; \ 203 return; \
202 } 204 }
203 205
204 #define PUSH_TOKEN_AND_GO_FORWARD(T) {\ 206 #define DO_TOKEN_AND_GO_FORWARD(T) { \
205 PREPARE_PUSH_TOKEN(); \ 207 PREPARE_TOKEN(); \
206 FORWARD(); \ 208 FORWARD(); \
207 next_.token = T; \ 209 next_.token = T; \
208 return; \ 210 return; \
209 } 211 }
210 212
211 #define PUSH_EOS() { \ 213 #define DO_EOS() { \
212 cursor_ -= 1; \ 214 cursor_ -= 1; \
213 PUSH_TOKEN(Token::EOS); \ 215 DO_TOKEN(Token::EOS); \
214 } 216 }
215 217
216 #define PUSH_LINE_TERMINATOR(s) { \ 218 #define DO_LINE_TERMINATOR(s) { \
217 start_ = cursor_; \ 219 start_ = cursor_; \
218 has_line_terminator_before_next_ = true; \ 220 has_line_terminator_before_next_ = true; \
219 } 221 }
220 222
221 #define FORWARD() { \ 223 #define FORWARD() { \
222 if (++cursor_ >= buffer_end_) primary_char = 0; \ 224 if (++cursor_ >= buffer_end_) primary_char = 0; \
223 else primary_char = *(cursor_); \ 225 else primary_char = *(cursor_); \
224 } 226 }
225 227
226 #define BACKWARD(n) { \ 228 #define BACKWARD(n) { \
227 cursor_ -= n; \ 229 cursor_ -= n; \
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 {% endif -%} 261 {% endif -%}
260 {{dispatch_action(default_action[0], default_action[1])}} 262 {{dispatch_action(default_action[0], default_action[1])}}
261 FORWARD(); 263 FORWARD();
262 goto code_start; 264 goto code_start;
263 265
264 fell_through: 266 fell_through:
265 CHECK(false); 267 CHECK(false);
266 } 268 }
267 } } 269 } }
268 270
OLDNEW
« no previous file with comments | « src/lexer/lexer_py.re ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698