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, true); | 269 token = parseModifiers(token); |
| 270 listener.endNamedMixinApplication(typedefKeyword, token); | 270 token = parseMixinApplication(token); |
| 271 Token implementsKeyword = null; | |
| 272 if (optional('implements', token)) { | |
| 273 implementsKeyword = token; | |
| 274 token = parseTypeList(token.next); | |
| 275 } | |
| 276 listener.endNamedMixinApplication( | |
| 277 typedefKeyword, implementsKeyword, token); | |
| 271 } else { | 278 } else { |
| 272 listener.beginFunctionTypeAlias(token); | 279 listener.beginFunctionTypeAlias(token); |
| 273 token = parseReturnTypeOpt(token.next); | 280 token = parseReturnTypeOpt(token.next); |
| 274 token = parseIdentifier(token); | 281 token = parseIdentifier(token); |
| 275 token = parseTypeVariablesOpt(token); | 282 token = parseTypeVariablesOpt(token); |
| 276 token = parseFormalParameters(token); | 283 token = parseFormalParameters(token); |
| 277 listener.endFunctionTypeAlias(typedefKeyword, token); | 284 listener.endFunctionTypeAlias(typedefKeyword, token); |
| 278 } | 285 } |
| 279 return expect(';', token); | 286 return expect(';', token); |
| 280 } | 287 } |
| 281 | 288 |
| 282 Token parseMixinApplication(Token token, bool isTypedef) { | 289 Token parseMixinApplication(Token token) { |
|
Johnni Winther
2013/01/24 08:33:18
Good to get rid of this :)
| |
| 283 listener.beginMixinApplication(token); | 290 listener.beginMixinApplication(token); |
| 284 if (isTypedef) { | |
| 285 token = parseModifiers(token); | |
| 286 } else { | |
| 287 listener.handleModifiers(0); | |
| 288 } | |
| 289 token = parseType(token); | 291 token = parseType(token); |
| 290 token = expect('with', token); | 292 token = expect('with', token); |
| 291 token = parseTypeList(token); | 293 token = parseTypeList(token); |
| 292 listener.endMixinApplication(); | 294 listener.endMixinApplication(); |
| 293 return token; | 295 return token; |
| 294 } | 296 } |
| 295 | 297 |
| 296 Token parseReturnTypeOpt(Token token) { | 298 Token parseReturnTypeOpt(Token token) { |
| 297 if (identical(token.stringValue, 'void')) { | 299 if (identical(token.stringValue, 'void')) { |
| 298 listener.handleVoidKeyword(token); | 300 listener.handleVoidKeyword(token); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 modifierCount++; | 484 modifierCount++; |
| 483 token = token.next; | 485 token = token.next; |
| 484 } | 486 } |
| 485 listener.handleModifiers(modifierCount); | 487 listener.handleModifiers(modifierCount); |
| 486 token = parseIdentifier(token.next); | 488 token = parseIdentifier(token.next); |
| 487 token = parseTypeVariablesOpt(token); | 489 token = parseTypeVariablesOpt(token); |
| 488 Token extendsKeyword; | 490 Token extendsKeyword; |
| 489 if (optional('extends', token)) { | 491 if (optional('extends', token)) { |
| 490 extendsKeyword = token; | 492 extendsKeyword = token; |
| 491 if (optional('with', token.next.next)) { | 493 if (optional('with', token.next.next)) { |
| 492 token = parseMixinApplication(token.next, false); | 494 token = parseMixinApplication(token.next); |
| 493 } else { | 495 } else { |
| 494 token = parseType(token.next); | 496 token = parseType(token.next); |
| 495 } | 497 } |
| 496 } else { | 498 } else { |
| 497 extendsKeyword = null; | 499 extendsKeyword = null; |
| 498 listener.handleNoType(token); | 500 listener.handleNoType(token); |
| 499 } | 501 } |
| 500 Token implementsKeyword; | 502 Token implementsKeyword; |
| 501 int interfacesCount = 0; | 503 int interfacesCount = 0; |
| 502 if (optional('implements', token)) { | 504 if (optional('implements', token)) { |
| (...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2195 } | 2197 } |
| 2196 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2198 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2197 return expectSemicolon(token); | 2199 return expectSemicolon(token); |
| 2198 } | 2200 } |
| 2199 | 2201 |
| 2200 Token parseEmptyStatement(Token token) { | 2202 Token parseEmptyStatement(Token token) { |
| 2201 listener.handleEmptyStatement(token); | 2203 listener.handleEmptyStatement(token); |
| 2202 return expectSemicolon(token); | 2204 return expectSemicolon(token); |
| 2203 } | 2205 } |
| 2204 } | 2206 } |
| OLD | NEW |