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

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartScanner.java

Issue 10979081: Report escaped newlines in string literals (issue 5296) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « no previous file | compiler/java/com/google/dart/compiler/parser/ParserErrorCode.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/parser/DartScanner.java
===================================================================
--- compiler/java/com/google/dart/compiler/parser/DartScanner.java (revision 13022)
+++ compiler/java/com/google/dart/compiler/parser/DartScanner.java (working copy)
@@ -4,8 +4,10 @@
package com.google.dart.compiler.parser;
+import com.google.dart.compiler.DartCompilationError;
import com.google.dart.compiler.DartCompilerListener;
import com.google.dart.compiler.Source;
+import com.google.dart.compiler.common.SourceInfo;
import com.google.dart.compiler.metrics.DartEventType;
import com.google.dart.compiler.metrics.Tracer;
import com.google.dart.compiler.metrics.Tracer.TraceEvent;
@@ -878,11 +880,7 @@
advance();
switch (c) {
case '\n':
- if (!multiLine) {
- // TODO(zundel): better way to report error?
- internalState.resetModes();
- return Token.ILLEGAL;
- }
+ reportError(position() - 1, ParserErrorCode.ESCAPED_NEWLINE);
c = '\n';
break;
case 'b':
@@ -1215,13 +1213,8 @@
// Raw strings.
advance();
if (is('\'') || is('"')) {
-// int offset = position() - 1;
Token token = scanString(true);
-// if (listener != null) {
-// listener.onError(new DartCompilationError(
-// new SourceInfo(sourceReference, offset, position() - offset),
-// ParserErrorCode.DEPRECATED_RAW_STRING));
-// }
+// reportError(position() - 1, ParserErrorCode.DEPRECATED_RAW_STRING);
return token;
} else {
return Token.AT;
@@ -1255,6 +1248,14 @@
}
}
+ private void reportError(int offset, ParserErrorCode errorCode) {
+ if (listener != null) {
+ listener.onError(new DartCompilationError(
+ new SourceInfo(sourceReference, offset, position() - offset),
+ errorCode));
+ }
+ }
+
/**
* Scan for #library, #import, #source, and #resource directives
*/
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/parser/ParserErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698