Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 7 /** |
| 8 * An event generating parser of Dart programs. This parser expects | 8 * An event generating parser of Dart programs. This parser expects |
| 9 * all tokens in a linked list (aka a token stream). | 9 * all tokens in a linked list (aka a token stream). |
| 10 * | 10 * |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 return parseClassBody(token); | 259 return parseClassBody(token); |
| 260 } | 260 } |
| 261 | 261 |
| 262 Token parseTypedef(Token token) { | 262 Token parseTypedef(Token token) { |
| 263 Token typedefKeyword = token; | 263 Token typedefKeyword = token; |
| 264 if (optional('=', peekAfterType(token.next))) { | 264 if (optional('=', peekAfterType(token.next))) { |
| 265 listener.beginNamedMixinApplication(token); | 265 listener.beginNamedMixinApplication(token); |
| 266 token = parseIdentifier(token.next); | 266 token = parseIdentifier(token.next); |
| 267 token = parseTypeVariablesOpt(token); | 267 token = parseTypeVariablesOpt(token); |
| 268 token = expect('=', token); | 268 token = expect('=', token); |
| 269 token = parseMixinApplication(token); | 269 token = parseMixinApplication(token, true); |
| 270 listener.endNamedMixinApplication(typedefKeyword, token); | 270 listener.endNamedMixinApplication(typedefKeyword, token); |
| 271 } else { | 271 } else { |
| 272 listener.beginFunctionTypeAlias(token); | 272 listener.beginFunctionTypeAlias(token); |
| 273 token = parseReturnTypeOpt(token.next); | 273 token = parseReturnTypeOpt(token.next); |
| 274 token = parseIdentifier(token); | 274 token = parseIdentifier(token); |
| 275 token = parseTypeVariablesOpt(token); | 275 token = parseTypeVariablesOpt(token); |
| 276 token = parseFormalParameters(token); | 276 token = parseFormalParameters(token); |
| 277 listener.endFunctionTypeAlias(typedefKeyword, token); | 277 listener.endFunctionTypeAlias(typedefKeyword, token); |
| 278 } | 278 } |
| 279 return expect(';', token); | 279 return expect(';', token); |
| 280 } | 280 } |
| 281 | 281 |
| 282 Token parseMixinApplication(Token token) { | 282 Token parseMixinApplication(Token token, bool isTypedef) { |
|
Johnni Winther
2013/01/21 11:15:22
Make isTypedef a named parameter. Helps reading ca
kasperl
2013/01/21 11:16:30
Only problem is that I'd prefer not to make it opt
| |
| 283 listener.beginMixinApplication(token); | 283 listener.beginMixinApplication(token); |
| 284 token = parseModifiers(token); | 284 if (isTypedef) { |
| 285 token = parseModifiers(token); | |
| 286 } else { | |
| 287 listener.handleModifiers(0); | |
| 288 } | |
| 285 token = parseType(token); | 289 token = parseType(token); |
| 286 token = expect('with', token); | 290 token = expect('with', token); |
| 287 token = parseTypeList(token); | 291 token = parseTypeList(token); |
| 288 listener.endMixinApplication(); | 292 listener.endMixinApplication(); |
| 289 return token; | 293 return token; |
| 290 } | 294 } |
| 291 | 295 |
| 292 Token parseReturnTypeOpt(Token token) { | 296 Token parseReturnTypeOpt(Token token) { |
| 293 if (identical(token.stringValue, 'void')) { | 297 if (identical(token.stringValue, 'void')) { |
| 294 listener.handleVoidKeyword(token); | 298 listener.handleVoidKeyword(token); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 modifierCount++; | 482 modifierCount++; |
| 479 token = token.next; | 483 token = token.next; |
| 480 } | 484 } |
| 481 listener.handleModifiers(modifierCount); | 485 listener.handleModifiers(modifierCount); |
| 482 token = parseIdentifier(token.next); | 486 token = parseIdentifier(token.next); |
| 483 token = parseTypeVariablesOpt(token); | 487 token = parseTypeVariablesOpt(token); |
| 484 Token extendsKeyword; | 488 Token extendsKeyword; |
| 485 if (optional('extends', token)) { | 489 if (optional('extends', token)) { |
| 486 extendsKeyword = token; | 490 extendsKeyword = token; |
| 487 if (optional('with', token.next.next)) { | 491 if (optional('with', token.next.next)) { |
| 488 // TODO(kasperl): Disallow modifiers here. | 492 token = parseMixinApplication(token.next, false); |
| 489 token = parseMixinApplication(token.next); | |
| 490 } else { | 493 } else { |
| 491 token = parseType(token.next); | 494 token = parseType(token.next); |
| 492 } | 495 } |
| 493 } else { | 496 } else { |
| 494 extendsKeyword = null; | 497 extendsKeyword = null; |
| 495 listener.handleNoType(token); | 498 listener.handleNoType(token); |
| 496 } | 499 } |
| 497 Token implementsKeyword; | 500 Token implementsKeyword; |
| 498 int interfacesCount = 0; | 501 int interfacesCount = 0; |
| 499 if (optional('implements', token)) { | 502 if (optional('implements', token)) { |
| (...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2192 } | 2195 } |
| 2193 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2196 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2194 return expectSemicolon(token); | 2197 return expectSemicolon(token); |
| 2195 } | 2198 } |
| 2196 | 2199 |
| 2197 Token parseEmptyStatement(Token token) { | 2200 Token parseEmptyStatement(Token token) { |
| 2198 listener.handleEmptyStatement(token); | 2201 listener.handleEmptyStatement(token); |
| 2199 return expectSemicolon(token); | 2202 return expectSemicolon(token); |
| 2200 } | 2203 } |
| 2201 } | 2204 } |
| OLD | NEW |