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

Unified Diff: runtime/vm/scanner.cc

Issue 23452043: Introduce newline tokens into the token stream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase (fingerprints) Created 7 years, 3 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/scanner.h ('k') | runtime/vm/scanner_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scanner.cc
diff --git a/runtime/vm/scanner.cc b/runtime/vm/scanner.cc
index d483da0e2336ed6ff3e05eecd4e33e13aa51063e..ecbe7097ed98badfa60553510c54b0d50a914cb6 100644
--- a/runtime/vm/scanner.cc
+++ b/runtime/vm/scanner.cc
@@ -42,10 +42,18 @@ void Scanner::InitKeywordTable() {
void Scanner::Reset() {
+ // Non-chaning newline properties.
+ newline_token_.kind = Token::kNEWLINE;
+ newline_token_.literal = NULL;
+ newline_token_.length = 1;
+ // We don't preserve the column information.
+ newline_token_.position.column = 0;
+
lookahead_pos_ = -1;
token_start_ = 0;
c0_ = '\0';
newline_seen_ = false;
+ prev_token_line_ = 1;
while (saved_context_ != NULL) {
ScanContext* ctx = saved_context_;
saved_context_ = ctx->next;
@@ -863,7 +871,16 @@ void Scanner::ScanAll(GrowableTokenStream* token_stream) {
Reset();
do {
Scan();
+
+ for (intptr_t diff = current_token_.position.line - prev_token_line_;
+ diff > 0;
+ diff--) {
+ newline_token_.position.line = current_token_.position.line - diff;
+ token_stream->Add(newline_token_);
+ }
+
token_stream->Add(current_token_);
+ prev_token_line_ = current_token_.position.line;
} while (current_token_.kind != Token::kEOS);
}
« no previous file with comments | « runtime/vm/scanner.h ('k') | runtime/vm/scanner_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698