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 class FormalParameterType { | 7 class FormalParameterType { |
| 8 final String type; | 8 final String type; |
| 9 const FormalParameterType(this.type); | 9 const FormalParameterType(this.type); |
| 10 bool get isRequired => this == REQUIRED; | 10 bool get isRequired => this == REQUIRED; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 listener.endTopLevelDeclaration(token); | 52 listener.endTopLevelDeclaration(token); |
| 53 count++; | 53 count++; |
| 54 } | 54 } |
| 55 listener.endCompilationUnit(count, token); | 55 listener.endCompilationUnit(count, token); |
| 56 return token; | 56 return token; |
| 57 } | 57 } |
| 58 | 58 |
| 59 Token parseTopLevelDeclaration(Token token) { | 59 Token parseTopLevelDeclaration(Token token) { |
| 60 token = parseMetadataStar(token); | 60 token = parseMetadataStar(token); |
| 61 final String value = token.stringValue; | 61 final String value = token.stringValue; |
| 62 if ((identical(value, 'abstract') && optional('class', token.next)) | 62 if (identical(value, 'abstract') && optional('class', token.next)) { |
| 63 || identical(value, 'class')) { | |
| 64 return parseClass(token); | 63 return parseClass(token); |
| 64 } else if (identical(value, 'class')) { | |
| 65 return parseClassOrMixinApplication(token); | |
| 65 } else if (identical(value, 'typedef')) { | 66 } else if (identical(value, 'typedef')) { |
| 66 return parseTypedef(token); | 67 return parseTypedef(token); |
| 67 } else if (identical(value, 'library')) { | 68 } else if (identical(value, 'library')) { |
| 68 return parseLibraryName(token); | 69 return parseLibraryName(token); |
| 69 } else if (identical(value, 'import')) { | 70 } else if (identical(value, 'import')) { |
| 70 return parseImport(token); | 71 return parseImport(token); |
| 71 } else if (identical(value, 'export')) { | 72 } else if (identical(value, 'export')) { |
| 72 return parseExport(token); | 73 return parseExport(token); |
| 73 } else if (identical(value, 'part')) { | 74 } else if (identical(value, 'part')) { |
| 74 return parsePartOrPartOf(token); | 75 return parsePartOrPartOf(token); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 token = parseIdentifier(token.next); | 240 token = parseIdentifier(token.next); |
| 240 } | 241 } |
| 241 token = parseArgumentsOpt(token); | 242 token = parseArgumentsOpt(token); |
| 242 listener.endMetadata(atToken, period, token); | 243 listener.endMetadata(atToken, period, token); |
| 243 return token; | 244 return token; |
| 244 } | 245 } |
| 245 | 246 |
| 246 Token parseTypedef(Token token) { | 247 Token parseTypedef(Token token) { |
| 247 Token typedefKeyword = token; | 248 Token typedefKeyword = token; |
| 248 if (optional('=', peekAfterType(token.next))) { | 249 if (optional('=', peekAfterType(token.next))) { |
| 250 // TODO(aprelev@gmail.com): Remove deprecated 'typedef' mixin application. | |
| 249 listener.beginNamedMixinApplication(token); | 251 listener.beginNamedMixinApplication(token); |
| 250 token = parseIdentifier(token.next); | 252 token = parseIdentifier(token.next); |
| 251 token = parseTypeVariablesOpt(token); | 253 token = parseTypeVariablesOpt(token); |
| 252 token = expect('=', token); | 254 token = expect('=', token); |
| 253 token = parseModifiers(token); | 255 token = parseModifiers(token); |
| 254 token = parseMixinApplication(token); | 256 token = parseMixinApplication(token); |
| 255 Token implementsKeyword = null; | 257 Token implementsKeyword = null; |
| 256 if (optional('implements', token)) { | 258 if (optional('implements', token)) { |
| 257 implementsKeyword = token; | 259 implementsKeyword = token; |
| 258 token = parseTypeList(token.next); | 260 token = parseTypeList(token.next); |
| 259 } | 261 } |
| 260 listener.endNamedMixinApplication( | 262 listener.endNamedMixinApplication( |
| 261 typedefKeyword, implementsKeyword, token); | 263 typedefKeyword, implementsKeyword, token); |
| 262 } else { | 264 } else { |
| 263 listener.beginFunctionTypeAlias(token); | 265 listener.beginFunctionTypeAlias(token); |
| 264 token = parseReturnTypeOpt(token.next); | 266 token = parseReturnTypeOpt(token.next); |
| 265 token = parseIdentifier(token); | 267 token = parseIdentifier(token); |
| 266 token = parseTypeVariablesOpt(token); | 268 token = parseTypeVariablesOpt(token); |
| 267 token = parseFormalParameters(token); | 269 token = parseFormalParameters(token); |
| 268 listener.endFunctionTypeAlias(typedefKeyword, token); | 270 listener.endFunctionTypeAlias(typedefKeyword, token); |
| 269 } | 271 } |
| 270 return expect(';', token); | 272 return expect(';', token); |
| 271 } | 273 } |
| 272 | 274 |
| 275 | |
|
Johnni Winther
2013/10/10 07:29:56
Extra line.
aam-me
2013/10/11 03:02:06
Done.
| |
| 273 Token parseMixinApplication(Token token) { | 276 Token parseMixinApplication(Token token) { |
| 274 listener.beginMixinApplication(token); | 277 listener.beginMixinApplication(token); |
| 275 token = parseType(token); | 278 token = parseType(token); |
| 276 token = expect('with', token); | 279 token = expect('with', token); |
| 277 token = parseTypeList(token); | 280 token = parseTypeList(token); |
| 278 listener.endMixinApplication(); | 281 listener.endMixinApplication(); |
| 279 return token; | 282 return token; |
| 280 } | 283 } |
| 281 | 284 |
| 282 Token parseReturnTypeOpt(Token token) { | 285 Token parseReturnTypeOpt(Token token) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 BeginGroupToken beginGroupToken = token; | 449 BeginGroupToken beginGroupToken = token; |
| 447 Token endGroup = beginGroupToken.endGroup; | 450 Token endGroup = beginGroupToken.endGroup; |
| 448 if (endGroup == null) { | 451 if (endGroup == null) { |
| 449 return listener.unmatched(beginGroupToken); | 452 return listener.unmatched(beginGroupToken); |
| 450 } else if (!identical(endGroup.kind, $CLOSE_CURLY_BRACKET)) { | 453 } else if (!identical(endGroup.kind, $CLOSE_CURLY_BRACKET)) { |
| 451 return listener.unmatched(beginGroupToken); | 454 return listener.unmatched(beginGroupToken); |
| 452 } | 455 } |
| 453 return beginGroupToken.endGroup; | 456 return beginGroupToken.endGroup; |
| 454 } | 457 } |
| 455 | 458 |
| 459 Token parseClassOrMixinApplication(Token token) { | |
| 460 Token classKeyword = token; | |
| 461 if (optional('=', peekAfterType(token.next))) { | |
| 462 listener.beginNamedMixinApplication(token); | |
| 463 token = parseIdentifier(token.next); | |
| 464 token = parseTypeVariablesOpt(token); | |
| 465 token = expect('=', token); | |
| 466 token = parseModifiers(token); | |
|
Johnni Winther
2013/10/10 07:29:56
Modifiers should preceed the 'class' keyword:
abs
aam-me
2013/10/11 03:02:06
Done.
| |
| 467 token = parseMixinApplication(token); | |
| 468 Token implementsKeyword = null; | |
| 469 if (optional('implements', token)) { | |
| 470 implementsKeyword = token; | |
| 471 token = parseTypeList(token.next); | |
| 472 } | |
| 473 listener.endNamedMixinApplication( | |
| 474 classKeyword, implementsKeyword, token); | |
| 475 return expect(';', token); | |
| 476 } else { | |
| 477 return parseClass(token); | |
| 478 } | |
| 479 } | |
| 480 | |
| 456 Token parseClass(Token token) { | 481 Token parseClass(Token token) { |
| 457 Token begin = token; | 482 Token begin = token; |
| 458 listener.beginClassDeclaration(token); | 483 listener.beginClassDeclaration(token); |
| 459 int modifierCount = 0; | 484 int modifierCount = 0; |
| 460 if (optional('abstract', token)) { | 485 if (optional('abstract', token)) { |
| 461 listener.handleModifier(token); | 486 listener.handleModifier(token); |
| 462 modifierCount++; | 487 modifierCount++; |
| 463 token = token.next; | 488 token = token.next; |
| 464 } | 489 } |
| 465 listener.handleModifiers(modifierCount); | 490 listener.handleModifiers(modifierCount); |
| (...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2392 } | 2417 } |
| 2393 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2418 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2394 return expectSemicolon(token); | 2419 return expectSemicolon(token); |
| 2395 } | 2420 } |
| 2396 | 2421 |
| 2397 Token parseEmptyStatement(Token token) { | 2422 Token parseEmptyStatement(Token token) { |
| 2398 listener.handleEmptyStatement(token); | 2423 listener.handleEmptyStatement(token); |
| 2399 return expectSemicolon(token); | 2424 return expectSemicolon(token); |
| 2400 } | 2425 } |
| 2401 } | 2426 } |
| OLD | NEW |