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

Side by Side Diff: src/lexer/experimental-scanner.h

Issue 98863002: Experimental scanner: fix harmony flag setting. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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-shell.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 virtual ~ScannerBase() { 81 virtual ~ScannerBase() {
82 scanners_->erase(this); 82 scanners_->erase(this);
83 if (scanners_->empty()) { 83 if (scanners_->empty()) {
84 isolate_->heap()->RemoveGCEpilogueCallback( 84 isolate_->heap()->RemoveGCEpilogueCallback(
85 &ScannerBase::UpdateBuffersAfterGC); 85 &ScannerBase::UpdateBuffersAfterGC);
86 delete scanners_; 86 delete scanners_;
87 scanners_ = NULL; 87 scanners_ = NULL;
88 } 88 }
89 } 89 }
90 90
91 // Has to be called after creating the scanner and setting the flags.
92 virtual void Init() = 0;
93
94 // Seek forward to the given position. This operation works for simple cases
95 // such as seeking forward until simple delimiter tokens, which is what it is
96 // used for. After this call, we will have the token at the given position as
97 // the "next" token. The "current" token will be invalid. FIXME: for utf-8,
98 // we need to decide if pos is counted in characters or in bytes.
99 virtual void SeekForward(int pos) = 0;
100 virtual void SetEnd(int pos) = 0;
101
102 // Scans the input as a regular expression pattern, previous character(s) must
103 // be /(=). Returns true if a pattern is scanned. FIXME: this won't work for
104 // utf-8 newlines.
105 virtual bool ScanRegExpPattern(bool seen_equal) = 0;
106 // Returns true if regexp flags are scanned (always since flags can
107 // be empty).
108 virtual bool ScanRegExpFlags() = 0;
109
110 // Returns the location of the last seen octal literal.
111 virtual Location octal_position() const = 0;
112 virtual void clear_octal_position() = 0;
113
91 // Returns the next token and advances input. 114 // Returns the next token and advances input.
92 Token::Value Next() { 115 Token::Value Next() {
93 has_line_terminator_before_next_ = false; 116 has_line_terminator_before_next_ = false;
94 current_ = next_; 117 current_ = next_;
95 std::swap(current_literal_, next_literal_); 118 std::swap(current_literal_, next_literal_);
96 Scan(); // Virtual! Will fill in next_. 119 Scan(); // Virtual! Will fill in next_.
97 return current_.token; 120 return current_.token;
98 } 121 }
99 122
100 // Returns the current token again. 123 // Returns the current token again.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return next_literal_->is_ascii; 233 return next_literal_->is_ascii;
211 } 234 }
212 235
213 bool is_next_contextual_keyword(Vector<const char> keyword) { 236 bool is_next_contextual_keyword(Vector<const char> keyword) {
214 if (!is_next_literal_ascii()) return false; 237 if (!is_next_literal_ascii()) return false;
215 Vector<const char> literal = next_literal_ascii_string(); 238 Vector<const char> literal = next_literal_ascii_string();
216 return literal.length() == keyword.length() && 239 return literal.length() == keyword.length() &&
217 (memcmp(literal.start(), keyword.start(), literal.length()) == 0); 240 (memcmp(literal.start(), keyword.start(), literal.length()) == 0);
218 } 241 }
219 242
220 // Seek forward to the given position. This operation works for simple cases
221 // such as seeking forward until simple delimiter tokens, which is what it is
222 // used for. After this call, we will have the token at the given position as
223 // the "next" token. The "current" token will be invalid. FIXME: for utf-8,
224 // we need to decide if pos is counted in characters or in bytes.
225 virtual void SeekForward(int pos) = 0;
226 virtual void SetEnd(int pos) = 0;
227
228 // Scans the input as a regular expression pattern, previous character(s) must
229 // be /(=). Returns true if a pattern is scanned. FIXME: this won't work for
230 // utf-8 newlines.
231 virtual bool ScanRegExpPattern(bool seen_equal) = 0;
232 // Returns true if regexp flags are scanned (always since flags can
233 // be empty).
234 virtual bool ScanRegExpFlags() = 0;
235
236 // Returns the location of the last seen octal literal.
237 virtual Location octal_position() const = 0;
238 virtual void clear_octal_position() = 0;
239
240 protected: 243 protected:
241 struct TokenDesc { 244 struct TokenDesc {
242 Token::Value token; 245 Token::Value token;
243 int beg_pos; 246 int beg_pos;
244 int end_pos; 247 int end_pos;
245 bool has_escapes; 248 bool has_escapes;
246 }; 249 };
247 250
248 struct LiteralDesc { 251 struct LiteralDesc {
249 int beg_pos; 252 int beg_pos;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 : ScannerBase(isolate), 295 : ScannerBase(isolate),
293 source_handle_(source), 296 source_handle_(source),
294 buffer_(NULL), 297 buffer_(NULL),
295 buffer_end_(NULL), 298 buffer_end_(NULL),
296 start_(NULL), 299 start_(NULL),
297 cursor_(NULL), 300 cursor_(NULL),
298 marker_(NULL), 301 marker_(NULL),
299 last_octal_end_(NULL) { 302 last_octal_end_(NULL) {
300 ASSERT(source->IsFlat()); 303 ASSERT(source->IsFlat());
301 SetBufferBasedOnHandle(); 304 SetBufferBasedOnHandle();
305 }
306
307 virtual void Init() {
302 Scan(); 308 Scan();
303 } 309 }
304 310
305 virtual ~ExperimentalScanner() { } 311 virtual ~ExperimentalScanner() { }
306 312
307 virtual void SeekForward(int pos); 313 virtual void SeekForward(int pos);
308 virtual void SetEnd(int pos); 314 virtual void SetEnd(int pos);
309 virtual bool ScanRegExpPattern(bool seen_equal); 315 virtual bool ScanRegExpPattern(bool seen_equal);
310 virtual bool ScanRegExpFlags(); 316 virtual bool ScanRegExpFlags();
311 virtual Location octal_position() const; 317 virtual Location octal_position() const;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 // character. 610 // character.
605 const Char* temp_cursor = last_octal_end_ - 1; 611 const Char* temp_cursor = last_octal_end_ - 1;
606 while (temp_cursor >= buffer_ && *temp_cursor >= '0' && *temp_cursor <= '7') 612 while (temp_cursor >= buffer_ && *temp_cursor >= '0' && *temp_cursor <= '7')
607 --temp_cursor; 613 --temp_cursor;
608 return Location(temp_cursor - buffer_ + 1, last_octal_end_ - buffer_); 614 return Location(temp_cursor - buffer_ + 1, last_octal_end_ - buffer_);
609 } 615 }
610 616
611 } } 617 } }
612 618
613 #endif // V8_LEXER_EXPERIMENTAL_SCANNER_H 619 #endif // V8_LEXER_EXPERIMENTAL_SCANNER_H
OLDNEW
« no previous file with comments | « no previous file | src/lexer/lexer-shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698