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

Unified Diff: dart/frog/leg/scanner/scanner.dart

Issue 9288070: Don't allow escaping newlines in single line strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 8 years, 11 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 | dart/frog/leg/scanner/source_list.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/scanner/scanner.dart
diff --git a/dart/frog/leg/scanner/scanner.dart b/dart/frog/leg/scanner/scanner.dart
index 35e0b1e83f4b2a7ff34cf995de4eaaee49f4dca5..6eafd064132bf1df8bc16802f868875a3f93216a 100644
--- a/dart/frog/leg/scanner/scanner.dart
+++ b/dart/frog/leg/scanner/scanner.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -636,34 +636,32 @@ class AbstractScanner<T> implements Scanner {
}
int tokenizeSingleLineString(int next, int q1, int start) {
- while (next !== $EOF) {
- if (next === q1) {
- appendByteStringToken(STRING_INFO, utf8String(start, 0));
- return advance();
- } else if (next === $BACKSLASH) {
+ while (next !== q1) {
+ if (next === $BACKSLASH) {
next = advance();
- if (next === $EOF) {
- throw new MalformedInputException("unterminated string literal",
- charOffset);
- }
} else if (next === $$) {
- beginToken();
- next = advance();
- if (next === $OPEN_CURLY_BRACKET) {
- next = tokenizeInterpolatedExpression(next, start);
- } else {
- next = tokenizeInterpolatedIdentifier(next, start);
- }
+ next = tokenizeStringInterpolation(start);
start = byteOffset;
continue;
- } else if (next === $LF || next === $CR) {
+ }
+ if (next <= $CR && (next === $LF || next === $CR || next === $EOF)) {
throw new MalformedInputException("unterminated string literal",
charOffset);
}
next = advance();
}
- throw new MalformedInputException("unterminated string literal",
- charOffset);
+ appendByteStringToken(STRING_INFO, utf8String(start, 0));
+ return advance();
+ }
+
+ int tokenizeStringInterpolation(int start) {
+ beginToken();
+ int next = advance();
+ if (next === $OPEN_CURLY_BRACKET) {
+ return tokenizeInterpolatedExpression(next, start);
+ } else {
+ return tokenizeInterpolatedIdentifier(next, start);
+ }
}
int tokenizeInterpolatedExpression(int next, int start) {
« no previous file with comments | « no previous file | dart/frog/leg/scanner/source_list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698