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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser_fasta.dart

Issue 2948473002: integrating fasta parser (Closed)
Patch Set: Created 3 years, 6 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
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 part of analyzer.parser;
6
7 class _Builder implements Builder {
8 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
9 }
10
11 class _ElementStore implements ElementStore {
12 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
13 }
14
15 class _KernelLibraryBuilder implements KernelLibraryBuilder {
16 @override
17 final uri;
18
19 _KernelLibraryBuilder(this.uri);
20
21 @override
22 Uri get fileUri => uri;
23
24 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
25 }
26
27 /**
28 * Replacement parser based on Fasta.
29 */
30 class _Parser2 implements Parser {
31 @override
32 Token currentToken;
33
34 /**
35 * The builder which creates the analyzer AST data structures
36 * based on the Fasta parser.
37 */
38 final AstBuilder _astBuilder;
39
40 /**
41 * The error listener that will be informed of any errors that are found
42 * during the parse.
43 */
44 final AnalysisErrorListener _errorListener;
45
46 /**
47 * The fasta parser being wrapped.
48 */
49 final fasta.Parser _fastaParser;
50
51 /**
52 * The source being parsed.
53 */
54 final Source _source;
55
56 factory _Parser2(Source source, AnalysisErrorListener errorListener) {
57 var errorReporter = new ErrorReporter(errorListener, source);
58 var library = new _KernelLibraryBuilder(source.uri);
59 var member = new _Builder();
60 var elementStore = new _ElementStore();
61 var scope = new Scope.top(isModifiable: true);
62
63 AstBuilder astBuilder = new AstBuilder(
64 errorReporter, library, member, elementStore, scope, true);
65 fasta.Parser fastaParser = new fasta.Parser(astBuilder);
66 astBuilder.parser = fastaParser;
67 return new _Parser2._(source, errorListener, fastaParser, astBuilder);
68 }
69
70 _Parser2._(
71 this._source, this._errorListener, this._fastaParser, this._astBuilder);
72
73 @override
74 bool get parseGenericMethodComments => _astBuilder.parseGenericMethodComments;
75
76 @override
77 set parseGenericMethodComments(bool value) {
78 _astBuilder.parseGenericMethodComments = value;
79 }
80
81 @override
82 CompilationUnit parseCompilationUnit(Token token) {
83 currentToken = token;
84 return parseCompilationUnit2();
85 }
86
87 @override
88 CompilationUnit parseCompilationUnit2() {
89 currentToken = _fastaParser.parseUnit(currentToken);
90 return _astBuilder.pop();
91 }
92
93 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
94 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/test/generated/parser_fasta_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698