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

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

Issue 2978063002: Move parser helper classes to own files and clean them up. (Closed)
Patch Set: Don't use problems.dart in parser. Created 3 years, 5 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.listener; 5 library fasta.parser.listener;
6 6
7 import '../../scanner/token.dart' show BeginToken, Token, TokenType;
8
7 import '../fasta_codes.dart' show Message; 9 import '../fasta_codes.dart' show Message;
8 10
9 import '../../scanner/token.dart' show BeginToken, Token, TokenType;
10
11 import '../util/link.dart' show Link; 11 import '../util/link.dart' show Link;
12 12
13 import 'parser.dart' show Assert, FormalParameterType, MemberKind; 13 import 'assert.dart' show Assert;
14
15 import 'formal_parameter_kind.dart' show FormalParameterKind;
14 16
15 import 'identifier_context.dart' show IdentifierContext; 17 import 'identifier_context.dart' show IdentifierContext;
16 18
19 import 'member_kind.dart' show MemberKind;
20
21 import 'parser_error.dart' show ParserError;
22
17 /// A parser event listener that does nothing except throw exceptions 23 /// A parser event listener that does nothing except throw exceptions
18 /// on parser errors. 24 /// on parser errors.
19 /// 25 ///
20 /// Events are methods that begin with one of: `begin`, `end`, or `handle`. 26 /// Events are methods that begin with one of: `begin`, `end`, or `handle`.
21 /// 27 ///
22 /// Events starting with `begin` and `end` come in pairs. Normally, a 28 /// Events starting with `begin` and `end` come in pairs. Normally, a
23 /// `beginFoo` event is followed by an `endFoo` event. There's a few exceptions 29 /// `beginFoo` event is followed by an `endFoo` event. There's a few exceptions
24 /// documented below. 30 /// documented below.
25 /// 31 ///
26 /// Events starting with `handle` are used when isn't possible to have a begin 32 /// Events starting with `handle` are used when isn't possible to have a begin
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void beginFactoryMethod(Token token) {} 195 void beginFactoryMethod(Token token) {}
190 196
191 void endFactoryMethod( 197 void endFactoryMethod(
192 Token beginToken, Token factoryKeyword, Token endToken) { 198 Token beginToken, Token factoryKeyword, Token endToken) {
193 logEvent("FactoryMethod"); 199 logEvent("FactoryMethod");
194 } 200 }
195 201
196 void beginFormalParameter(Token token, MemberKind kind) {} 202 void beginFormalParameter(Token token, MemberKind kind) {}
197 203
198 void endFormalParameter(Token thisKeyword, Token nameToken, 204 void endFormalParameter(Token thisKeyword, Token nameToken,
199 FormalParameterType kind, MemberKind memberKind) { 205 FormalParameterKind kind, MemberKind memberKind) {
200 logEvent("FormalParameter"); 206 logEvent("FormalParameter");
201 } 207 }
202 208
203 void handleNoFormalParameters(Token token, MemberKind kind) { 209 void handleNoFormalParameters(Token token, MemberKind kind) {
204 logEvent("NoFormalParameters"); 210 logEvent("NoFormalParameters");
205 } 211 }
206 212
207 void beginFormalParameters(Token token, MemberKind kind) {} 213 void beginFormalParameters(Token token, MemberKind kind) {}
208 214
209 void endFormalParameters( 215 void endFormalParameters(
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 void discardTypeReplacedWithCommentTypeAssign() {} 1101 void discardTypeReplacedWithCommentTypeAssign() {}
1096 1102
1097 /// Creates a new synthetic token whose `next` pointer points to [next]. 1103 /// Creates a new synthetic token whose `next` pointer points to [next].
1098 /// 1104 ///
1099 /// If [next] is `null`, `null` is returned. 1105 /// If [next] is `null`, `null` is returned.
1100 Token newSyntheticToken(Token next) { 1106 Token newSyntheticToken(Token next) {
1101 if (next == null) return null; 1107 if (next == null) return null;
1102 return new Token(TokenType.RECOVERY, next.charOffset)..next = next; 1108 return new Token(TokenType.RECOVERY, next.charOffset)..next = next;
1103 } 1109 }
1104 } 1110 }
1105
1106 class ParserError {
1107 /// Character offset from the beginning of file where this error starts.
1108 final int beginOffset;
1109
1110 /// Character offset from the beginning of file where this error ends.
1111 final int endOffset;
1112
1113 final Message message;
1114
1115 ParserError(this.beginOffset, this.endOffset, this.message);
1116
1117 ParserError.fromTokens(Token begin, Token end, Message message)
1118 : this(begin.charOffset, end.charOffset + end.charCount, message);
1119
1120 String toString() => "@${beginOffset}: ${message.message}\n${message.tip}";
1121 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/formal_parameter_kind.dart ('k') | pkg/front_end/lib/src/fasta/parser/member_kind.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698