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

Side by Side Diff: compiler/java/com/google/dart/compiler/parser/DartScanner.java

Issue 10941052: Preparation for reporting an error for deprecated raw strings (issue 4815) (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 package com.google.dart.compiler.parser; 5 package com.google.dart.compiler.parser;
6 6
7 import com.google.dart.compiler.DartCompilerListener;
8 import com.google.dart.compiler.Source;
7 import com.google.dart.compiler.metrics.DartEventType; 9 import com.google.dart.compiler.metrics.DartEventType;
8 import com.google.dart.compiler.metrics.Tracer; 10 import com.google.dart.compiler.metrics.Tracer;
9 import com.google.dart.compiler.metrics.Tracer.TraceEvent; 11 import com.google.dart.compiler.metrics.Tracer.TraceEvent;
10 import com.google.dart.compiler.parser.DartScanner.InternalState.Mode; 12 import com.google.dart.compiler.parser.DartScanner.InternalState.Mode;
11 13
12 import java.util.ArrayList; 14 import java.util.ArrayList;
13 import java.util.List; 15 import java.util.List;
14 import java.util.Stack; 16 import java.util.Stack;
15 17
16 /** 18 /**
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 382
381 private static boolean isWhiteSpace(int c) { 383 private static boolean isWhiteSpace(int c) {
382 return c == ' ' || c == '\t'; 384 return c == ' ' || c == '\t';
383 } 385 }
384 386
385 private int commentCharCount; 387 private int commentCharCount;
386 private int lastCommentStart; 388 private int lastCommentStart;
387 private int lastCommentStop; 389 private int lastCommentStop;
388 private String source; 390 private String source;
389 private InternalState internalState; 391 private InternalState internalState;
392 private Source sourceReference;
393 private DartCompilerListener listener;
390 394
391 public DartScanner(String source) { 395 public DartScanner(String source) {
392 this(source, 0); 396 this(source, 0, null, null);
393 } 397 }
394 398
395 public DartScanner(String source, int start) { 399 public DartScanner(String source, int start) {
400 this(source, 0, null, null);
401 }
402
403 public DartScanner(String source, int start, Source sourceReference, DartCompi lerListener listener) {
396 final TraceEvent logEvent = Tracer.canTrace() ? Tracer.start(DartEventType.S CANNER) : null; 404 final TraceEvent logEvent = Tracer.canTrace() ? Tracer.start(DartEventType.S CANNER) : null;
397 try { 405 try {
398 this.source = source; 406 this.source = source;
407 this.sourceReference = sourceReference;
408 this.listener = listener;
399 internalState = new InternalState(); 409 internalState = new InternalState();
400 internalState.tokens = new ArrayList<TokenData>(source.length()/2); 410 internalState.tokens = new ArrayList<TokenData>(source.length()/2);
401 411
402 // Initialize lookahead positions. 412 // Initialize lookahead positions.
403 // TODO Determine if line & column should be relative to 0 or 'start' 413 // TODO Determine if line & column should be relative to 0 or 'start'
404 internalState.nextLookaheadPos = start; 414 internalState.nextLookaheadPos = start;
405 for (int i = 0; i < internalState.lookaheadPos.length; ++i) { 415 for (int i = 0; i < internalState.lookaheadPos.length; ++i) {
406 internalState.lookaheadPos[i] = start; 416 internalState.lookaheadPos[i] = start;
407 } 417 }
408 418
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 return select(Token.TRUNC); 1208 return select(Token.TRUNC);
1199 } 1209 }
1200 } else { 1210 } else {
1201 return Token.BIT_NOT; 1211 return Token.BIT_NOT;
1202 } 1212 }
1203 1213
1204 case '@': 1214 case '@':
1205 // Raw strings. 1215 // Raw strings.
1206 advance(); 1216 advance();
1207 if (is('\'') || is('"')) { 1217 if (is('\'') || is('"')) {
1208 boolean isRaw = true; 1218 // int offset = position() - 1;
1209 return scanString(isRaw); 1219 Token token = scanString(true);
1220 // if (listener != null) {
1221 // listener.onError(new DartCompilationError(
1222 // new SourceInfo(sourceReference, offset, position() - offset),
1223 // ParserErrorCode.DEPRECATED_RAW_STRING));
1224 // }
1225 return token;
1210 } else { 1226 } else {
1211 return Token.AT; 1227 return Token.AT;
1212 } 1228 }
1213 1229
1214 case '#': 1230 case '#':
1215 return scanDirective(); 1231 return scanDirective();
1216 1232
1217 case 'r': 1233 case 'r':
1218 if (lookahead(1) == '\'' || lookahead(1) == '"') { 1234 if (lookahead(1) == '\'' || lookahead(1) == '"') {
1219 advance(); 1235 advance();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 while (true) { 1354 while (true) {
1339 int c = lookahead(0); 1355 int c = lookahead(0);
1340 if (isLineTerminator(c)) { 1356 if (isLineTerminator(c)) {
1341 } else if (!isWhiteSpace(c)) { 1357 } else if (!isWhiteSpace(c)) {
1342 break; 1358 break;
1343 } 1359 }
1344 advance(); 1360 advance();
1345 } 1361 }
1346 } 1362 }
1347 } 1363 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698