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

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

Issue 9634008: Introduce element categories and move resolver towards being more compositional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years, 9 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 | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/leg/scanner/token.dart » ('j') | 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) 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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 token = parseIdentifier(token.next); 650 token = parseIdentifier(token.next);
651 } 651 }
652 token = parseFormalParameters(token); 652 token = parseFormalParameters(token);
653 token = parseFunctionBody(token, false); 653 token = parseFunctionBody(token, false);
654 listener.endFactoryMethod(factoryKeyword, period, token); 654 listener.endFactoryMethod(factoryKeyword, period, token);
655 return token.next; 655 return token.next;
656 } 656 }
657 657
658 Token parseOperatorName(Token token) { 658 Token parseOperatorName(Token token) {
659 assert(optional('operator', token)); 659 assert(optional('operator', token));
660 if (isUserDefinableOperator(token.next)) { 660 if (isUserDefinableOperator(token.next.stringValue)) {
661 Token operator = token; 661 Token operator = token;
662 token = token.next; 662 token = token.next;
663 listener.handleOperatorName(operator, token); 663 listener.handleOperatorName(operator, token);
664 return token.next; 664 return token.next;
665 } else { 665 } else {
666 return parseIdentifier(token); 666 return parseIdentifier(token);
667 } 667 }
668 } 668 }
669 669
670 bool isUserDefinableOperator(Token token) {
671 String value = token.stringValue;
672 return
673 (value === '==') ||
674 (value === '~') ||
675 (value === 'negate') ||
676 (value === '[]') ||
677 (value === '[]=') ||
678 (value === '*') ||
679 (value === '/') ||
680 (value === '%') ||
681 (value === '~/') ||
682 (value === '+') ||
683 (value === '-') ||
684 (value === '<<') ||
685 (value === '>>>') ||
686 (value === '>>') ||
687 (value === '>=') ||
688 (value === '>') ||
689 (value === '<=') ||
690 (value === '<') ||
691 (value === '&') ||
692 (value === '^') ||
693 (value === '|');
694 }
695
696 Token parseFunction(Token token, Token getOrSet) { 670 Token parseFunction(Token token, Token getOrSet) {
697 listener.beginFunction(token); 671 listener.beginFunction(token);
698 token = parseModifiers(token); 672 token = parseModifiers(token);
699 if (getOrSet === token) token = token.next; 673 if (getOrSet === token) token = token.next;
700 token = parseReturnTypeOpt(token); 674 token = parseReturnTypeOpt(token);
701 if (getOrSet === token) token = token.next; 675 if (getOrSet === token) token = token.next;
702 listener.beginFunctionName(token); 676 listener.beginFunctionName(token);
703 if (optional('operator', token)) { 677 if (optional('operator', token)) {
704 token = parseOperatorName(token); 678 token = parseOperatorName(token);
705 } else { 679 } else {
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 } 1625 }
1652 listener.handleContinueStatement(hasTarget, continueKeyword, token); 1626 listener.handleContinueStatement(hasTarget, continueKeyword, token);
1653 return expectSemicolon(token); 1627 return expectSemicolon(token);
1654 } 1628 }
1655 1629
1656 Token parseEmptyStatement(Token token) { 1630 Token parseEmptyStatement(Token token) {
1657 listener.handleEmptyStatement(token); 1631 listener.handleEmptyStatement(token);
1658 return expectSemicolon(token); 1632 return expectSemicolon(token);
1659 } 1633 }
1660 } 1634 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/leg/scanner/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698