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 part of scanner; | 5 part of scanner; |
6 | 6 |
7 class FormalParameterType { | 7 class FormalParameterType { |
8 final String type; | 8 final String type; |
9 const FormalParameterType(this.type); | 9 const FormalParameterType(this.type); |
10 bool get isRequired => this == REQUIRED; | 10 bool get isRequired => this == REQUIRED; |
(...skipping 25 matching lines...) Expand all Loading... |
36 * suffix can be one of "opt", or "star". "opt" means zero or one | 36 * suffix can be one of "opt", or "star". "opt" means zero or one |
37 * matches, "star" means zero or more matches. For example, | 37 * matches, "star" means zero or more matches. For example, |
38 * [parseMetadataStar] corresponds to this grammar snippet: [: | 38 * [parseMetadataStar] corresponds to this grammar snippet: [: |
39 * metadata* :], and [parseTypeOpt] corresponds to: [: type? :]. | 39 * metadata* :], and [parseTypeOpt] corresponds to: [: type? :]. |
40 */ | 40 */ |
41 class Parser { | 41 class Parser { |
42 final Listener listener; | 42 final Listener listener; |
43 bool mayParseFunctionExpressions = true; | 43 bool mayParseFunctionExpressions = true; |
44 bool yieldIsKeyword; | 44 bool yieldIsKeyword; |
45 bool awaitIsKeyword; | 45 bool awaitIsKeyword; |
| 46 bool allowAssertMessage; |
46 | 47 |
47 Parser(this.listener, | 48 Parser(this.listener, |
48 {this.yieldIsKeyword: false, this.awaitIsKeyword: false}); | 49 {this.yieldIsKeyword: false, |
| 50 this.awaitIsKeyword: false, |
| 51 this.allowAssertMessage: false}) { |
| 52 print("PARSER: $allowAssertMessage"); |
| 53 if (!allowAssertMessage) { |
| 54 try {throw 0;} catch(e,s) {print(s);} |
| 55 } |
| 56 } |
49 | 57 |
50 Token parseUnit(Token token) { | 58 Token parseUnit(Token token) { |
51 listener.beginCompilationUnit(token); | 59 listener.beginCompilationUnit(token); |
52 int count = 0; | 60 int count = 0; |
53 while (!identical(token.kind, EOF_TOKEN)) { | 61 while (!identical(token.kind, EOF_TOKEN)) { |
54 token = parseTopLevelDeclaration(token); | 62 token = parseTopLevelDeclaration(token); |
55 listener.endTopLevelDeclaration(token); | 63 listener.endTopLevelDeclaration(token); |
56 count++; | 64 count++; |
57 } | 65 } |
58 listener.endCompilationUnit(count, token); | 66 listener.endCompilationUnit(count, token); |
(...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 } | 2675 } |
2668 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2676 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
2669 return expectSemicolon(token); | 2677 return expectSemicolon(token); |
2670 } | 2678 } |
2671 | 2679 |
2672 Token parseEmptyStatement(Token token) { | 2680 Token parseEmptyStatement(Token token) { |
2673 listener.handleEmptyStatement(token); | 2681 listener.handleEmptyStatement(token); |
2674 return expectSemicolon(token); | 2682 return expectSemicolon(token); |
2675 } | 2683 } |
2676 } | 2684 } |
OLD | NEW |