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

Side by Side Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2778213002: Use message.yaml in parser. (Closed)
Patch Set: Update subpackage relationships. 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/parser/element_listener.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.analyzer.ast_builder; 5 library fasta.analyzer.ast_builder;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
11 import 'package:analyzer/dart/element/element.dart' show Element; 11 import 'package:analyzer/dart/element/element.dart' show Element;
12 import 'package:front_end/src/fasta/parser/parser.dart' 12 import 'package:front_end/src/fasta/parser/parser.dart'
13 show FormalParameterType; 13 show FormalParameterType;
14 import 'package:front_end/src/fasta/scanner/token.dart' 14 import 'package:front_end/src/fasta/scanner/token.dart'
15 show BeginGroupToken, Token; 15 show BeginGroupToken, Token;
16 16
17 import 'package:front_end/src/fasta/errors.dart' show internalError; 17 import 'package:front_end/src/fasta/errors.dart' show internalError;
18 import 'package:front_end/src/fasta/fasta_codes.dart'
19 show FastaMessage, codeExpectedExpression;
18 import 'package:front_end/src/fasta/kernel/kernel_builder.dart' 20 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'
19 show Builder, KernelLibraryBuilder, ProcedureBuilder; 21 show Builder, KernelLibraryBuilder, ProcedureBuilder;
20 import 'package:front_end/src/fasta/parser/identifier_context.dart' 22 import 'package:front_end/src/fasta/parser/identifier_context.dart'
21 show IdentifierContext; 23 show IdentifierContext;
22 import 'package:front_end/src/fasta/quote.dart'; 24 import 'package:front_end/src/fasta/quote.dart';
23 import 'package:front_end/src/fasta/source/scope_listener.dart' 25 import 'package:front_end/src/fasta/source/scope_listener.dart'
24 show JumpTargetKind, NullValue, Scope, ScopeListener; 26 show JumpTargetKind, NullValue, Scope, ScopeListener;
25 import 'analyzer.dart' show toKernel; 27 import 'analyzer.dart' show toKernel;
26 import 'element_store.dart' 28 import 'element_store.dart'
27 show 29 show
28 AnalyzerLocalVariableElemment, 30 AnalyzerLocalVariableElemment,
29 AnalyzerParameterElement, 31 AnalyzerParameterElement,
30 ElementStore, 32 ElementStore,
31 KernelClassElement; 33 KernelClassElement;
32 import 'package:analyzer/src/dart/error/syntactic_errors.dart'; 34 import 'package:analyzer/src/dart/error/syntactic_errors.dart';
33 import 'package:front_end/src/fasta/parser/error_kind.dart';
34 import 'token_utils.dart' show toAnalyzerToken, toAnalyzerCommentToken; 35 import 'token_utils.dart' show toAnalyzerToken, toAnalyzerCommentToken;
35 36
36 class AstBuilder extends ScopeListener { 37 class AstBuilder extends ScopeListener {
37 final AstFactory ast = standard.astFactory; 38 final AstFactory ast = standard.astFactory;
38 39
39 final ErrorReporter errorReporter; 40 final ErrorReporter errorReporter;
40 final KernelLibraryBuilder library; 41 final KernelLibraryBuilder library;
41 final Builder member; 42 final Builder member;
42 final ElementStore elementStore; 43 final ElementStore elementStore;
43 44
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 toAnalyzerToken(closeCurlyBracket))); 1040 toAnalyzerToken(closeCurlyBracket)));
1040 } 1041 }
1041 } 1042 }
1042 1043
1043 @override 1044 @override
1044 void handleInvalidExpression(Token token) { 1045 void handleInvalidExpression(Token token) {
1045 debugEvent("InvalidExpression"); 1046 debugEvent("InvalidExpression");
1046 } 1047 }
1047 1048
1048 @override 1049 @override
1049 Token handleUnrecoverableError(Token token, ErrorKind kind, Map arguments) { 1050 Token handleUnrecoverableError(Token token, FastaMessage message) {
1050 if (kind == ErrorKind.ExpectedExpression) { 1051 if (message.code == codeExpectedExpression) {
1051 String lexeme = token.lexeme; 1052 String lexeme = token.lexeme;
1052 if (identical('async', lexeme) || identical('yield', lexeme)) { 1053 if (identical('async', lexeme) || identical('yield', lexeme)) {
1053 errorReporter?.reportErrorForOffset( 1054 errorReporter?.reportErrorForOffset(
1054 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER, 1055 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
1055 token.charOffset, 1056 token.charOffset,
1056 token.charCount); 1057 token.charCount);
1057 push(ast.simpleIdentifier(toAnalyzerToken(token))); 1058 push(ast.simpleIdentifier(toAnalyzerToken(token)));
1058 return token; 1059 return token;
1059 } 1060 }
1060 } 1061 }
1061 return super.handleUnrecoverableError(token, kind, arguments); 1062 return super.handleUnrecoverableError(token, message);
1062 } 1063 }
1063 1064
1064 void handleUnaryPrefixExpression(Token token) { 1065 void handleUnaryPrefixExpression(Token token) {
1065 debugEvent("UnaryPrefixExpression"); 1066 debugEvent("UnaryPrefixExpression");
1066 push(ast.prefixExpression(toAnalyzerToken(token), pop())); 1067 push(ast.prefixExpression(toAnalyzerToken(token), pop()));
1067 } 1068 }
1068 1069
1069 void handleUnaryPrefixAssignmentExpression(Token token) { 1070 void handleUnaryPrefixAssignmentExpression(Token token) {
1070 debugEvent("UnaryPrefixAssignmentExpression"); 1071 debugEvent("UnaryPrefixAssignmentExpression");
1071 push(ast.prefixExpression(toAnalyzerToken(token), pop())); 1072 push(ast.prefixExpression(toAnalyzerToken(token), pop()));
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 } else if (identical('static', s)) { 1945 } else if (identical('static', s)) {
1945 staticKeyword = token; 1946 staticKeyword = token;
1946 } else if (identical('var', s)) { 1947 } else if (identical('var', s)) {
1947 finalConstOrVarKeyword = token; 1948 finalConstOrVarKeyword = token;
1948 } else { 1949 } else {
1949 internalError('Unhandled modifier: $s'); 1950 internalError('Unhandled modifier: $s');
1950 } 1951 }
1951 } 1952 }
1952 } 1953 }
1953 } 1954 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/parser/element_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698