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

Side by Side Diff: frog/leg/scanner/parser.dart

Issue 9284022: Operators. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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. 7 * all tokens in a linked list.
8 */ 8 */
9 class Parser { 9 class Parser {
10 final Listener listener; 10 final Listener listener;
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 if (isGetOrSet(token.next) && isIdentifier(token.next.next)) { 555 if (isGetOrSet(token.next) && isIdentifier(token.next.next)) {
556 // For example: get get identifier 556 // For example: get get identifier
557 getOrSet = token.next; 557 getOrSet = token.next;
558 token = token.next.next; 558 token = token.next.next;
559 } else { 559 } else {
560 // For example: get identifier 560 // For example: get identifier
561 getOrSet = token; 561 getOrSet = token;
562 token = token.next; 562 token = token.next;
563 } 563 }
564 } 564 }
565 } else { 565 } else if (token.stringValue !== 'operator') {
566 peek = peekAfterType(token); 566 peek = peekAfterType(token);
567 if (isGetOrSet(peek) && isIdentifier(peek.next)) { 567 if (isGetOrSet(peek) && isIdentifier(peek.next)) {
568 // type? get identifier 568 // type? get identifier
569 getOrSet = token; 569 getOrSet = token;
570 token = peek.next; 570 token = peek.next;
571 } else if (isIdentifier(peek)) { 571 } else if (isIdentifier(peek)) {
Lasse Reichstein Nielsen 2012/01/27 09:42:34 You could move the test for 'operator' to after th
ngeoffray 2012/01/27 10:50:04 Code has changed since after Peter's recent change
572 token = peek; 572 token = peek;
573 peek = peekAfterType(token); 573 peek = peekAfterType(token);
574 } 574 }
575 } 575 }
576 if (optional('operator', token)) { 576 if (optional('operator', token)) {
577 token = parseOperatorName(token); 577 token = parseOperatorName(token);
578 } else { 578 } else {
579 token = parseIdentifier(token); 579 token = parseIdentifier(token);
580 } 580 }
581 bool isField; 581 bool isField;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 (value === '&') || 674 (value === '&') ||
675 (value === '^') || 675 (value === '^') ||
676 (value === '|'); 676 (value === '|');
677 } 677 }
678 678
679 Token parseFunction(Token token) { 679 Token parseFunction(Token token) {
680 listener.beginFunction(token); 680 listener.beginFunction(token);
681 token = parseModifiers(token); 681 token = parseModifiers(token);
682 token = parseReturnTypeOpt(token); 682 token = parseReturnTypeOpt(token);
683 listener.beginFunctionName(token); 683 listener.beginFunctionName(token);
684 token = parseIdentifier(token); 684 if (optional('operator', token)) {
685 token = parseOperatorName(token);
686 } else {
687 token = parseIdentifier(token);
688 }
685 token = parseQualifiedRestOpt(token); 689 token = parseQualifiedRestOpt(token);
686 listener.endFunctionName(token); 690 listener.endFunctionName(token);
687 token = parseFormalParameters(token); 691 token = parseFormalParameters(token);
688 token = parseInitializersOpt(token); 692 token = parseInitializersOpt(token);
689 token = parseFunctionBody(token, false); 693 token = parseFunctionBody(token, false);
690 listener.endFunction(token); 694 listener.endFunction(token);
691 return token.next; 695 return token.next;
692 } 696 }
693 697
694 Token parseUnamedFunction(Token token) { 698 Token parseUnamedFunction(Token token) {
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 } 1592 }
1589 listener.handleContinueStatement(hasTarget, continueKeyword, token); 1593 listener.handleContinueStatement(hasTarget, continueKeyword, token);
1590 return expectSemicolon(token); 1594 return expectSemicolon(token);
1591 } 1595 }
1592 1596
1593 Token parseEmptyStatement(Token token) { 1597 Token parseEmptyStatement(Token token) {
1594 listener.handleEmptyStatement(token); 1598 listener.handleEmptyStatement(token);
1595 return expectSemicolon(token); 1599 return expectSemicolon(token);
1596 } 1600 }
1597 } 1601 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698