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

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

Issue 44053004: Experimental scanner: misc 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 <Normal> whitespace { SKIP(); } 381 <Normal> whitespace { SKIP(); }
382 382
383 <Normal> ["] :=> DoubleQuoteString 383 <Normal> ["] :=> DoubleQuoteString
384 <Normal> ['] :=> SingleQuoteString 384 <Normal> ['] :=> SingleQuoteString
385 385
386 <Normal> identifier_start :=> Identifier 386 <Normal> identifier_start :=> Identifier
387 <Normal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { YYSETCONDITION (kConditionIdentifier); goto yy0; } send(Token::ILLEGAL); start_ = cursor_; goto yy0; } 387 <Normal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { YYSETCONDITION (kConditionIdentifier); goto yy0; } send(Token::ILLEGAL); start_ = cursor_; goto yy0; }
388 <Normal> "\\" { PUSH_TOKEN(Token::ILLEGAL); } 388 <Normal> "\\" { PUSH_TOKEN(Token::ILLEGAL); }
389 389
390 <Normal> eof { PUSH_EOF_AND_RETURN();} 390 <Normal> eof { PUSH_EOF_AND_RETURN();}
391 <Normal> any { marker_ = cursor_; YYSETCONDITION(kConditionIdentif ierIllegal); goto yy0; } 391 <Normal> any { PUSH_TOKEN(Token::ILLEGAL); }
392 392
393 <DoubleQuoteString> "\\\\" { goto yy0; } 393 <DoubleQuoteString> "\\\\" { goto yy0; }
394 <DoubleQuoteString> "\\\"" { goto yy0; } 394 <DoubleQuoteString> "\\\"" { goto yy0; }
395 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);} 395 <DoubleQuoteString> '"' { PUSH_TOKEN(Token::STRING);}
396 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; } 396 <DoubleQuoteString> "\\" "\n" "\r"? { goto yy0; }
397 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; } 397 <DoubleQuoteString> "\\" "\r" "\n"? { goto yy0; }
398 <DoubleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL) ; } 398 <DoubleQuoteString> "\n" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL) ; }
399 <DoubleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL) ; } 399 <DoubleQuoteString> "\r" => Normal { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL) ; }
400 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); } 400 <DoubleQuoteString> eof { TERMINATE_ILLEGAL(); }
401 <DoubleQuoteString> any { goto yy0; } 401 <DoubleQuoteString> any { goto yy0; }
(...skipping 15 matching lines...) Expand all
417 417
418 <IdentifierIllegal> identifier_start { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL) ; } 418 <IdentifierIllegal> identifier_start { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL) ; }
419 <IdentifierIllegal> identifier_char\identifier_start { marker_ = cursor_; g oto yy0; } 419 <IdentifierIllegal> identifier_char\identifier_start { marker_ = cursor_; g oto yy0; }
420 <IdentifierIllegal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { cur sor_ -= 6; PUSH_TOKEN(Token::ILLEGAL); } marker_ = cursor_; PUSH_TOKEN(Token::IL LEGAL); } 420 <IdentifierIllegal> "\\u" [0-9a-fA-F]{4} { if (ValidIdentifierStart()) { cur sor_ -= 6; PUSH_TOKEN(Token::ILLEGAL); } marker_ = cursor_; PUSH_TOKEN(Token::IL LEGAL); }
421 <IdentifierIllegal> "\\"+ { marker_ = cursor_; goto yy0; } 421 <IdentifierIllegal> "\\"+ { marker_ = cursor_; goto yy0; }
422 <IdentifierIllegal> number not_identifier_char { YYCTYPE* temp = cursor_; cu rsor_ = marker_; send(Token::ILLEGAL); cursor_ = temp; YYSETCONDITION(kCondition Normal); PUSH_TOKEN_LOOKAHEAD(Token::NUMBER); } 422 <IdentifierIllegal> number not_identifier_char { YYCTYPE* temp = cursor_; cu rsor_ = marker_; send(Token::ILLEGAL); cursor_ = temp; YYSETCONDITION(kCondition Normal); PUSH_TOKEN_LOOKAHEAD(Token::NUMBER); }
423 <IdentifierIllegal> number "\\u" [0-9a-fA-F]{4} { YYCTYPE* temp = cursor_; c ursor_ = marker_; send(Token::ILLEGAL); cursor_ = temp; send(Token::ILLEGAL); st art_ = cursor_; goto yy0; } 423 <IdentifierIllegal> number "\\u" [0-9a-fA-F]{4} { YYCTYPE* temp = cursor_; c ursor_ = marker_; send(Token::ILLEGAL); cursor_ = temp; send(Token::ILLEGAL); st art_ = cursor_; goto yy0; }
424 <IdentifierIllegal> any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL) ; } 424 <IdentifierIllegal> any { PUSH_TOKEN_LOOKAHEAD(Token::ILLEGAL) ; }
425 425
426 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();} 426 <SingleLineComment> line_terminator { PUSH_LINE_TERMINATOR();}
427 <SingleLineComment> eof { PUSH_TOKEN(Token::EOS); } 427 <SingleLineComment> eof { start_ = cursor_ - 1; PUSH_TOKEN(Token ::EOS); }
428 <SingleLineComment> any { goto yy0; } 428 <SingleLineComment> any { goto yy0; }
429 429
430 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();} 430 <MultiLineComment> [*][//] { PUSH_LINE_TERMINATOR();}
431 <MultiLineComment> eof { TERMINATE_ILLEGAL(); } 431 <MultiLineComment> eof { start_ = cursor_ - 1; PUSH_TOKEN(Token::EOS); }
432 <MultiLineComment> any { goto yy0; } 432 <MultiLineComment> any { goto yy0; }
433 433
434 <HtmlComment> eof { TERMINATE_ILLEGAL(); } 434 <HtmlComment> eof { start_ = cursor_ - 1; PUSH_TOKEN(Token::EOS); }
435 <HtmlComment> "-->" { PUSH_LINE_TERMINATOR();} 435 <HtmlComment> "-->" { PUSH_LINE_TERMINATOR();}
436 <HtmlComment> line_terminator+ { PUSH_LINE_TERMINATOR();} 436 <HtmlComment> line_terminator+ { PUSH_LINE_TERMINATOR();}
437 <HtmlComment> any { goto yy0; } 437 <HtmlComment> any { goto yy0; }
438 */ 438 */
439 439
440 fill: 440 fill:
441 int unfinished_size = cursor_ - start_; 441 int unfinished_size = cursor_ - start_;
442 if (FLAG_trace_lexer) { 442 if (FLAG_trace_lexer) {
443 printf( 443 printf(
444 "scanner needs a refill. Exiting for now with:\n" 444 "scanner needs a refill. Exiting for now with:\n"
(...skipping 18 matching lines...) Expand all
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