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

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

Issue 27705002: Experimental parser: Refactoring and timing. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Code review (ulan) Created 7 years, 2 months 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 | src/lexer/lexer.re » ('j') | 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:
2 // (re2c/examples/push.re)
1 // Copyright 2013 the V8 project authors. All rights reserved. 3 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
4 // met: 6 // met:
5 // 7 //
6 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 11 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 12 // disclaimer in the documentation and/or other materials provided
(...skipping 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (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
26 // 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.
27 29
28 #ifndef V8_LEXER_LEXER_H 30 #ifndef V8_LEXER_LEXER_H
29 #define V8_LEXER_LEXER_H 31 #define V8_LEXER_LEXER_H
30 32
33 #include <vector>
34
31 #include "token.h" 35 #include "token.h"
32 #include "flags.h" 36 #include "flags.h"
33 37
34 class PushScanner; 38 class ExperimentalScanner;
39
40 class PushScanner {
41 public:
42 explicit PushScanner(ExperimentalScanner* sink);
43
44 ~PushScanner();
45
46 void send(v8::internal::Token::Value token);
47 uint32_t push(const void *input, int input_size);
48
49 private:
50 bool eof_;
51 int32_t state_;
52 int32_t condition_;
53
54 uint8_t* limit_;
55 uint8_t* start_;
56 uint8_t* cursor_;
57 uint8_t* marker_;
58 int real_start_;
59
60 uint8_t* buffer_;
61 uint8_t* buffer_end_;
62
63 uint8_t yych;
64 uint32_t yyaccept;
65
66 ExperimentalScanner* sink_;
67 };
35 68
36 class ExperimentalScanner { 69 class ExperimentalScanner {
37 public: 70 public:
38 explicit ExperimentalScanner(const char* fname); 71 ExperimentalScanner(const char* fname, bool read_all_at_once);
39 ~ExperimentalScanner(); 72 ~ExperimentalScanner();
40 v8::internal::Token::Value Next(int* beg_pos, int* end_pos); 73 v8::internal::Token::Value Next(int* beg_pos, int* end_pos);
41 void Record(v8::internal::Token::Value token, int beg_pos, int end_pos); 74 void Record(v8::internal::Token::Value token, int beg_pos, int end_pos);
75
42 private: 76 private:
43 void FillTokens(); 77 void FillTokens();
44 static const int BUFFER_SIZE = 256; 78 static const int BUFFER_SIZE = 256;
45 v8::internal::Token::Value token_[BUFFER_SIZE]; 79 std::vector<v8::internal::Token::Value> token_;
46 int beg_[BUFFER_SIZE]; 80 std::vector<int> beg_;
47 int end_[BUFFER_SIZE]; 81 std::vector<int> end_;
48 int current_; 82 size_t current_;
49 int fetched_; 83 size_t fetched_;
50 FILE* file_; 84 FILE* file_;
51 PushScanner* scanner_; 85 PushScanner* scanner_;
86 bool read_all_at_once_;
87 const v8::internal::byte* source_;
88 int length_;
52 }; 89 };
53 90
54 #endif // V8_LEXER_LEXER_H 91 #endif // V8_LEXER_LEXER_H
OLDNEW
« no previous file with comments | « no previous file | src/lexer/lexer.re » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698