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

Side by Side Diff: lib/compiler/implementation/scanner/scanner.dart

Issue 10519011: Properly parse []. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
« no previous file with comments | « lib/compiler/implementation/scanner/array_based_scanner.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 interface Scanner { 5 interface Scanner {
6 Token tokenize(); 6 Token tokenize();
7 } 7 }
8 8
9 /** 9 /**
10 * Common base class for a Dart scanner. 10 * Common base class for a Dart scanner.
11 */ 11 */
12 class AbstractScanner<T extends SourceString> implements Scanner { 12 class AbstractScanner<T extends SourceString> implements Scanner {
13 abstract int advance(); 13 abstract int advance();
14 abstract int nextByte(); 14 abstract int nextByte();
15 abstract int peek(); 15 abstract int peek();
16 abstract int select(int choice, PrecedenceInfo yes, PrecedenceInfo no); 16 abstract int select(int choice, PrecedenceInfo yes, PrecedenceInfo no);
17 abstract void appendPrecedenceToken(PrecedenceInfo info); 17 abstract void appendPrecedenceToken(PrecedenceInfo info);
18 abstract void appendStringToken(PrecedenceInfo info, String value); 18 abstract void appendStringToken(PrecedenceInfo info, String value);
19 abstract void appendByteStringToken(PrecedenceInfo info, T value); 19 abstract void appendByteStringToken(PrecedenceInfo info, T value);
20 abstract void appendKeywordToken(Keyword keyword); 20 abstract void appendKeywordToken(Keyword keyword);
21 abstract void appendWhiteSpace(int next); 21 abstract void appendWhiteSpace(int next);
22 abstract void appendEofToken(); 22 abstract void appendEofToken();
23 abstract T asciiString(int start, int offset); 23 abstract T asciiString(int start, int offset);
24 abstract T utf8String(int start, int offset); 24 abstract T utf8String(int start, int offset);
25 abstract Token firstToken(); 25 abstract Token firstToken();
26 abstract Token previousToken();
26 abstract void beginToken(); 27 abstract void beginToken();
27 abstract void addToCharOffset(int offset); 28 abstract void addToCharOffset(int offset);
28 abstract int get charOffset(); 29 abstract int get charOffset();
29 abstract int get byteOffset(); 30 abstract int get byteOffset();
30 abstract void appendBeginGroup(PrecedenceInfo info, String value); 31 abstract void appendBeginGroup(PrecedenceInfo info, String value);
31 abstract int appendEndGroup(PrecedenceInfo info, String value, int openKind); 32 abstract int appendEndGroup(PrecedenceInfo info, String value, int openKind);
32 abstract void appendGt(PrecedenceInfo info, String value); 33 abstract void appendGt(PrecedenceInfo info, String value);
33 abstract void appendGtGt(PrecedenceInfo info, String value); 34 abstract void appendGtGt(PrecedenceInfo info, String value);
34 abstract void appendGtGtGt(PrecedenceInfo info, String value); 35 abstract void appendGtGtGt(PrecedenceInfo info, String value);
35 abstract void discardOpenLt(); 36 abstract void discardOpenLt();
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } else { 237 } else {
237 appendPrecedenceToken(TILDE_INFO); 238 appendPrecedenceToken(TILDE_INFO);
238 return next; 239 return next;
239 } 240 }
240 } 241 }
241 242
242 int tokenizeOpenSquareBracket(int next) { 243 int tokenizeOpenSquareBracket(int next) {
243 // [ [] []= 244 // [ [] []=
244 next = advance(); 245 next = advance();
245 if (next === $CLOSE_SQUARE_BRACKET) { 246 if (next === $CLOSE_SQUARE_BRACKET) {
246 return select($EQ, INDEX_EQ_INFO, INDEX_INFO); 247 Token token = previousToken();
247 } else { 248 if (token is KeywordToken && token.value == Keyword.OPERATOR) {
248 appendBeginGroup(OPEN_SQUARE_BRACKET_INFO, "["); 249 return select($EQ, INDEX_EQ_INFO, INDEX_INFO);
249 return next; 250 }
250 } 251 }
252 appendBeginGroup(OPEN_SQUARE_BRACKET_INFO, "[");
253 return next;
251 } 254 }
252 255
253 int tokenizeCaret(int next) { 256 int tokenizeCaret(int next) {
254 // ^ ^= 257 // ^ ^=
255 return select($EQ, CARET_EQ_INFO, CARET_INFO); 258 return select($EQ, CARET_EQ_INFO, CARET_INFO);
256 } 259 }
257 260
258 int tokenizeBar(int next) { 261 int tokenizeBar(int next) {
259 // | || |= 262 // | || |=
260 next = advance(); 263 next = advance();
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 charOffset); 761 charOffset);
759 } 762 }
760 } 763 }
761 764
762 class MalformedInputException { 765 class MalformedInputException {
763 final String message; 766 final String message;
764 final position; 767 final position;
765 MalformedInputException(this.message, this.position); 768 MalformedInputException(this.message, this.position);
766 toString() => message; 769 toString() => message;
767 } 770 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/array_based_scanner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698