| 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 library fasta.parser.parser; | 5 library fasta.parser.parser; |
| 6 | 6 |
| 7 import '../fasta_codes.dart' show Code, Message, Template; | 7 import '../fasta_codes.dart' show Code, Message, Template; |
| 8 | 8 |
| 9 import '../fasta_codes.dart' as fasta; | 9 import '../fasta_codes.dart' as fasta; |
| 10 | 10 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 (token.next.isIdentifier || optional("void", token.next))) { | 254 (token.next.isIdentifier || optional("void", token.next))) { |
| 255 return parseTypedef(token); | 255 return parseTypedef(token); |
| 256 } else if (identical(value, 'library')) { | 256 } else if (identical(value, 'library')) { |
| 257 return parseLibraryName(token); | 257 return parseLibraryName(token); |
| 258 } else if (identical(value, 'import')) { | 258 } else if (identical(value, 'import')) { |
| 259 return parseImport(token); | 259 return parseImport(token); |
| 260 } else if (identical(value, 'export')) { | 260 } else if (identical(value, 'export')) { |
| 261 return parseExport(token); | 261 return parseExport(token); |
| 262 } else if (identical(value, 'part')) { | 262 } else if (identical(value, 'part')) { |
| 263 return parsePartOrPartOf(token); | 263 return parsePartOrPartOf(token); |
| 264 } else if (token.type == TokenType.IDENTIFIER || token.keyword != null) { |
| 265 return parseTopLevelMember(token); |
| 264 } else { | 266 } else { |
| 265 return parseTopLevelMember(token); | 267 reportRecoverableErrorWithToken(token, fasta.templateExpectedDeclaration); |
| 268 listener.handleInvalidTopLevelDeclaration(token); |
| 269 return token.next; |
| 266 } | 270 } |
| 267 } | 271 } |
| 268 | 272 |
| 269 /// library qualified ';' | 273 /// library qualified ';' |
| 270 Token parseLibraryName(Token token) { | 274 Token parseLibraryName(Token token) { |
| 271 Token libraryKeyword = token; | 275 Token libraryKeyword = token; |
| 272 listener.beginLibraryName(libraryKeyword); | 276 listener.beginLibraryName(libraryKeyword); |
| 273 assert(optional('library', token)); | 277 assert(optional('library', token)); |
| 274 token = parseQualified(token.next, IdentifierContext.libraryName, | 278 token = parseQualified(token.next, IdentifierContext.libraryName, |
| 275 IdentifierContext.libraryNameContinuation); | 279 IdentifierContext.libraryNameContinuation); |
| (...skipping 3785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4061 } | 4065 } |
| 4062 | 4066 |
| 4063 Token reportUnexpectedToken(Token token) { | 4067 Token reportUnexpectedToken(Token token) { |
| 4064 return reportUnrecoverableErrorWithToken( | 4068 return reportUnrecoverableErrorWithToken( |
| 4065 token, fasta.templateUnexpectedToken); | 4069 token, fasta.templateUnexpectedToken); |
| 4066 } | 4070 } |
| 4067 } | 4071 } |
| 4068 | 4072 |
| 4069 // TODO(ahe): Remove when analyzer supports generalized function syntax. | 4073 // TODO(ahe): Remove when analyzer supports generalized function syntax. |
| 4070 typedef _MessageWithArgument<T> = Message Function(T); | 4074 typedef _MessageWithArgument<T> = Message Function(T); |
| OLD | NEW |