| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 kConditionSingleQuoteString, | 70 kConditionSingleQuoteString, |
| 71 kConditionIdentifier, | 71 kConditionIdentifier, |
| 72 kConditionIdentifierIllegal, | 72 kConditionIdentifierIllegal, |
| 73 kConditionSingleLineComment, | 73 kConditionSingleLineComment, |
| 74 kConditionMultiLineComment, | 74 kConditionMultiLineComment, |
| 75 kConditionHtmlComment | 75 kConditionHtmlComment |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 using namespace v8::internal; | 78 using namespace v8::internal; |
| 79 | 79 |
| 80 namespace { | |
| 81 | |
| 82 inline int HexValue(uc32 c) { | |
| 83 c -= '0'; | |
| 84 if (static_cast<unsigned>(c) <= 9) return c; | |
| 85 c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36. | |
| 86 if (static_cast<unsigned>(c) <= 5) return c + 10; | |
| 87 return -1; | |
| 88 } | |
| 89 | |
| 90 } | |
| 91 | |
| 92 #define PUSH_TOKEN(T) { send(T); SKIP(); } | 80 #define PUSH_TOKEN(T) { send(T); SKIP(); } |
| 93 #define PUSH_TOKEN_LOOKAHEAD(T) { --cursor_; send(T); SKIP(); } | 81 #define PUSH_TOKEN_LOOKAHEAD(T) { --cursor_; send(T); SKIP(); } |
| 94 #define PUSH_EOF_AND_RETURN() { send(Token::EOS); eof_ = true; return 1;} | 82 #define PUSH_EOF_AND_RETURN() { send(Token::EOS); eof_ = true; return 1;} |
| 95 #define PUSH_LINE_TERMINATOR() { just_seen_line_terminator_ = true; SKIP(); } | 83 #define PUSH_LINE_TERMINATOR() { just_seen_line_terminator_ = true; SKIP(); } |
| 96 #define TERMINATE_ILLEGAL() { send(Token::ILLEGAL); send(Token::EOS); return 1;
} | 84 #define TERMINATE_ILLEGAL() { send(Token::ILLEGAL); send(Token::EOS); return 1;
} |
| 97 | 85 |
| 98 PushScanner::PushScanner(ExperimentalScanner* sink, UnicodeCache* unicode_cache) | 86 PushScanner::PushScanner(ExperimentalScanner* sink, UnicodeCache* unicode_cache) |
| 99 : unicode_cache_(unicode_cache), | 87 : unicode_cache_(unicode_cache), |
| 100 eof_(false), | 88 eof_(false), |
| 101 state_(-1), | 89 state_(-1), |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 size_t start_offset = start_ - buffer_; | 420 size_t start_offset = start_ - buffer_; |
| 433 memmove(buffer_, start_, limit_ - start_); | 421 memmove(buffer_, start_, limit_ - start_); |
| 434 marker_ -= start_offset; | 422 marker_ -= start_offset; |
| 435 cursor_ -= start_offset; | 423 cursor_ -= start_offset; |
| 436 limit_ -= start_offset; | 424 limit_ -= start_offset; |
| 437 start_ -= start_offset; | 425 start_ -= start_offset; |
| 438 real_start_ += start_offset; | 426 real_start_ += start_offset; |
| 439 } | 427 } |
| 440 return 0; | 428 return 0; |
| 441 } | 429 } |
| OLD | NEW |