| 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 class PartialParser extends Parser { | 5 class PartialParser extends Parser { |
| 6 PartialParser(Listener listener) : super(listener); | 6 PartialParser(Listener listener) : super(listener); |
| 7 | 7 |
| 8 Token parseClassBody(Token token) => skipBlock(token); | 8 Token parseClassBody(Token token) => skipBlock(token); |
| 9 | 9 |
| 10 Token fullParseClassBody(Token token) => super.parseClassBody(token); | 10 Token fullParseClassBody(Token token) => super.parseClassBody(token); |
| 11 | 11 |
| 12 Token parseExpression(Token token) => skipExpression(token); | |
| 13 | |
| 14 Token skipExpression(Token token) { | 12 Token skipExpression(Token token) { |
| 15 while (true) { | 13 while (true) { |
| 16 final kind = token.kind; | 14 final kind = token.kind; |
| 17 final value = token.stringValue; | 15 final value = token.stringValue; |
| 18 if ((kind === EOF_TOKEN) || | 16 if ((kind === EOF_TOKEN) || |
| 19 (value === ';') || | 17 (value === ';') || |
| 20 (value === ',') || | 18 (value === ',') || |
| 21 (value === ']')) | 19 (value === ']')) |
| 22 return token; | 20 return token; |
| 23 if (!mayParseFunctionExpressions && value === '{') | 21 if (!mayParseFunctionExpressions && value === '{') |
| 24 return token; | 22 return token; |
| 25 if ((value !== '<') && (token is BeginGroupToken)) { | 23 if ((value !== '<') && (token is BeginGroupToken)) { |
| 26 BeginGroupToken begin = token; | 24 BeginGroupToken begin = token; |
| 27 token = (begin.endGroup !== null) ? begin.endGroup : token; | 25 token = (begin.endGroup !== null) ? begin.endGroup : token; |
| 28 } | 26 } |
| 29 token = token.next; | 27 token = token.next; |
| 30 } | 28 } |
| 31 } | 29 } |
| 32 | 30 |
| 33 Token parseFunctionBody(Token token, bool isExpression) { | 31 Token parseFunctionBody(Token token, bool isExpression) { |
| 34 assert(!isExpression); | 32 assert(!isExpression); |
| 35 String value = token.stringValue; | 33 String value = token.stringValue; |
| 36 if (value === ';') { | 34 if (value === ';') { |
| 37 // No body. | 35 // No body. |
| 38 } else if (value === '=>') { | 36 } else if (value === '=>') { |
| 39 token = parseExpression(token.next); | 37 token = skipExpression(token.next); |
| 40 expectSemicolon(token); | 38 expectSemicolon(token); |
| 41 } else { | 39 } else { |
| 42 token = skipBlock(token); | 40 token = skipBlock(token); |
| 43 } | 41 } |
| 44 // There is no "skipped function body event", so we use | 42 // There is no "skipped function body event", so we use |
| 45 // handleNoFunctionBody instead. | 43 // handleNoFunctionBody instead. |
| 46 listener.handleNoFunctionBody(token); | 44 listener.handleNoFunctionBody(token); |
| 47 return token; | 45 return token; |
| 48 } | 46 } |
| 49 | 47 |
| 50 Token parseFormalParameters(Token token) => skipFormals(token); | 48 Token parseFormalParameters(Token token) => skipFormals(token); |
| 51 | 49 |
| 52 Token skipFormals(BeginGroupToken token) { | 50 Token skipFormals(BeginGroupToken token) { |
| 53 listener.beginOptionalFormalParameters(token); | 51 listener.beginOptionalFormalParameters(token); |
| 54 expect('(', token); | 52 expect('(', token); |
| 55 Token endToken = token.endGroup; | 53 Token endToken = token.endGroup; |
| 56 listener.endFormalParameters(0, token, endToken); | 54 listener.endFormalParameters(0, token, endToken); |
| 57 return endToken.next; | 55 return endToken.next; |
| 58 } | 56 } |
| 59 } | 57 } |
| OLD | NEW |