| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 Token parseFunctionBody(Token token, bool isExpression) { | 94 Token parseFunctionBody(Token token, bool isExpression) { |
| 95 assert(!isExpression); | 95 assert(!isExpression); |
| 96 String value = token.stringValue; | 96 String value = token.stringValue; |
| 97 if (identical(value, ';')) { | 97 if (identical(value, ';')) { |
| 98 // No body. | 98 // No body. |
| 99 } else if (identical(value, '=>')) { | 99 } else if (identical(value, '=>')) { |
| 100 token = parseExpression(token.next); | 100 token = parseExpression(token.next); |
| 101 expectSemicolon(token); | 101 expectSemicolon(token); |
| 102 } else if (value === '=') { | 102 } else if (value == '=') { |
| 103 token = parseRedirectingFactoryBody(token); | 103 token = parseRedirectingFactoryBody(token); |
| 104 expectSemicolon(token); | 104 expectSemicolon(token); |
| 105 } else { | 105 } else { |
| 106 token = skipBlock(token); | 106 token = skipBlock(token); |
| 107 } | 107 } |
| 108 // There is no "skipped function body event", so we use | 108 // There is no "skipped function body event", so we use |
| 109 // handleNoFunctionBody instead. | 109 // handleNoFunctionBody instead. |
| 110 listener.handleNoFunctionBody(token); | 110 listener.handleNoFunctionBody(token); |
| 111 return token; | 111 return token; |
| 112 } | 112 } |
| 113 | 113 |
| 114 Token parseFormalParameters(Token token) => skipFormals(token); | 114 Token parseFormalParameters(Token token) => skipFormals(token); |
| 115 | 115 |
| 116 Token skipFormals(Token token) { | 116 Token skipFormals(Token token) { |
| 117 listener.beginOptionalFormalParameters(token); | 117 listener.beginOptionalFormalParameters(token); |
| 118 if (!optional('(', token)) { | 118 if (!optional('(', token)) { |
| 119 if (optional(';', token)) { | 119 if (optional(';', token)) { |
| 120 listener.recoverableError("expected '('", token: token); | 120 listener.recoverableError("expected '('", token: token); |
| 121 return token; | 121 return token; |
| 122 } | 122 } |
| 123 return listener.unexpected(token); | 123 return listener.unexpected(token); |
| 124 } | 124 } |
| 125 BeginGroupToken beginGroupToken = token; | 125 BeginGroupToken beginGroupToken = token; |
| 126 Token endToken = beginGroupToken.endGroup; | 126 Token endToken = beginGroupToken.endGroup; |
| 127 listener.endFormalParameters(0, token, endToken); | 127 listener.endFormalParameters(0, token, endToken); |
| 128 return endToken.next; | 128 return endToken.next; |
| 129 } | 129 } |
| 130 } | 130 } |
| OLD | NEW |