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

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

Issue 10540073: Properly parse > in end of types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Better tests 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 | « frog/tests/leg/unparser_test.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 /** 5 /**
6 * An event generating parser of Dart programs. This parser expects 6 * An event generating parser of Dart programs. This parser expects
7 * all tokens in a linked list (aka a token stream). 7 * all tokens in a linked list (aka a token stream).
8 * 8 *
9 * The class [Scanner] is used to generate a token stream. See the 9 * The class [Scanner] is used to generate a token stream. See the
10 * file scanner.dart. 10 * file scanner.dart.
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (isIdentifier(token)) { 254 if (isIdentifier(token)) {
255 listener.handleIdentifier(token); 255 listener.handleIdentifier(token);
256 } else { 256 } else {
257 listener.expectedIdentifier(token); 257 listener.expectedIdentifier(token);
258 } 258 }
259 return token.next; 259 return token.next;
260 } 260 }
261 261
262 Token expect(String string, Token token) { 262 Token expect(String string, Token token) {
263 if (string !== token.stringValue) { 263 if (string !== token.stringValue) {
264 if (string === '>') {
265 if (token.stringValue === '>>') {
266 Token gt = new Token(GT_INFO, token.charOffset + 1);
267 gt.next = token.next;
268 return gt;
269 } else if (token.stringValue === '>>>') {
270 Token gtgt = new Token(GT_GT_INFO, token.charOffset + 1);
271 gtgt.next = token.next;
272 return gtgt;
273 }
274 }
275 return listener.expected(string, token); 264 return listener.expected(string, token);
276 } 265 }
277 return token.next; 266 return token.next;
278 } 267 }
279 268
280 Token parseTypeVariable(Token token) { 269 Token parseTypeVariable(Token token) {
281 listener.beginTypeVariable(token); 270 listener.beginTypeVariable(token);
282 token = parseIdentifier(token); 271 token = parseIdentifier(token);
283 if (optional('extends', token)) { 272 if (optional('extends', token)) {
284 token = parseType(token.next); 273 token = parseType(token.next);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 Token parseStuff(Token token, Function beginStuff, Function stuffParser, 317 Token parseStuff(Token token, Function beginStuff, Function stuffParser,
329 Function endStuff, Function handleNoStuff) { 318 Function endStuff, Function handleNoStuff) {
330 if (optional('<', token)) { 319 if (optional('<', token)) {
331 Token begin = token; 320 Token begin = token;
332 beginStuff(begin); 321 beginStuff(begin);
333 int count = 0; 322 int count = 0;
334 do { 323 do {
335 token = stuffParser(token.next); 324 token = stuffParser(token.next);
336 ++count; 325 ++count;
337 } while (optional(',', token)); 326 } while (optional(',', token));
327 Token next = token.next;
328 if (token.stringValue === '>>') {
329 token = new Token(GT_INFO, token.charOffset);
330 token.next = new Token(GT_INFO, token.charOffset + 1);
331 token.next.next = next;
332 } else if (token.stringValue === '>>>') {
333 token = new Token(GT_INFO, token.charOffset);
334 token.next = new Token(GT_GT_INFO, token.charOffset + 1);
335 token.next.next = next;
336 }
338 endStuff(count, begin, token); 337 endStuff(count, begin, token);
339 return expect('>', token); 338 return expect('>', token);
340 } 339 }
341 handleNoStuff(token); 340 handleNoStuff(token);
342 return token; 341 return token;
343 } 342 }
344 343
345 Token parseTopLevelMember(Token token) { 344 Token parseTopLevelMember(Token token) {
346 Token start = token; 345 Token start = token;
347 listener.beginTopLevelMember(token); 346 listener.beginTopLevelMember(token);
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 } 1670 }
1672 listener.handleContinueStatement(hasTarget, continueKeyword, token); 1671 listener.handleContinueStatement(hasTarget, continueKeyword, token);
1673 return expectSemicolon(token); 1672 return expectSemicolon(token);
1674 } 1673 }
1675 1674
1676 Token parseEmptyStatement(Token token) { 1675 Token parseEmptyStatement(Token token) {
1677 listener.handleEmptyStatement(token); 1676 listener.handleEmptyStatement(token);
1678 return expectSemicolon(token); 1677 return expectSemicolon(token);
1679 } 1678 }
1680 } 1679 }
OLDNEW
« no previous file with comments | « frog/tests/leg/unparser_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698