| 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 #include <vector> | |
| 34 | |
| 35 #include "token.h" | 33 #include "token.h" |
| 36 #include "flags.h" | 34 #include "flags.h" |
| 37 | 35 |
| 36 namespace v8 { |
| 37 namespace internal { |
| 38 |
| 38 class ExperimentalScanner; | 39 class ExperimentalScanner; |
| 39 | 40 |
| 40 class PushScanner { | 41 class PushScanner { |
| 41 public: | 42 public: |
| 42 explicit PushScanner(ExperimentalScanner* sink); | 43 explicit PushScanner(ExperimentalScanner* sink); |
| 43 | 44 |
| 44 ~PushScanner(); | 45 ~PushScanner(); |
| 45 | 46 |
| 46 void send(v8::internal::Token::Value token); | 47 void send(v8::internal::Token::Value token); |
| 47 uint32_t push(const void *input, int input_size); | 48 uint32_t push(const void *input, int input_size); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 59 | 60 |
| 60 uint8_t* buffer_; | 61 uint8_t* buffer_; |
| 61 uint8_t* buffer_end_; | 62 uint8_t* buffer_end_; |
| 62 | 63 |
| 63 uint8_t yych; | 64 uint8_t yych; |
| 64 uint32_t yyaccept; | 65 uint32_t yyaccept; |
| 65 | 66 |
| 66 ExperimentalScanner* sink_; | 67 ExperimentalScanner* sink_; |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 class ExperimentalScanner { | 70 } } |
| 70 public: | |
| 71 ExperimentalScanner(const char* fname, bool read_all_at_once); | |
| 72 ~ExperimentalScanner(); | |
| 73 v8::internal::Token::Value Next(int* beg_pos, int* end_pos); | |
| 74 void Record(v8::internal::Token::Value token, int beg_pos, int end_pos); | |
| 75 | |
| 76 private: | |
| 77 void FillTokens(); | |
| 78 static const int BUFFER_SIZE = 256; | |
| 79 std::vector<v8::internal::Token::Value> token_; | |
| 80 std::vector<int> beg_; | |
| 81 std::vector<int> end_; | |
| 82 size_t current_; | |
| 83 size_t fetched_; | |
| 84 FILE* file_; | |
| 85 PushScanner* scanner_; | |
| 86 bool read_all_at_once_; | |
| 87 const v8::internal::byte* source_; | |
| 88 int length_; | |
| 89 }; | |
| 90 | 71 |
| 91 #endif // V8_LEXER_LEXER_H | 72 #endif // V8_LEXER_LEXER_H |
| OLD | NEW |