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

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

Issue 83633002: Experimental parser: continue unifying the API with Scanner. (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 | src/lexer/lexer-shell.cc » ('j') | 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 2f70e1c39679268afaec018fdbded0da57c2d188..b9ce4826e4d54c123e570630ea9b51fa93e3ac75 100644
--- a/src/lexer/experimental-scanner.h
+++ b/src/lexer/experimental-scanner.h
@@ -63,6 +63,20 @@ class UnicodeCache;
template<typename YYCTYPE>
class ExperimentalScanner {
public:
+ struct Location {
+ Location(int b, int e) : beg_pos(b), end_pos(e) { }
+ Location() : beg_pos(0), end_pos(0) { }
+
+ bool IsValid() const {
+ return beg_pos >= 0 && end_pos >= beg_pos;
+ }
+
+ static Location invalid() { return Location(-1, -1); }
+
+ int beg_pos;
+ int end_pos;
+ };
+
explicit ExperimentalScanner(
YYCTYPE* source,
YYCTYPE* source_end,
@@ -70,7 +84,15 @@ class ExperimentalScanner {
~ExperimentalScanner();
- Token::Value Next(int* beg_pos, int* end_pos);
+ Token::Value Next() {
+ current_ = next_;
+ Scan(); // will fill in next_.
+ return current_.token;
+ }
+
+ Location location() {
+ return Location(current_.beg_pos, current_.end_pos);
+ }
void SetHarmonyNumericLiterals(bool numeric_literals) {
harmony_numeric_literals_ = numeric_literals;
@@ -85,6 +107,15 @@ class ExperimentalScanner {
}
private:
+ struct TokenDesc {
+ Token::Value token;
+ int beg_pos;
+ int end_pos;
+ LiteralBuffer* literal_chars;
+ };
+
+ void Scan();
+
bool ValidIdentifierStart();
bool ValidIdentifierPart();
uc32 ScanHexNumber(int length);
@@ -100,6 +131,9 @@ class ExperimentalScanner {
YYCTYPE yych;
+ TokenDesc current_; // desc for current token (as returned by Next())
+ TokenDesc next_; // desc for next token (one token look-ahead)
+
bool harmony_numeric_literals_;
bool harmony_modules_;
bool harmony_scoping_;
@@ -122,6 +156,7 @@ ExperimentalScanner<YYCTYPE>::ExperimentalScanner(
start_ = buffer_;
cursor_ = buffer_;
marker_ = buffer_;
+ Scan();
}
« 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