Chromium Code Reviews| 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 (value == '=') { |
| 116 token = parseExpression(token.next); | |
| 117 expectSemicolon(token); | |
| 118 } else if (value == '=') { | |
| 119 token = parseRedirectingFactoryBody(token); | 137 token = parseRedirectingFactoryBody(token); |
| 120 expectSemicolon(token); | 138 expectSemicolon(token); |
| 121 } else { | 139 } else { |
| 122 token = skipBlock(token); | 140 if (identical(value, '=>')) { |
|
floitsch
2014/11/03 17:55:54
I prefer the 'else if' indentation.
Why this chan
Johnni Winther
2014/11/04 12:24:33
Done.
| |
| 141 token = parseExpression(token.next); | |
| 142 expectSemicolon(token); | |
| 143 } else { | |
| 144 token = skipBlock(token); | |
| 145 } | |
| 123 } | 146 } |
| 124 listener.skippedFunctionBody(token); | 147 listener.skippedFunctionBody(token); |
| 125 } | 148 } |
| 126 return token; | 149 return token; |
| 127 } | 150 } |
| 128 | 151 |
| 129 Token parseFormalParameters(Token token) => skipFormals(token); | 152 Token parseFormalParameters(Token token) => skipFormals(token); |
| 130 | 153 |
| 131 Token skipFormals(Token token) { | 154 Token skipFormals(Token token) { |
| 132 listener.beginOptionalFormalParameters(token); | 155 listener.beginOptionalFormalParameters(token); |
| 133 if (!optional('(', token)) { | 156 if (!optional('(', token)) { |
| 134 if (optional(';', token)) { | 157 if (optional(';', token)) { |
| 135 listener.recoverableError(token, "expected '('"); | 158 listener.recoverableError(token, "expected '('"); |
| 136 return token; | 159 return token; |
| 137 } | 160 } |
| 138 return listener.unexpected(token); | 161 return listener.unexpected(token); |
| 139 } | 162 } |
| 140 BeginGroupToken beginGroupToken = token; | 163 BeginGroupToken beginGroupToken = token; |
| 141 Token endToken = beginGroupToken.endGroup; | 164 Token endToken = beginGroupToken.endGroup; |
| 142 listener.endFormalParameters(0, token, endToken); | 165 listener.endFormalParameters(0, token, endToken); |
| 143 return endToken.next; | 166 return endToken.next; |
| 144 } | 167 } |
| 145 } | 168 } |
| OLD | NEW |