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

Side by Side Diff: src/lexer/lexer.re

Issue 27315002: Experimental push model parser: Keywords. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 2 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 #include <fcntl.h> 1 #include <fcntl.h>
2 #include <stdio.h> 2 #include <stdio.h>
3 #include <stddef.h> 3 #include <stddef.h>
4 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <string.h> 5 #include <string.h>
6 6
7 // TODO: 7 // TODO:
8 // - SpiderMonkey compatibility hack: " --> something" is treated 8 // - SpiderMonkey compatibility hack: " --> something" is treated
9 // as a single line comment. 9 // as a single line comment.
10 // - An identifier cannot start immediately after a number. 10 // - An identifier cannot start immediately after a number.
11 // - Run-time lexing modifications: harmony number literals, keywords depending
12 // on harmony_modules, harmony_scoping
11 13
12 enum Condition { 14 enum Condition {
13 kConditionNormal, 15 kConditionNormal,
14 kConditionDoubleQuoteString, 16 kConditionDoubleQuoteString,
15 kConditionSingleQuoteString, 17 kConditionSingleQuoteString,
16 kConditionIdentifier, 18 kConditionIdentifier,
17 kConditionSingleLineComment, 19 kConditionSingleLineComment,
18 kConditionMultiLineComment, 20 kConditionMultiLineComment,
19 kConditionHtmlComment 21 kConditionHtmlComment
20 }; 22 };
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 any = [\000-\377]; 169 any = [\000-\377];
168 whitespace_char = [ \t\v\f\r]; 170 whitespace_char = [ \t\v\f\r];
169 whitespace = whitespace_char+; 171 whitespace = whitespace_char+;
170 identifier_start_ = [$_\\a-zA-z]; 172 identifier_start_ = [$_\\a-zA-z];
171 identifier_char = [$_\\a-zA-z0-9]; 173 identifier_char = [$_\\a-zA-z0-9];
172 line_terminator = [\n\r]+; 174 line_terminator = [\n\r]+;
173 digit = [0-9]; 175 digit = [0-9];
174 hex_digit = [0-9a-fA-F]; 176 hex_digit = [0-9a-fA-F];
175 maybe_exponent = ('e' [-+]? digit+)?; 177 maybe_exponent = ('e' [-+]? digit+)?;
176 178
179 <Normal> "break" { PUSH_TOKEN(Token::BREAK); }
180 <Normal> "case" { PUSH_TOKEN(Token::CASE); }
181 <Normal> "catch" { PUSH_TOKEN(Token::CATCH); }
182 <Normal> "class" { PUSH_TOKEN(Token::FUTURE_RESERVED_WORD); }
183 <Normal> "const" { PUSH_TOKEN(Token::CONST); }
184 <Normal> "continue" { PUSH_TOKEN(Token::CONTINUE); }
185 <Normal> "debugger" { PUSH_TOKEN(Token::DEBUGGER); }
186 <Normal> "default" { PUSH_TOKEN(Token::DEFAULT); }
187 <Normal> "delete" { PUSH_TOKEN(Token::DELETE); }
188 <Normal> "do" { PUSH_TOKEN(Token::DO); }
189 <Normal> "else" { PUSH_TOKEN(Token::ELSE); }
190 <Normal> "enum" { PUSH_TOKEN(Token::FUTURE_RESERVED_WORD); }
191 <Normal> "export" { PUSH_TOKEN(Token::FUTURE_RESERVED_WORD); }
192 <Normal> "extends" { PUSH_TOKEN(Token::FUTURE_RESERVED_WORD); }
193 <Normal> "false" { PUSH_TOKEN(Token::FALSE_LITERAL); }
194 <Normal> "finally" { PUSH_TOKEN(Token::FINALLY); }
195 <Normal> "for" { PUSH_TOKEN(Token::FOR); }
196 <Normal> "function" { PUSH_TOKEN(Token::FUNCTION); }
197 <Normal> "if" { PUSH_TOKEN(Token::IF); }
198 <Normal> "implements" { PUSH_TOKEN(Token::FUTURE_STRICT_RESERVED_WORD); }
199 <Normal> "import" { PUSH_TOKEN(Token::FUTURE_RESERVED_WORD); }
200 <Normal> "in" { PUSH_TOKEN(Token::IN); }
201 <Normal> "instanceof" { PUSH_TOKEN(Token::INSTANCEOF); }
202 <Normal> "interface" { PUSH_TOKEN(Token::FUTURE_STRICT_RESERVED_WORD); }
203 <Normal> "let" { PUSH_TOKEN(Token::FUTURE_STRICT_RESERVED_WORD); }
204 <Normal> "new" { PUSH_TOKEN(Token::NEW); }
205 <Normal> "null" { PUSH_TOKEN(Token::NULL_LITERAL); }
206 <Normal> "package" { PUSH_TOKEN(Token::FUTURE_STRICT_RESERVED_WORD); }
207 <Normal> "private" { PUSH_TOKEN(Token::FUTURE_STRICT_RESERVED_WORD); }
208 <Normal> "protected" { PUSH_TOKEN(Token::FUTURE_STRICT_RESERVED_WORD); }
209 <Normal> "public" { PUSH_TOKEN(Token::FUTURE_STRICT_RESERVED_WORD); }
210 <Normal> "return" { PUSH_TOKEN(Token::RETURN); }
211 <Normal> "static" { PUSH_TOKEN(Token::FUTURE_STRICT_RESERVED_WORD); }
212 <Normal> "super" { PUSH_TOKEN(Token::FUTURE_RESERVED_WORD); }
213 <Normal> "switch" { PUSH_TOKEN(Token::SWITCH); }
214 <Normal> "this" { PUSH_TOKEN(Token::THIS); }
215 <Normal> "throw" { PUSH_TOKEN(Token::THROW); }
216 <Normal> "true" { PUSH_TOKEN(Token::TRUE_LITERAL); }
217 <Normal> "try" { PUSH_TOKEN(Token::TRY); }
218 <Normal> "typeof" { PUSH_TOKEN(Token::TYPEOF); }
219 <Normal> "var" { PUSH_TOKEN(Token::VAR); }
220 <Normal> "void" { PUSH_TOKEN(Token::VOID); }
221 <Normal> "while" { PUSH_TOKEN(Token::WHILE); }
222 <Normal> "with" { PUSH_TOKEN(Token::WITH); }
223 <Normal> "yield" { PUSH_TOKEN(Token::YIELD); }
224
177 <Normal> "|=" { PUSH_TOKEN(Token::ASSIGN_BIT_OR); } 225 <Normal> "|=" { PUSH_TOKEN(Token::ASSIGN_BIT_OR); }
178 <Normal> "^=" { PUSH_TOKEN(Token::ASSIGN_BIT_XOR); } 226 <Normal> "^=" { PUSH_TOKEN(Token::ASSIGN_BIT_XOR); }
179 <Normal> "&=" { PUSH_TOKEN(Token::ASSIGN_BIT_AND); } 227 <Normal> "&=" { PUSH_TOKEN(Token::ASSIGN_BIT_AND); }
180 <Normal> "+=" { PUSH_TOKEN(Token::ASSIGN_ADD); } 228 <Normal> "+=" { PUSH_TOKEN(Token::ASSIGN_ADD); }
181 <Normal> "-=" { PUSH_TOKEN(Token::ASSIGN_SUB); } 229 <Normal> "-=" { PUSH_TOKEN(Token::ASSIGN_SUB); }
182 <Normal> "*=" { PUSH_TOKEN(Token::ASSIGN_MUL); } 230 <Normal> "*=" { PUSH_TOKEN(Token::ASSIGN_MUL); }
183 <Normal> "/=" { PUSH_TOKEN(Token::ASSIGN_DIV); } 231 <Normal> "/=" { PUSH_TOKEN(Token::ASSIGN_DIV); }
184 <Normal> "%=" { PUSH_TOKEN(Token::ASSIGN_MOD); } 232 <Normal> "%=" { PUSH_TOKEN(Token::ASSIGN_MOD); }
185 233
186 <Normal> "===" { PUSH_TOKEN(Token::EQ_STRICT); } 234 <Normal> "===" { PUSH_TOKEN(Token::EQ_STRICT); }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 411 }
364 412
365 413
366 void ExperimentalScanner::Record(Token::Value token, int beg, int end) { 414 void ExperimentalScanner::Record(Token::Value token, int beg, int end) {
367 if (token == Token::EOS) end--; 415 if (token == Token::EOS) end--;
368 token_[fetched_] = token; 416 token_[fetched_] = token;
369 beg_[fetched_] = beg; 417 beg_[fetched_] = beg;
370 end_[fetched_] = end; 418 end_[fetched_] = end;
371 fetched_++; 419 fetched_++;
372 } 420 }
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