| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 PartialParser extends Parser { | 7 class PartialParser extends Parser { |
| 8 PartialParser(Listener listener) : super(listener); | 8 PartialParser(Listener listener) : super(listener); |
| 9 | 9 |
| 10 Token parseClassBody(Token token) => skipClassBody(token); | 10 Token parseClassBody(Token token) => skipClassBody(token); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 BeginGroupToken beginGroupToken = token; | 96 BeginGroupToken beginGroupToken = token; |
| 97 Token endGroup = beginGroupToken.endGroup; | 97 Token endGroup = beginGroupToken.endGroup; |
| 98 if (endGroup == null) { | 98 if (endGroup == null) { |
| 99 return listener.unmatched(beginGroupToken); | 99 return listener.unmatched(beginGroupToken); |
| 100 } else if (!identical(endGroup.kind, $CLOSE_CURLY_BRACKET)) { | 100 } else if (!identical(endGroup.kind, $CLOSE_CURLY_BRACKET)) { |
| 101 return listener.unmatched(beginGroupToken); | 101 return listener.unmatched(beginGroupToken); |
| 102 } | 102 } |
| 103 return endGroup; | 103 return endGroup; |
| 104 } | 104 } |
| 105 | 105 |
| 106 Token skipAsyncModifier(Token token) { |
| 107 String value = token.stringValue; |
| 108 if (identical(value, 'async')) { |
| 109 token = token.next; |
| 110 value = token.stringValue; |
| 111 |
| 112 if (identical(value, '*')) { |
| 113 token = token.next; |
| 114 } |
| 115 } else if (identical(value, 'sync')) { |
| 116 token = token.next; |
| 117 value = token.stringValue; |
| 118 |
| 119 if (identical(value, '*')) { |
| 120 token = token.next; |
| 121 } |
| 122 } |
| 123 return token; |
| 124 } |
| 125 |
| 106 Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) { | 126 Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) { |
| 107 assert(!isExpression); | 127 assert(!isExpression); |
| 128 token = skipAsyncModifier(token); |
| 108 String value = token.stringValue; | 129 String value = token.stringValue; |
| 109 if (identical(value, ';')) { | 130 if (identical(value, ';')) { |
| 110 if (!allowAbstract) { | 131 if (!allowAbstract) { |
| 111 listener.reportError(token, MessageKind.BODY_EXPECTED); | 132 listener.reportError(token, MessageKind.BODY_EXPECTED); |
| 112 } | 133 } |
| 113 listener.handleNoFunctionBody(token); | 134 listener.handleNoFunctionBody(token); |
| 114 } else { | 135 } else { |
| 115 if (identical(value, '=>')) { | 136 if (identical(value, '=>')) { |
| 116 token = parseExpression(token.next); | 137 token = parseExpression(token.next); |
| 117 expectSemicolon(token); | 138 expectSemicolon(token); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 136 return token; | 157 return token; |
| 137 } | 158 } |
| 138 return listener.unexpected(token); | 159 return listener.unexpected(token); |
| 139 } | 160 } |
| 140 BeginGroupToken beginGroupToken = token; | 161 BeginGroupToken beginGroupToken = token; |
| 141 Token endToken = beginGroupToken.endGroup; | 162 Token endToken = beginGroupToken.endGroup; |
| 142 listener.endFormalParameters(0, token, endToken); | 163 listener.endFormalParameters(0, token, endToken); |
| 143 return endToken.next; | 164 return endToken.next; |
| 144 } | 165 } |
| 145 } | 166 } |
| OLD | NEW |