| OLD | NEW |
| 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.listener; | 5 library fasta.parser.listener; |
| 6 | 6 |
| 7 import '../fasta_codes.dart' show FastaMessage; | 7 import '../fasta_codes.dart' show FastaMessage; |
| 8 | 8 |
| 9 import '../../scanner/token.dart' show Token, TokenType; | 9 import '../../scanner/token.dart' show Token, TokenType; |
| 10 | 10 |
| 11 import '../scanner/token.dart' show BeginGroupToken, SymbolToken; | 11 import '../scanner/token.dart' show BeginGroupToken, SymbolToken; |
| 12 | 12 |
| 13 import '../util/link.dart' show Link; | 13 import '../util/link.dart' show Link; |
| 14 | 14 |
| 15 import 'parser.dart' show FormalParameterType; | 15 import 'parser.dart' show FormalParameterType, MemberKind; |
| 16 | 16 |
| 17 import 'identifier_context.dart' show IdentifierContext; | 17 import 'identifier_context.dart' show IdentifierContext; |
| 18 | 18 |
| 19 /// A parser event listener that does nothing except throw exceptions | 19 /// A parser event listener that does nothing except throw exceptions |
| 20 /// on parser errors. | 20 /// on parser errors. |
| 21 /// | 21 /// |
| 22 /// Events are methods that begin with one of: `begin`, `end`, or `handle`. | 22 /// Events are methods that begin with one of: `begin`, `end`, or `handle`. |
| 23 /// | 23 /// |
| 24 /// Events starting with `begin` and `end` come in pairs. Normally, a | 24 /// Events starting with `begin` and `end` come in pairs. Normally, a |
| 25 /// `beginFoo` event is followed by an `endFoo` event. There's a few exceptions | 25 /// `beginFoo` event is followed by an `endFoo` event. There's a few exceptions |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 logEvent("ExpressionStatement"); | 173 logEvent("ExpressionStatement"); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void beginFactoryMethod(Token token) {} | 176 void beginFactoryMethod(Token token) {} |
| 177 | 177 |
| 178 void endFactoryMethod( | 178 void endFactoryMethod( |
| 179 Token beginToken, Token factoryKeyword, Token endToken) { | 179 Token beginToken, Token factoryKeyword, Token endToken) { |
| 180 logEvent("FactoryMethod"); | 180 logEvent("FactoryMethod"); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void beginFormalParameter(Token token) {} | 183 void beginFormalParameter(Token token, MemberKind kind) {} |
| 184 | 184 |
| 185 void endFormalParameter(Token covariantKeyword, Token thisKeyword, | 185 void endFormalParameter(Token thisKeyword, Token nameToken, |
| 186 Token nameToken, FormalParameterType kind) { | 186 FormalParameterType kind, MemberKind memberKind) { |
| 187 logEvent("FormalParameter"); | 187 logEvent("FormalParameter"); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void handleNoFormalParameters(Token token) { | 190 void handleNoFormalParameters(Token token, MemberKind kind) { |
| 191 logEvent("NoFormalParameters"); | 191 logEvent("NoFormalParameters"); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void beginFormalParameters(Token token) {} | 194 void beginFormalParameters(Token token, MemberKind kind) {} |
| 195 | 195 |
| 196 void endFormalParameters(int count, Token beginToken, Token endToken) { | 196 void endFormalParameters( |
| 197 int count, Token beginToken, Token endToken, MemberKind kind) { |
| 197 logEvent("FormalParameters"); | 198 logEvent("FormalParameters"); |
| 198 } | 199 } |
| 199 | 200 |
| 200 /// Handle the end of a field declaration. Substructures: | 201 /// Handle the end of a field declaration. Substructures: |
| 201 /// - Metadata | 202 /// - Metadata |
| 202 /// - Modifiers | 203 /// - Modifiers |
| 203 /// - Type | 204 /// - Type |
| 204 /// - Variable declarations (count times) | 205 /// - Variable declarations (count times) |
| 205 /// | 206 /// |
| 206 /// Doesn't have a corresponding begin event, use [beginMember] instead. | 207 /// Doesn't have a corresponding begin event, use [beginMember] instead. |
| 207 void endFields( | 208 void endFields(int count, Token beginToken, Token endToken) { |
| 208 int count, Token covariantKeyword, Token beginToken, Token endToken) { | |
| 209 logEvent("Fields"); | 209 logEvent("Fields"); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void beginForStatement(Token token) {} | 212 void beginForStatement(Token token) {} |
| 213 | 213 |
| 214 void endForStatement(Token forKeyword, Token leftSeparator, | 214 void endForStatement(Token forKeyword, Token leftSeparator, |
| 215 int updateExpressionCount, Token endToken) { | 215 int updateExpressionCount, Token endToken) { |
| 216 logEvent("ForStatement"); | 216 logEvent("ForStatement"); |
| 217 } | 217 } |
| 218 | 218 |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 void beginFunctionTypedFormalParameter(Token token) {} | 808 void beginFunctionTypedFormalParameter(Token token) {} |
| 809 | 809 |
| 810 /// Handle the end of a function typed formal parameter. Substructures: | 810 /// Handle the end of a function typed formal parameter. Substructures: |
| 811 /// - metadata | 811 /// - metadata |
| 812 /// - modifiers | 812 /// - modifiers |
| 813 /// - return type | 813 /// - return type |
| 814 /// - parameter name (simple identifier) | 814 /// - parameter name (simple identifier) |
| 815 /// - type parameters | 815 /// - type parameters |
| 816 /// - formal parameters | 816 /// - formal parameters |
| 817 void endFunctionTypedFormalParameter( | 817 void endFunctionTypedFormalParameter( |
| 818 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { | 818 Token thisKeyword, FormalParameterType kind) { |
| 819 logEvent("FunctionTypedFormalParameter"); | 819 logEvent("FunctionTypedFormalParameter"); |
| 820 } | 820 } |
| 821 | 821 |
| 822 /// Handle an identifier token. | 822 /// Handle an identifier token. |
| 823 /// | 823 /// |
| 824 /// [context] indicates what kind of construct the identifier appears in. | 824 /// [context] indicates what kind of construct the identifier appears in. |
| 825 void handleIdentifier(Token token, IdentifierContext context) { | 825 void handleIdentifier(Token token, IdentifierContext context) { |
| 826 logEvent("Identifier"); | 826 logEvent("Identifier"); |
| 827 } | 827 } |
| 828 | 828 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 | 1074 |
| 1075 final FastaMessage message; | 1075 final FastaMessage message; |
| 1076 | 1076 |
| 1077 ParserError(this.beginOffset, this.endOffset, this.message); | 1077 ParserError(this.beginOffset, this.endOffset, this.message); |
| 1078 | 1078 |
| 1079 ParserError.fromTokens(Token begin, Token end, FastaMessage message) | 1079 ParserError.fromTokens(Token begin, Token end, FastaMessage message) |
| 1080 : this(begin.charOffset, end.charOffset + end.charCount, message); | 1080 : this(begin.charOffset, end.charOffset + end.charCount, message); |
| 1081 | 1081 |
| 1082 String toString() => "@${beginOffset}: ${message.message}\n${message.tip}"; | 1082 String toString() => "@${beginOffset}: ${message.message}\n${message.tip}"; |
| 1083 } | 1083 } |
| OLD | NEW |