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

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

Issue 2837473002: merge fasta.PrecedenceInfo into analyzer.TokenType (Closed)
Patch Set: Created 3 years, 8 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 codeUnspecified, 51 codeUnspecified,
52 codeUnsupportedPrefixPlus, 52 codeUnsupportedPrefixPlus,
53 codeUnterminatedString, 53 codeUnterminatedString,
54 codeYieldAsIdentifier, 54 codeYieldAsIdentifier,
55 codeYieldNotGenerator; 55 codeYieldNotGenerator;
56 56
57 import '../scanner.dart' show ErrorToken; 57 import '../scanner.dart' show ErrorToken;
58 58
59 import '../scanner/recover.dart' show closeBraceFor, skipToEof; 59 import '../scanner/recover.dart' show closeBraceFor, skipToEof;
60 60
61 import '../../scanner/token.dart' show Keyword; 61 import '../../scanner/token.dart'
62 show
63 ASSIGNMENT_PRECEDENCE,
64 CASCADE_PRECEDENCE,
65 EQUALITY_PRECEDENCE,
66 Keyword,
67 POSTFIX_PRECEDENCE,
68 RELATIONAL_PRECEDENCE,
69 TokenType;
62 70
63 import '../scanner/precedence.dart' 71 import '../scanner/precedence.dart'
64 show 72 show
65 ASSIGNMENT_PRECEDENCE,
66 AS_INFO, 73 AS_INFO,
67 CASCADE_PRECEDENCE,
68 EQUALITY_PRECEDENCE,
69 GT_INFO, 74 GT_INFO,
70 IS_INFO, 75 IS_INFO,
71 MINUS_MINUS_INFO, 76 MINUS_MINUS_INFO,
72 OPEN_PAREN_INFO, 77 OPEN_PAREN_INFO,
73 OPEN_SQUARE_BRACKET_INFO, 78 OPEN_SQUARE_BRACKET_INFO,
74 PERIOD_INFO, 79 PERIOD_INFO,
75 PLUS_PLUS_INFO, 80 PLUS_PLUS_INFO,
76 POSTFIX_PRECEDENCE,
77 PrecedenceInfo,
78 QUESTION_INFO, 81 QUESTION_INFO,
79 QUESTION_PERIOD_INFO, 82 QUESTION_PERIOD_INFO,
80 RELATIONAL_PRECEDENCE,
81 SCRIPT_INFO; 83 SCRIPT_INFO;
82 84
83 import '../scanner/token.dart' 85 import '../scanner/token.dart'
84 show 86 show
85 BeginGroupToken, 87 BeginGroupToken,
86 KeywordToken, 88 KeywordToken,
87 SymbolToken, 89 SymbolToken,
88 Token, 90 Token,
89 isUserDefinableOperator; 91 isUserDefinableOperator;
90 92
(...skipping 2628 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 token = parseExpressionWithoutCascade(token); 2721 token = parseExpressionWithoutCascade(token);
2720 listener.handleConditionalExpression(question, colon); 2722 listener.handleConditionalExpression(question, colon);
2721 return token; 2723 return token;
2722 } 2724 }
2723 2725
2724 Token parsePrecedenceExpression( 2726 Token parsePrecedenceExpression(
2725 Token token, int precedence, bool allowCascades) { 2727 Token token, int precedence, bool allowCascades) {
2726 assert(precedence >= 1); 2728 assert(precedence >= 1);
2727 assert(precedence <= POSTFIX_PRECEDENCE); 2729 assert(precedence <= POSTFIX_PRECEDENCE);
2728 token = parseUnaryExpression(token, allowCascades); 2730 token = parseUnaryExpression(token, allowCascades);
2729 PrecedenceInfo info = token.info; 2731 TokenType info = token.info;
2730 int tokenLevel = info.precedence; 2732 int tokenLevel = info.precedence;
2731 for (int level = tokenLevel; level >= precedence; --level) { 2733 for (int level = tokenLevel; level >= precedence; --level) {
2732 while (identical(tokenLevel, level)) { 2734 while (identical(tokenLevel, level)) {
2733 Token operator = token; 2735 Token operator = token;
2734 if (identical(tokenLevel, CASCADE_PRECEDENCE)) { 2736 if (identical(tokenLevel, CASCADE_PRECEDENCE)) {
2735 if (!allowCascades) { 2737 if (!allowCascades) {
2736 return token; 2738 return token;
2737 } 2739 }
2738 token = parseCascadeExpression(token); 2740 token = parseCascadeExpression(token);
2739 } else if (identical(tokenLevel, ASSIGNMENT_PRECEDENCE)) { 2741 } else if (identical(tokenLevel, ASSIGNMENT_PRECEDENCE)) {
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
3905 return reportUnrecoverableError( 3907 return reportUnrecoverableError(
3906 token, () => code.format(uri, token.charOffset, string)); 3908 token, () => code.format(uri, token.charOffset, string));
3907 } 3909 }
3908 } 3910 }
3909 3911
3910 typedef FastaMessage NoArgument(Uri uri, int charOffset); 3912 typedef FastaMessage NoArgument(Uri uri, int charOffset);
3911 3913
3912 typedef FastaMessage TokenArgument(Uri uri, int charOffset, Token token); 3914 typedef FastaMessage TokenArgument(Uri uri, int charOffset, Token token);
3913 3915
3914 typedef FastaMessage StringArgument(Uri uri, int charOffset, String string); 3916 typedef FastaMessage StringArgument(Uri uri, int charOffset, String string);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698