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

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

Issue 78713002: Experimental lexer generator: generate code for utf-16 character classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Code review (dcarney) 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 | « src/scanner.h ('k') | 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 {# TODO implement CLASS checks #}
4 {%- macro do_key(key) -%} 3 {%- macro do_key(key) -%}
5 {%- for r in key -%} 4 {%- for r in key -%}
6 {%- if not loop.first %} || {% endif -%} 5 {%- if not loop.first %} || {% endif -%}
7 {%- if r[0] == 'LATIN_1' -%} 6 {%- if r[0] == 'LATIN_1' -%}
8 {%- if r[1][0] == r[1][1] -%} 7 {%- if r[1][0] == r[1][1] -%}
9 yych == {{r[1][0]}} 8 yych == {{r[1][0]}}
10 {%- elif r[1][0] == 0 -%} 9 {%- elif r[1][0] == 0 -%}
11 yych <= {{r[1][1]}} 10 yych <= {{r[1][1]}}
12 {%- elif r[1][1] == 255 -%} 11 {%- elif r[1][1] == 255 -%}
13 yych >= {{r[1][0]}} 12 yych >= {{r[1][0]}}
14 {%- else -%} 13 {%- else -%}
15 ({{r[1][0]}} <= yych && yych <= {{r[1][1]}}) 14 ({{r[1][0]}} <= yych && yych <= {{r[1][1]}})
16 {%- endif -%} 15 {%- endif -%}
17 {%- elif r[0] == 'CLASS' -%} 16 {%- elif r[0] == 'CLASS' -%}
18 {%- if r[1] == 'eos' -%} 17 {%- if r[1] == 'eos' -%}
19 (yych == 0 && cursor_ >= buffer_end_) 18 (yych == 0 && cursor_ >= buffer_end_)
20 {%- elif r[1] == 'zero' -%} 19 {%- elif r[1] == 'zero' -%}
21 (yych == 0 && cursor_ < buffer_end_) 20 (yych == 0 && cursor_ < buffer_end_)
21 {%- elif r[1] == 'whitespace' and encoding == 'utf16'-%}
22 unicode_cache_->IsWhiteSpace(yych)
23 {%- elif r[1] == 'letter' and encoding == 'utf16'-%}
24 {# FIXME: Add and use unicode_cache_->InNonAsciiLetter #}
25 (!(yych >= 'a' && yych <= 'z') && !(yych >= 'A' && yych <= 'Z') && unic ode_cache_->IsLetter(yych))
26 {%- elif r[1] == 'identifier_part_not_letter' and encoding == 'utf16'-%}
27 unicode_cache_->IsIdentifierPartNotLetter(yych)
22 {%- else -%} 28 {%- else -%}
23 » false 29 » false /* {{r[1]}} */
24 {%- endif -%} 30 {%- endif -%}
25 {%- else -%} 31 {%- else -%}
26 false 32 false
27 {%- endif -%} 33 {%- endif -%}
28 {%- endfor -%} 34 {%- endfor -%}
29 {%- endmacro -%} 35 {%- endmacro -%}
30 36
31 37
32 {% macro dispatch_action(type, value) -%} 38 {% macro dispatch_action(type, value) -%}
33 {%- if type == 'code' %} 39 {%- if type == 'code' %}
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 {% endif -%} 201 {% endif -%}
196 {{dispatch_action(default_action[0], default_action[1])}} 202 {{dispatch_action(default_action[0], default_action[1])}}
197 FORWARD(); 203 FORWARD();
198 goto code_start; 204 goto code_start;
199 205
200 fell_through: 206 fell_through:
201 CHECK(false); 207 CHECK(false);
202 } 208 }
203 } } 209 } }
204 210
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | tools/lexer_generator/code_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698