| 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) => skipClassBody(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); | 12 Token parseExpression(Token token) => skipExpression(token); |
| 13 | 13 |
| 14 Token skipExpression(Token token) { | 14 Token skipExpression(Token token) { |
| 15 while (true) { | 15 while (true) { |
| 16 final kind = token.kind; | 16 final kind = token.kind; |
| 17 final value = token.stringValue; | 17 final value = token.stringValue; |
| 18 if ((kind === EOF_TOKEN) || | 18 if ((kind === EOF_TOKEN) || |
| 19 (value === ';') || | 19 (value === ';') || |
| 20 (value === ',') || | 20 (value === ',') || |
| 21 (value === ']')) | 21 (value === ']')) |
| 22 return token; | 22 return token; |
| 23 if (!mayParseFunctionExpressions && value === '{') | 23 if (!mayParseFunctionExpressions && value === '{') |
| 24 return token; | 24 return token; |
| 25 if ((value !== '<') && (token is BeginGroupToken)) { | 25 if ((value !== '<') && (token is BeginGroupToken)) { |
| 26 BeginGroupToken begin = token; | 26 BeginGroupToken begin = token; |
| 27 token = (begin.endGroup !== null) ? begin.endGroup : token; | 27 token = (begin.endGroup !== null) ? begin.endGroup : token; |
| 28 } | 28 } |
| 29 token = token.next; | 29 token = token.next; |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 Token skipClassBody(Token token) { |
| 34 if (!optional('{', token)) { |
| 35 return listener.expectedClassBodyToSkip(token); |
| 36 } |
| 37 BeginGroupToken beginGroupToken = token; |
| 38 assert(beginGroupToken.endGroup === null || |
| 39 beginGroupToken.endGroup.kind === $CLOSE_CURLY_BRACKET); |
| 40 return beginGroupToken.endGroup; |
| 41 } |
| 42 |
| 33 Token parseFunctionBody(Token token, bool isExpression) { | 43 Token parseFunctionBody(Token token, bool isExpression) { |
| 34 assert(!isExpression); | 44 assert(!isExpression); |
| 35 String value = token.stringValue; | 45 String value = token.stringValue; |
| 36 if (value === ';') { | 46 if (value === ';') { |
| 37 // No body. | 47 // No body. |
| 38 } else if (value === '=>') { | 48 } else if (value === '=>') { |
| 39 token = parseExpression(token.next); | 49 token = parseExpression(token.next); |
| 40 expectSemicolon(token); | 50 expectSemicolon(token); |
| 41 } else { | 51 } else { |
| 42 token = skipBlock(token); | 52 token = skipBlock(token); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 57 return token; | 67 return token; |
| 58 } | 68 } |
| 59 return listener.unexpected(token); | 69 return listener.unexpected(token); |
| 60 } | 70 } |
| 61 BeginGroupToken beginGroupToken = token; | 71 BeginGroupToken beginGroupToken = token; |
| 62 Token endToken = beginGroupToken.endGroup; | 72 Token endToken = beginGroupToken.endGroup; |
| 63 listener.endFormalParameters(0, token, endToken); | 73 listener.endFormalParameters(0, token, endToken); |
| 64 return endToken.next; | 74 return endToken.next; |
| 65 } | 75 } |
| 66 } | 76 } |
| OLD | NEW |