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

Unified Diff: runtime/vm/scanner.h

Issue 1969563002: Eliminate GrowableTokenStream (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 | « runtime/vm/object_test.cc ('k') | runtime/vm/scanner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scanner.h
diff --git a/runtime/vm/scanner.h b/runtime/vm/scanner.h
index 23b723cd068afacb3a8cf5ebdbcaf105a33f0a30..f6a0545ff28bd2d26730de57d0c3956a03114060 100644
--- a/runtime/vm/scanner.h
+++ b/runtime/vm/scanner.h
@@ -22,7 +22,7 @@ class ScanContext;
class String;
// A call to Scan() scans the source one token at at time.
-// The scanned token is returned by cur_token().
+// The scanned token is returned by current_token().
// GetStream() scans the entire source text and returns a stream of tokens.
class Scanner : ValueObject {
public:
@@ -44,7 +44,14 @@ class Scanner : ValueObject {
const String* literal; // Identifier, number or string literal.
};
- typedef ZoneGrowableArray<TokenDescriptor> GrowableTokenStream;
+ class TokenCollector : public ValueObject {
+ public:
+ TokenCollector() { }
+ virtual ~TokenCollector() { }
+ virtual void AddToken(const TokenDescriptor& token);
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TokenCollector);
+ };
// Initializes scanner to scan string source.
Scanner(const String& source, const String& private_key);
@@ -53,14 +60,13 @@ class Scanner : ValueObject {
// Scans one token at a time.
void Scan();
+ // Scans the entire source and collects tokens in the provided collector.
+ void ScanAll(TokenCollector* collector);
+
// Scans to specified token position.
// Use CurrentPosition() to extract line and column number.
void ScanTo(intptr_t token_index);
- // Scans entire source and returns a stream of tokens.
- // Should be called only once.
- const GrowableTokenStream& GetStream();
-
// Info about most recently recognized token.
const TokenDescriptor& current_token() const { return current_token_; }
@@ -77,10 +83,8 @@ class Scanner : ValueObject {
// Return true if str is an identifier.
bool IsIdent(const String& str);
- // Does the token stream contain a valid literal. This is used to implement
- // the Dart methods int.parse and double.parse.
- static bool IsValidLiteral(const Scanner::GrowableTokenStream& tokens,
- Token::Kind literal_kind,
+ // Does the token stream contain a valid integer literal.
+ static bool IsValidInteger(const String& str,
bool* is_positive,
const String** value);
@@ -115,9 +119,6 @@ class Scanner : ValueObject {
void ErrorMsg(const char* msg);
- // Scans entire source into a given stream of tokens.
- void ScanAll(GrowableTokenStream* token_stream);
-
// These functions return true if the given character is a letter,
// a decimal digit, a hexadecimal digit, etc.
static bool IsLetter(int32_t c);
@@ -182,8 +183,6 @@ class Scanner : ValueObject {
Thread* thread() const { return thread_; }
Zone* zone() const { return zone_; }
- static void PrintTokens(const GrowableTokenStream& ts);
-
TokenDescriptor current_token_; // Current token.
TokenDescriptor newline_token_; // Newline token.
TokenDescriptor empty_string_token_; // Token for "".
« no previous file with comments | « runtime/vm/object_test.cc ('k') | runtime/vm/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698