OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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 part of analyzer.parser; | 5 part of analyzer.parser; |
6 | 6 |
7 class _Builder implements Builder { | 7 class _Builder implements Builder { |
8 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 8 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
9 } | 9 } |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 @override | 31 @override |
32 Token currentToken; | 32 Token currentToken; |
33 | 33 |
34 /** | 34 /** |
35 * The builder which creates the analyzer AST data structures | 35 * The builder which creates the analyzer AST data structures |
36 * based on the Fasta parser. | 36 * based on the Fasta parser. |
37 */ | 37 */ |
38 final AstBuilder _astBuilder; | 38 final AstBuilder _astBuilder; |
39 | 39 |
40 /** | 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. | 41 * The fasta parser being wrapped. |
48 */ | 42 */ |
49 final fasta.Parser _fastaParser; | 43 final fasta.Parser _fastaParser; |
50 | 44 |
51 /** | 45 /** |
52 * The source being parsed. | 46 * The source being parsed. |
53 */ | 47 */ |
54 final Source _source; | 48 final Source _source; |
55 | 49 |
56 factory _Parser2(Source source, AnalysisErrorListener errorListener) { | 50 factory _Parser2(Source source, AnalysisErrorListener errorListener) { |
57 var errorReporter = new ErrorReporter(errorListener, source); | 51 var errorReporter = new ErrorReporter(errorListener, source); |
58 var library = new _KernelLibraryBuilder(source.uri); | 52 var library = new _KernelLibraryBuilder(source.uri); |
59 var member = new _Builder(); | 53 var member = new _Builder(); |
60 var elementStore = new _ElementStore(); | 54 var elementStore = new _ElementStore(); |
61 var scope = new Scope.top(isModifiable: true); | 55 var scope = new Scope.top(isModifiable: true); |
62 | 56 |
63 AstBuilder astBuilder = new AstBuilder( | 57 AstBuilder astBuilder = new AstBuilder( |
64 errorReporter, library, member, elementStore, scope, true); | 58 errorReporter, library, member, elementStore, scope, true); |
65 fasta.Parser fastaParser = new fasta.Parser(astBuilder); | 59 fasta.Parser fastaParser = new fasta.Parser(astBuilder); |
66 astBuilder.parser = fastaParser; | 60 astBuilder.parser = fastaParser; |
67 return new _Parser2._(source, errorListener, fastaParser, astBuilder); | 61 return new _Parser2._(source, fastaParser, astBuilder); |
68 } | 62 } |
69 | 63 |
70 _Parser2._( | 64 _Parser2._(this._source, this._fastaParser, this._astBuilder); |
71 this._source, this._errorListener, this._fastaParser, this._astBuilder); | |
72 | 65 |
73 @override | 66 @override |
74 bool get parseGenericMethodComments => _astBuilder.parseGenericMethodComments; | 67 bool get parseGenericMethodComments => _astBuilder.parseGenericMethodComments; |
75 | 68 |
76 @override | 69 @override |
77 set parseGenericMethodComments(bool value) { | 70 set parseGenericMethodComments(bool value) { |
78 _astBuilder.parseGenericMethodComments = value; | 71 _astBuilder.parseGenericMethodComments = value; |
79 } | 72 } |
80 | 73 |
81 @override | 74 @override |
82 CompilationUnit parseCompilationUnit(Token token) { | 75 CompilationUnit parseCompilationUnit(Token token) { |
83 currentToken = token; | 76 currentToken = token; |
84 return parseCompilationUnit2(); | 77 return parseCompilationUnit2(); |
85 } | 78 } |
86 | 79 |
87 @override | 80 @override |
88 CompilationUnit parseCompilationUnit2() { | 81 CompilationUnit parseCompilationUnit2() { |
89 currentToken = _fastaParser.parseUnit(currentToken); | 82 currentToken = _fastaParser.parseUnit(currentToken); |
90 return _astBuilder.pop(); | 83 return _astBuilder.pop(); |
91 } | 84 } |
92 | 85 |
93 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 86 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
94 } | 87 } |
OLD | NEW |