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

Side by Side Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2872453004: cleanup TokenType var names (Closed)
Patch Set: Created 3 years, 7 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
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 library fasta.parser.parser; 5 library fasta.parser.parser;
6 6
7 import '../fasta_codes.dart' 7 import '../fasta_codes.dart'
8 show 8 show
9 FastaCode, 9 FastaCode,
10 FastaMessage, 10 FastaMessage,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return token; 286 return token;
287 } 287 }
288 288
289 Token parseTopLevelDeclaration(Token token) { 289 Token parseTopLevelDeclaration(Token token) {
290 token = _parseTopLevelDeclaration(token); 290 token = _parseTopLevelDeclaration(token);
291 listener.endTopLevelDeclaration(token); 291 listener.endTopLevelDeclaration(token);
292 return token; 292 return token;
293 } 293 }
294 294
295 Token _parseTopLevelDeclaration(Token token) { 295 Token _parseTopLevelDeclaration(Token token) {
296 if (identical(token.info, TokenType.SCRIPT_TAG)) { 296 if (identical(token.type, TokenType.SCRIPT_TAG)) {
297 return parseScript(token); 297 return parseScript(token);
298 } 298 }
299 token = parseMetadataStar(token); 299 token = parseMetadataStar(token);
300 final String value = token.stringValue; 300 final String value = token.stringValue;
301 if ((identical(value, 'abstract') && optional('class', token.next)) || 301 if ((identical(value, 'abstract') && optional('class', token.next)) ||
302 identical(value, 'class')) { 302 identical(value, 'class')) {
303 return parseClassOrNamedMixinApplication(token); 303 return parseClassOrNamedMixinApplication(token);
304 } else if (identical(value, 'enum')) { 304 } else if (identical(value, 'enum')) {
305 return parseEnum(token); 305 return parseEnum(token);
306 } else if (identical(value, 'typedef')) { 306 } else if (identical(value, 'typedef')) {
(...skipping 2424 matching lines...) Expand 10 before | Expand all | Expand 10 after
2731 token = parseExpressionWithoutCascade(token); 2731 token = parseExpressionWithoutCascade(token);
2732 listener.handleConditionalExpression(question, colon); 2732 listener.handleConditionalExpression(question, colon);
2733 return token; 2733 return token;
2734 } 2734 }
2735 2735
2736 Token parsePrecedenceExpression( 2736 Token parsePrecedenceExpression(
2737 Token token, int precedence, bool allowCascades) { 2737 Token token, int precedence, bool allowCascades) {
2738 assert(precedence >= 1); 2738 assert(precedence >= 1);
2739 assert(precedence <= POSTFIX_PRECEDENCE); 2739 assert(precedence <= POSTFIX_PRECEDENCE);
2740 token = parseUnaryExpression(token, allowCascades); 2740 token = parseUnaryExpression(token, allowCascades);
2741 TokenType info = token.info; 2741 TokenType type = token.type;
2742 int tokenLevel = info.precedence; 2742 int tokenLevel = type.precedence;
2743 for (int level = tokenLevel; level >= precedence; --level) { 2743 for (int level = tokenLevel; level >= precedence; --level) {
2744 while (identical(tokenLevel, level)) { 2744 while (identical(tokenLevel, level)) {
2745 Token operator = token; 2745 Token operator = token;
2746 if (identical(tokenLevel, CASCADE_PRECEDENCE)) { 2746 if (identical(tokenLevel, CASCADE_PRECEDENCE)) {
2747 if (!allowCascades) { 2747 if (!allowCascades) {
2748 return token; 2748 return token;
2749 } 2749 }
2750 token = parseCascadeExpression(token); 2750 token = parseCascadeExpression(token);
2751 } else if (identical(tokenLevel, ASSIGNMENT_PRECEDENCE)) { 2751 } else if (identical(tokenLevel, ASSIGNMENT_PRECEDENCE)) {
2752 // Right associative, so we recurse at the same precedence 2752 // Right associative, so we recurse at the same precedence
2753 // level. 2753 // level.
2754 listener.beginExpression(token.next); 2754 listener.beginExpression(token.next);
2755 token = parsePrecedenceExpression(token.next, level, allowCascades); 2755 token = parsePrecedenceExpression(token.next, level, allowCascades);
2756 listener.handleAssignmentExpression(operator); 2756 listener.handleAssignmentExpression(operator);
2757 } else if (identical(tokenLevel, POSTFIX_PRECEDENCE)) { 2757 } else if (identical(tokenLevel, POSTFIX_PRECEDENCE)) {
2758 if (identical(info, TokenType.PERIOD) || 2758 if (identical(type, TokenType.PERIOD) ||
2759 identical(info, TokenType.QUESTION_PERIOD)) { 2759 identical(type, TokenType.QUESTION_PERIOD)) {
2760 // Left associative, so we recurse at the next higher precedence 2760 // Left associative, so we recurse at the next higher precedence
2761 // level. However, POSTFIX_PRECEDENCE is the highest level, so we 2761 // level. However, POSTFIX_PRECEDENCE is the highest level, so we
2762 // should just call [parseUnaryExpression] directly. However, a 2762 // should just call [parseUnaryExpression] directly. However, a
2763 // unary expression isn't legal after a period, so we call 2763 // unary expression isn't legal after a period, so we call
2764 // [parsePrimary] instead. 2764 // [parsePrimary] instead.
2765 token = parsePrimary( 2765 token = parsePrimary(
2766 token.next, IdentifierContext.expressionContinuation); 2766 token.next, IdentifierContext.expressionContinuation);
2767 listener.handleBinaryExpression(operator); 2767 listener.handleBinaryExpression(operator);
2768 } else if ((identical(info, TokenType.OPEN_PAREN)) || 2768 } else if ((identical(type, TokenType.OPEN_PAREN)) ||
2769 (identical(info, TokenType.OPEN_SQUARE_BRACKET))) { 2769 (identical(type, TokenType.OPEN_SQUARE_BRACKET))) {
2770 token = parseArgumentOrIndexStar(token); 2770 token = parseArgumentOrIndexStar(token);
2771 } else if ((identical(info, TokenType.PLUS_PLUS)) || 2771 } else if ((identical(type, TokenType.PLUS_PLUS)) ||
2772 (identical(info, TokenType.MINUS_MINUS))) { 2772 (identical(type, TokenType.MINUS_MINUS))) {
2773 listener.handleUnaryPostfixAssignmentExpression(token); 2773 listener.handleUnaryPostfixAssignmentExpression(token);
2774 token = token.next; 2774 token = token.next;
2775 } else { 2775 } else {
2776 token = reportUnexpectedToken(token).next; 2776 token = reportUnexpectedToken(token).next;
2777 } 2777 }
2778 } else if (identical(info, TokenType.IS)) { 2778 } else if (identical(type, TokenType.IS)) {
2779 token = parseIsOperatorRest(token); 2779 token = parseIsOperatorRest(token);
2780 } else if (identical(info, TokenType.AS)) { 2780 } else if (identical(type, TokenType.AS)) {
2781 token = parseAsOperatorRest(token); 2781 token = parseAsOperatorRest(token);
2782 } else if (identical(info, TokenType.QUESTION)) { 2782 } else if (identical(type, TokenType.QUESTION)) {
2783 token = parseConditionalExpressionRest(token); 2783 token = parseConditionalExpressionRest(token);
2784 } else { 2784 } else {
2785 // Left associative, so we recurse at the next higher 2785 // Left associative, so we recurse at the next higher
2786 // precedence level. 2786 // precedence level.
2787 listener.beginExpression(token.next); 2787 listener.beginExpression(token.next);
2788 token = 2788 token =
2789 parsePrecedenceExpression(token.next, level + 1, allowCascades); 2789 parsePrecedenceExpression(token.next, level + 1, allowCascades);
2790 listener.handleBinaryExpression(operator); 2790 listener.handleBinaryExpression(operator);
2791 } 2791 }
2792 info = token.info; 2792 type = token.type;
2793 tokenLevel = info.precedence; 2793 tokenLevel = type.precedence;
2794 if (level == EQUALITY_PRECEDENCE || level == RELATIONAL_PRECEDENCE) { 2794 if (level == EQUALITY_PRECEDENCE || level == RELATIONAL_PRECEDENCE) {
2795 // We don't allow (a == b == c) or (a < b < c). 2795 // We don't allow (a == b == c) or (a < b < c).
2796 // Continue the outer loop if we have matched one equality or 2796 // Continue the outer loop if we have matched one equality or
2797 // relational operator. 2797 // relational operator.
2798 break; 2798 break;
2799 } 2799 }
2800 } 2800 }
2801 } 2801 }
2802 return token; 2802 return token;
2803 } 2803 }
(...skipping 15 matching lines...) Expand all
2819 do { 2819 do {
2820 mark = token; 2820 mark = token;
2821 if (optional('.', token)) { 2821 if (optional('.', token)) {
2822 Token period = token; 2822 Token period = token;
2823 token = parseSend(token.next, IdentifierContext.expressionContinuation); 2823 token = parseSend(token.next, IdentifierContext.expressionContinuation);
2824 listener.handleBinaryExpression(period); 2824 listener.handleBinaryExpression(period);
2825 } 2825 }
2826 token = parseArgumentOrIndexStar(token); 2826 token = parseArgumentOrIndexStar(token);
2827 } while (!identical(mark, token)); 2827 } while (!identical(mark, token));
2828 2828
2829 if (identical(token.info.precedence, ASSIGNMENT_PRECEDENCE)) { 2829 if (identical(token.type.precedence, ASSIGNMENT_PRECEDENCE)) {
2830 Token assignment = token; 2830 Token assignment = token;
2831 token = parseExpressionWithoutCascade(token.next); 2831 token = parseExpressionWithoutCascade(token.next);
2832 listener.handleAssignmentExpression(assignment); 2832 listener.handleAssignmentExpression(assignment);
2833 } 2833 }
2834 listener.endCascade(); 2834 listener.endCascade();
2835 return token; 2835 return token;
2836 } 2836 }
2837 2837
2838 Token parseUnaryExpression(Token token, bool allowCascades) { 2838 Token parseUnaryExpression(Token token, bool allowCascades) {
2839 String value = token.stringValue; 2839 String value = token.stringValue;
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
3917 return reportUnrecoverableError( 3917 return reportUnrecoverableError(
3918 token, () => code.format(uri, token.charOffset, string)); 3918 token, () => code.format(uri, token.charOffset, string));
3919 } 3919 }
3920 } 3920 }
3921 3921
3922 typedef FastaMessage NoArgument(Uri uri, int charOffset); 3922 typedef FastaMessage NoArgument(Uri uri, int charOffset);
3923 3923
3924 typedef FastaMessage TokenArgument(Uri uri, int charOffset, Token token); 3924 typedef FastaMessage TokenArgument(Uri uri, int charOffset, Token token);
3925 3925
3926 typedef FastaMessage StringArgument(Uri uri, int charOffset, String string); 3926 typedef FastaMessage StringArgument(Uri uri, int charOffset, String string);
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree/nodes.dart ('k') | pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698