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

Unified Diff: src/lexer/experimental-scanner.h

Issue 88823004: ExperimentalScanner += SeekForward. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lexer/experimental-scanner.h
diff --git a/src/lexer/experimental-scanner.h b/src/lexer/experimental-scanner.h
index 4e2f153fdaff9aa78b62e4781ba02963a6d1bf52..39c3304cae7fe86c699c69d5c614e2dbb89659db 100644
--- a/src/lexer/experimental-scanner.h
+++ b/src/lexer/experimental-scanner.h
@@ -181,7 +181,12 @@ class ScannerBase {
}
void clear_octal_position() { } // FIXME
- void SeekForward(int pos) { } // FIXME
+ // Seek forward to the given position. This operation works for simple cases
+ // such as seeking forward until simple delimiter tokens, which is what it is
+ // used for. After this call, we will have the token at the given position as
+ // the "next" token. The "current" token will be invalid. FIXME: for utf-8,
+ // we need to decide if pos is counted in characters or in bytes.
+ virtual void SeekForward(int pos) = 0;
// Scans the input as a regular expression pattern, previous
// character(s) must be /(=). Returns true if a pattern is scanned.
@@ -240,6 +245,7 @@ class ExperimentalScanner : public ScannerBase {
virtual ~ExperimentalScanner() { }
virtual void Scan();
+ virtual void SeekForward(int pos);
virtual bool ScanRegExpPattern(bool seen_equal);
virtual bool ScanRegExpFlags();
@@ -284,6 +290,15 @@ class ExperimentalScanner : public ScannerBase {
template<typename Char>
+void ExperimentalScanner<Char>::SeekForward(int pos) {
+ cursor_ = buffer_ + pos;
+ start_ = cursor_;
+ marker_ = cursor_;
+ Scan(); // Fills in next_.
+}
+
+
+template<typename Char>
bool ExperimentalScanner<Char>::ScanRegExpPattern(bool seen_equal) {
// Scan: ('/' | '/=') RegularExpressionBody '/' RegularExpressionFlags
bool in_character_class = false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698