| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 Token skipExpression(Token token) { | 28 Token skipExpression(Token token) { |
| 29 while (true) { | 29 while (true) { |
| 30 final kind = token.kind; | 30 final kind = token.kind; |
| 31 final value = token.stringValue; | 31 final value = token.stringValue; |
| 32 if ((identical(kind, EOF_TOKEN)) || | 32 if ((identical(kind, EOF_TOKEN)) || |
| 33 (identical(value, ';')) || | 33 (identical(value, ';')) || |
| 34 (identical(value, ',')) || | 34 (identical(value, ',')) || |
| 35 (identical(value, ']'))) | 35 (identical(value, ']'))) |
| 36 return token; | 36 return token; |
| 37 if (identical(value, '=')) { | 37 if (identical(value, '=') || |
| 38 identical(value, '?') || |
| 39 identical(value, ':')) { |
| 38 var nextValue = token.next.stringValue; | 40 var nextValue = token.next.stringValue; |
| 39 if (identical(nextValue, 'const')) { | 41 if (identical(nextValue, 'const')) { |
| 40 token = token.next; | 42 token = token.next; |
| 41 nextValue = token.next.stringValue; | 43 nextValue = token.next.stringValue; |
| 42 } | 44 } |
| 43 if (identical(nextValue, '{')) { | 45 if (identical(nextValue, '{')) { |
| 44 // Handle cases like this: | 46 // Handle cases like this: |
| 45 // class Foo { | 47 // class Foo { |
| 46 // var map; | 48 // var map; |
| 47 // Foo() : map = {}; | 49 // Foo() : map = {}; |
| 50 // Foo.x() : map = true ? {} : {}; |
| 48 // } | 51 // } |
| 49 BeginGroupToken begin = token.next; | 52 BeginGroupToken begin = token.next; |
| 50 token = (begin.endGroup != null) ? begin.endGroup : token; | 53 token = (begin.endGroup != null) ? begin.endGroup : token; |
| 51 token = token.next; | 54 token = token.next; |
| 52 continue; | 55 continue; |
| 53 } | 56 } |
| 54 if (identical(nextValue, '<')) { | 57 if (identical(nextValue, '<')) { |
| 55 // Handle cases like this: | 58 // Handle cases like this: |
| 56 // class Foo { | 59 // class Foo { |
| 57 // var map; | 60 // var map; |
| 58 // Foo() : map = <String, Foo>{}; | 61 // Foo() : map = <String, Foo>{}; |
| 62 // Foo.x() : map = true ? <String, Foo>{} : <String, Foo>{}; |
| 59 // } | 63 // } |
| 60 BeginGroupToken begin = token.next; | 64 BeginGroupToken begin = token.next; |
| 61 token = (begin.endGroup != null) ? begin.endGroup : token; | 65 token = (begin.endGroup != null) ? begin.endGroup : token; |
| 62 token = token.next; | 66 token = token.next; |
| 63 if (identical(token.stringValue, '{')) { | 67 if (identical(token.stringValue, '{')) { |
| 64 begin = token; | 68 begin = token; |
| 65 token = (begin.endGroup != null) ? begin.endGroup : token; | 69 token = (begin.endGroup != null) ? begin.endGroup : token; |
| 66 token = token.next; | 70 token = token.next; |
| 67 } | 71 } |
| 68 continue; | 72 continue; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return token; | 125 return token; |
| 122 } | 126 } |
| 123 return listener.unexpected(token); | 127 return listener.unexpected(token); |
| 124 } | 128 } |
| 125 BeginGroupToken beginGroupToken = token; | 129 BeginGroupToken beginGroupToken = token; |
| 126 Token endToken = beginGroupToken.endGroup; | 130 Token endToken = beginGroupToken.endGroup; |
| 127 listener.endFormalParameters(0, token, endToken); | 131 listener.endFormalParameters(0, token, endToken); |
| 128 return endToken.next; | 132 return endToken.next; |
| 129 } | 133 } |
| 130 } | 134 } |
| OLD | NEW |