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

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

Issue 28763003: Experimental parser: Starting to unify the ExperimentalScanner iface with Scanner iface. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/lexer/experimental-scanner.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/lexer.h b/src/lexer/experimental-scanner.h
similarity index 75%
copy from src/lexer/lexer.h
copy to src/lexer/experimental-scanner.h
index d4bc071dd39c42c3e7690b5f5a4b9ac2ab099eb9..13484b5387f51b8105f7dd4eeff21f7a978d223a 100644
--- a/src/lexer/lexer.h
+++ b/src/lexer/experimental-scanner.h
@@ -1,5 +1,3 @@
-// Portions of this code based on re2c:
-// (re2c/examples/push.re)
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -27,50 +25,42 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef V8_LEXER_LEXER_H
-#define V8_LEXER_LEXER_H
+#ifndef V8_LEXER_EXPERIMENTAL_SCANNER_H
+#define V8_LEXER_EXPERIMENTAL_SCANNER_H
#include <vector>
-#include "token.h"
#include "flags.h"
+#include "token.h"
-class ExperimentalScanner;
-
-class PushScanner {
- public:
- explicit PushScanner(ExperimentalScanner* sink);
-
- ~PushScanner();
-
- void send(v8::internal::Token::Value token);
- uint32_t push(const void *input, int input_size);
+namespace v8 {
+namespace internal {
- private:
- bool eof_;
- int32_t state_;
- int32_t condition_;
+class PushScanner;
- uint8_t* limit_;
- uint8_t* start_;
- uint8_t* cursor_;
- uint8_t* marker_;
- int real_start_;
+class ExperimentalScanner {
+ public:
+ struct Location {
+ Location(int b, int e) : beg_pos(b), end_pos(e) { }
+ Location() : beg_pos(0), end_pos(0) { }
- uint8_t* buffer_;
- uint8_t* buffer_end_;
+ bool IsValid() const {
+ return beg_pos >= 0 && end_pos >= beg_pos;
+ }
- uint8_t yych;
- uint32_t yyaccept;
+ static Location invalid() { return Location(-1, -1); }
- ExperimentalScanner* sink_;
-};
+ int beg_pos;
+ int end_pos;
+ };
-class ExperimentalScanner {
- public:
ExperimentalScanner(const char* fname, bool read_all_at_once);
~ExperimentalScanner();
- v8::internal::Token::Value Next(int* beg_pos, int* end_pos);
+
+ Token::Value Next();
+ Token::Value current_token();
+ Location location();
+
void Record(v8::internal::Token::Value token, int beg_pos, int end_pos);
private:
@@ -88,4 +78,6 @@ class ExperimentalScanner {
int length_;
};
-#endif // V8_LEXER_LEXER_H
+} } // namespace v8::internal
+
+#endif
« no previous file with comments | « no previous file | src/lexer/experimental-scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698