| 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) => skipClassBody(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 (value === '=' && token.next.stringValue === '{') { | 23 if (value === '=') { |
| 24 // Handle cases like this: | 24 var nextValue = token.next.stringValue; |
| 25 // class Foo { | 25 if (nextValue === 'const') { |
| 26 // var map; | 26 token = token.next; |
| 27 // Foo() : map = {}; | 27 nextValue = token.next.stringValue; |
| 28 // } | 28 } |
| 29 BeginGroupToken begin = token.next; | 29 if (nextValue === '{') { |
| 30 token = (begin.endGroup !== null) ? begin.endGroup : token; | 30 // Handle cases like this: |
| 31 token = token.next; | 31 // class Foo { |
| 32 continue; | 32 // var map; |
| 33 // Foo() : map = {}; |
| 34 // } |
| 35 BeginGroupToken begin = token.next; |
| 36 token = (begin.endGroup !== null) ? begin.endGroup : token; |
| 37 token = token.next; |
| 38 continue; |
| 39 } |
| 40 if (nextValue === '<') { |
| 41 // Handle cases like this: |
| 42 // class Foo { |
| 43 // var map; |
| 44 // Foo() : map = <Foo>{}; |
| 45 // } |
| 46 BeginGroupToken begin = token.next; |
| 47 token = (begin.endGroup !== null) ? begin.endGroup : token; |
| 48 token = token.next; |
| 49 if (token.stringValue === '{') { |
| 50 begin = token; |
| 51 token = (begin.endGroup !== null) ? begin.endGroup : token; |
| 52 token = token.next; |
| 53 } |
| 54 continue; |
| 55 } |
| 33 } | 56 } |
| 34 if (!mayParseFunctionExpressions && value === '{') | 57 if (!mayParseFunctionExpressions && value === '{') |
| 35 return token; | 58 return token; |
| 36 if ((value !== '<') && (token is BeginGroupToken)) { | 59 if ((value !== '<') && (token is BeginGroupToken)) { |
| 37 BeginGroupToken begin = token; | 60 BeginGroupToken begin = token; |
| 38 token = (begin.endGroup !== null) ? begin.endGroup : token; | 61 token = (begin.endGroup !== null) ? begin.endGroup : token; |
| 39 } | 62 } |
| 40 token = token.next; | 63 token = token.next; |
| 41 } | 64 } |
| 42 } | 65 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return token; | 101 return token; |
| 79 } | 102 } |
| 80 return listener.unexpected(token); | 103 return listener.unexpected(token); |
| 81 } | 104 } |
| 82 BeginGroupToken beginGroupToken = token; | 105 BeginGroupToken beginGroupToken = token; |
| 83 Token endToken = beginGroupToken.endGroup; | 106 Token endToken = beginGroupToken.endGroup; |
| 84 listener.endFormalParameters(0, token, endToken); | 107 listener.endFormalParameters(0, token, endToken); |
| 85 return endToken.next; | 108 return endToken.next; |
| 86 } | 109 } |
| 87 } | 110 } |
| OLD | NEW |