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

Side by Side Diff: src/scanner-base.h

Issue 5188006: Push version 2.5.7 to trunk.... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 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 | « src/scanner.cc ('k') | src/scanner-base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Features shared by parsing and pre-parsing scanners. 28 // Features shared by parsing and pre-parsing scanners.
29 29
30 #ifndef V8_SCANNER_BASE_H_ 30 #ifndef V8_SCANNER_BASE_H_
31 #define V8_SCANNER_BASE_H_ 31 #define V8_SCANNER_BASE_H_
32 32
33 #include "globals.h"
34 #include "checks.h"
35 #include "allocation.h"
33 #include "token.h" 36 #include "token.h"
34 #include "unicode.h" 37 #include "unicode-inl.h"
38 #include "char-predicates.h"
39 #include "utils.h"
35 40
36 namespace v8 { 41 namespace v8 {
37 namespace internal { 42 namespace internal {
38 43
44 // Interface through which the scanner reads characters from the input source.
45 class UTF16Buffer {
46 public:
47 UTF16Buffer();
48 virtual ~UTF16Buffer() {}
49
50 virtual void PushBack(uc32 ch) = 0;
51 // Returns a value < 0 when the buffer end is reached.
52 virtual uc32 Advance() = 0;
53 virtual void SeekForward(int pos) = 0;
54
55 int pos() const { return pos_; }
56
57 protected:
58 int pos_; // Current position in the buffer.
59 int end_; // Position where scanning should stop (EOF).
60 };
61
62
63 class ScannerConstants : AllStatic {
64 public:
65 typedef unibrow::Utf8InputBuffer<1024> Utf8Decoder;
66
67 static StaticResource<Utf8Decoder>* utf8_decoder() {
68 return &utf8_decoder_;
69 }
70
71 static unibrow::Predicate<IdentifierStart, 128> kIsIdentifierStart;
72 static unibrow::Predicate<IdentifierPart, 128> kIsIdentifierPart;
73 static unibrow::Predicate<unibrow::LineTerminator, 128> kIsLineTerminator;
74 static unibrow::Predicate<unibrow::WhiteSpace, 128> kIsWhiteSpace;
75
76 static bool IsIdentifier(unibrow::CharacterStream* buffer);
77
78 private:
79 static StaticResource<Utf8Decoder> utf8_decoder_;
80 };
81
82
39 class KeywordMatcher { 83 class KeywordMatcher {
40 // Incrementally recognize keywords. 84 // Incrementally recognize keywords.
41 // 85 //
42 // Recognized keywords: 86 // Recognized keywords:
43 // break case catch const* continue debugger* default delete do else 87 // break case catch const* continue debugger* default delete do else
44 // finally false for function if in instanceof native* new null 88 // finally false for function if in instanceof native* new null
45 // return switch this throw true try typeof var void while with 89 // return switch this throw true try typeof var void while with
46 // 90 //
47 // *: Actually "future reserved keywords". These are the only ones we 91 // *: Actually "future reserved keywords". These are the only ones we
48 // recognized, the remaining are allowed as identifiers. 92 // recognize, the remaining are allowed as identifiers.
93 // In ES5 strict mode, we should disallow all reserved keywords.
49 public: 94 public:
50 KeywordMatcher() 95 KeywordMatcher()
51 : state_(INITIAL), 96 : state_(INITIAL),
52 token_(Token::IDENTIFIER), 97 token_(Token::IDENTIFIER),
53 keyword_(NULL), 98 keyword_(NULL),
54 counter_(0), 99 counter_(0),
55 keyword_token_(Token::ILLEGAL) {} 100 keyword_token_(Token::ILLEGAL) {}
56 101
57 Token::Value token() { return token_; } 102 Token::Value token() { return token_; }
58 103
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Token::Value token_; 194 Token::Value token_;
150 195
151 // Matching a specific keyword string (there is only one possible valid 196 // Matching a specific keyword string (there is only one possible valid
152 // keyword with the current prefix). 197 // keyword with the current prefix).
153 const char* keyword_; 198 const char* keyword_;
154 int counter_; 199 int counter_;
155 Token::Value keyword_token_; 200 Token::Value keyword_token_;
156 }; 201 };
157 202
158 203
159
160
161
162
163 } } // namespace v8::internal 204 } } // namespace v8::internal
164 205
165 #endif // V8_SCANNER_BASE_H_ 206 #endif // V8_SCANNER_BASE_H_
OLDNEW
« no previous file with comments | « src/scanner.cc ('k') | src/scanner-base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698