| 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 12 matching lines...) Expand all Loading... |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 #ifndef V8_LEXER_LEXER_H | 30 #ifndef V8_LEXER_LEXER_H |
| 31 #define V8_LEXER_LEXER_H | 31 #define V8_LEXER_LEXER_H |
| 32 | 32 |
| 33 #if defined(WIN32) // FIXME: does this work? |
| 34 |
| 35 typedef signed char int8_t; |
| 36 typedef signed short int16_t; |
| 37 typedef signed int int32_t; |
| 38 |
| 39 typedef unsigned char uint8_t; |
| 40 typedef unsigned short uint16_t; |
| 41 typedef unsigned int uint32_t; |
| 42 |
| 43 #else |
| 44 |
| 45 #include <stdint.h> |
| 46 #include <unistd.h> |
| 47 |
| 48 #endif // defined(WIN32) |
| 49 |
| 33 #include "token.h" | 50 #include "token.h" |
| 34 #include "flags.h" | 51 #include "flags.h" |
| 35 | 52 |
| 53 #define YYCTYPE uint8_t |
| 54 |
| 36 namespace v8 { | 55 namespace v8 { |
| 37 namespace internal { | 56 namespace internal { |
| 38 | 57 |
| 39 class ExperimentalScanner; | 58 class ExperimentalScanner; |
| 40 class UnicodeCache; | 59 class UnicodeCache; |
| 41 | 60 |
| 42 class PushScanner { | 61 class PushScanner { |
| 43 public: | 62 public: |
| 44 explicit PushScanner(ExperimentalScanner* sink, UnicodeCache* unicode_cache); | 63 explicit PushScanner(ExperimentalScanner* sink, UnicodeCache* unicode_cache); |
| 45 | 64 |
| 46 ~PushScanner(); | 65 ~PushScanner(); |
| 47 | 66 |
| 48 void send(v8::internal::Token::Value token); | 67 void send(v8::internal::Token::Value token); |
| 49 uint32_t push(const void *input, int input_size); | 68 uint32_t push(const void *input, int input_size); |
| 50 | 69 |
| 51 private: | 70 private: |
| 52 bool ValidIdentifierStart(); | 71 bool ValidIdentifierStart(); |
| 53 bool ValidIdentifierPart(); | 72 bool ValidIdentifierPart(); |
| 54 uc32 ScanHexNumber(int length); | 73 uc32 ScanHexNumber(int length); |
| 55 | 74 |
| 56 UnicodeCache* unicode_cache_; | 75 UnicodeCache* unicode_cache_; |
| 57 | 76 |
| 58 bool eof_; | 77 bool eof_; |
| 59 int32_t state_; | 78 int32_t state_; |
| 60 int32_t condition_; | 79 int32_t condition_; |
| 61 | 80 |
| 62 uint8_t* limit_; | 81 YYCTYPE* limit_; |
| 63 uint8_t* start_; | 82 YYCTYPE* start_; |
| 64 uint8_t* cursor_; | 83 YYCTYPE* cursor_; |
| 65 uint8_t* marker_; | 84 YYCTYPE* marker_; |
| 66 int real_start_; | 85 int real_start_; |
| 67 | 86 |
| 68 uint8_t* buffer_; | 87 YYCTYPE* buffer_; |
| 69 uint8_t* buffer_end_; | 88 YYCTYPE* buffer_end_; |
| 70 | 89 |
| 71 uint8_t yych; | 90 YYCTYPE yych; |
| 72 uint32_t yyaccept; | 91 uint32_t yyaccept; |
| 73 | 92 |
| 74 bool just_seen_line_terminator_; | 93 bool just_seen_line_terminator_; |
| 75 | 94 |
| 76 ExperimentalScanner* sink_; | 95 ExperimentalScanner* sink_; |
| 77 }; | 96 }; |
| 78 | 97 |
| 79 } } | 98 } } |
| 80 | 99 |
| 81 #endif // V8_LEXER_LEXER_H | 100 #endif // V8_LEXER_LEXER_H |
| OLD | NEW |