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

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

Issue 44403002: Experimental scanner: number and whitespace fixes. (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 | 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 // Portions of this code based on re2c: 1 // Portions of this code based on re2c:
2 // (re2c/examples/push.re) 2 // (re2c/examples/push.re)
3 // Copyright 2013 the V8 project authors. All rights reserved. 3 // Copyright 2013 the V8 project authors. All rights reserved.
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 any = [\000-\377]; 259 any = [\000-\377];
260 whitespace_char = [ \t\v\f\r]; 260 whitespace_char = [ \t\v\f\r];
261 whitespace = whitespace_char+; 261 whitespace = whitespace_char+;
262 identifier_start = [$_a-zA-Z]; 262 identifier_start = [$_a-zA-Z];
263 identifier_char = [$_a-zA-Z0-9]; 263 identifier_char = [$_a-zA-Z0-9];
264 not_identifier_char = any\identifier_char\[\\]; 264 not_identifier_char = any\identifier_char\[\\];
265 line_terminator = [\n\r]+; 265 line_terminator = [\n\r]+;
266 digit = [0-9]; 266 digit = [0-9];
267 hex_digit = [0-9a-fA-F]; 267 hex_digit = [0-9a-fA-F];
268 maybe_exponent = ('e' [-+]? digit+)?; 268 maybe_exponent = ('e' [-+]? digit+)?;
269 number = ('0x' hex_digit+) | ("." digit+ maybe_exponent) | (digit+ ("." digi t+)? maybe_exponent); 269 number = ('0x' hex_digit+) | ("." digit+ maybe_exponent) | (digit+ ("." digi t*)? maybe_exponent);
270 270
271 <Normal> "break" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::BREA K); } 271 <Normal> "break" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::BREA K); }
272 <Normal> "case" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CASE ); } 272 <Normal> "case" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CASE ); }
273 <Normal> "catch" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CATC H); } 273 <Normal> "catch" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CATC H); }
274 <Normal> "class" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::FUTU RE_RESERVED_WORD); } 274 <Normal> "class" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::FUTU RE_RESERVED_WORD); }
275 <Normal> "const" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONS T); } 275 <Normal> "const" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONS T); }
276 <Normal> "continue" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONT INUE); } 276 <Normal> "continue" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::CONT INUE); }
277 <Normal> "debugger" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DEBU GGER); } 277 <Normal> "debugger" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DEBU GGER); }
278 <Normal> "default" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DEFA ULT); } 278 <Normal> "default" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DEFA ULT); }
279 <Normal> "delete" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DELE TE); } 279 <Normal> "delete" not_identifier_char { PUSH_TOKEN_LOOKAHEAD(Token::DELE TE); }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 <Normal> "%=" { PUSH_TOKEN(Token::ASSIGN_MOD); } 324 <Normal> "%=" { PUSH_TOKEN(Token::ASSIGN_MOD); }
325 325
326 <Normal> "===" { PUSH_TOKEN(Token::EQ_STRICT); } 326 <Normal> "===" { PUSH_TOKEN(Token::EQ_STRICT); }
327 <Normal> "==" { PUSH_TOKEN(Token::EQ); } 327 <Normal> "==" { PUSH_TOKEN(Token::EQ); }
328 <Normal> "=" { PUSH_TOKEN(Token::ASSIGN); } 328 <Normal> "=" { PUSH_TOKEN(Token::ASSIGN); }
329 <Normal> "!==" { PUSH_TOKEN(Token::NE_STRICT); } 329 <Normal> "!==" { PUSH_TOKEN(Token::NE_STRICT); }
330 <Normal> "!=" { PUSH_TOKEN(Token::NE); } 330 <Normal> "!=" { PUSH_TOKEN(Token::NE); }
331 <Normal> "!" { PUSH_TOKEN(Token::NOT); } 331 <Normal> "!" { PUSH_TOKEN(Token::NOT); }
332 332
333 <Normal> "//" :=> SingleLineComment 333 <Normal> "//" :=> SingleLineComment
334 <Normal> whitespace? "-->" { if (just_seen_line_terminator_) { YYSETCONDITIO N(kConditionSingleLineComment); goto yy0; } else { --cursor_; send(Token::DEC); start_ = cursor_; goto yy0; } } 334 <Normal> whitespace* "-->" { if (just_seen_line_terminator_) { YYSETCONDITIO N(kConditionSingleLineComment); goto yy0; } else { --cursor_; send(Token::DEC); start_ = cursor_; goto yy0; } }
335 <Normal> "/*" :=> MultiLineComment 335 <Normal> "/*" :=> MultiLineComment
336 <Normal> "<!--" :=> HtmlComment 336 <Normal> "<!--" :=> HtmlComment
337 337
338 <Normal> ">>>=" { PUSH_TOKEN(Token::ASSIGN_SHR); } 338 <Normal> ">>>=" { PUSH_TOKEN(Token::ASSIGN_SHR); }
339 <Normal> ">>>" { PUSH_TOKEN(Token::SHR); } 339 <Normal> ">>>" { PUSH_TOKEN(Token::SHR); }
340 <Normal> "<<=" { PUSH_TOKEN(Token::ASSIGN_SHL); } 340 <Normal> "<<=" { PUSH_TOKEN(Token::ASSIGN_SHL); }
341 <Normal> ">>=" { PUSH_TOKEN(Token::ASSIGN_SAR); } 341 <Normal> ">>=" { PUSH_TOKEN(Token::ASSIGN_SAR); }
342 <Normal> "<=" { PUSH_TOKEN(Token::LTE); } 342 <Normal> "<=" { PUSH_TOKEN(Token::LTE); }
343 <Normal> ">=" { PUSH_TOKEN(Token::GTE); } 343 <Normal> ">=" { PUSH_TOKEN(Token::GTE); }
344 <Normal> "<<" { PUSH_TOKEN(Token::SHL); } 344 <Normal> "<<" { PUSH_TOKEN(Token::SHL); }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 size_t start_offset = start_ - buffer_; 463 size_t start_offset = start_ - buffer_;
464 memmove(buffer_, start_, limit_ - start_); 464 memmove(buffer_, start_, limit_ - start_);
465 marker_ -= start_offset; 465 marker_ -= start_offset;
466 cursor_ -= start_offset; 466 cursor_ -= start_offset;
467 limit_ -= start_offset; 467 limit_ -= start_offset;
468 start_ -= start_offset; 468 start_ -= start_offset;
469 real_start_ += start_offset; 469 real_start_ += start_offset;
470 } 470 }
471 return 0; 471 return 0;
472 } 472 }
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