| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library fasta.parser.main; | |
| 6 | |
| 7 import 'dart:convert' show LineSplitter, UTF8; | |
| 8 | |
| 9 import 'dart:io' show File; | |
| 10 | |
| 11 import '../scanner/token.dart' show Token; | |
| 12 | |
| 13 import '../scanner/io.dart' show readBytesFromFileSync; | |
| 14 | |
| 15 import '../scanner.dart' show scan; | |
| 16 | |
| 17 import 'listener.dart' show Listener; | |
| 18 | |
| 19 import 'top_level_parser.dart' show TopLevelParser; | |
| 20 | |
| 21 import 'identifier_context.dart' show IdentifierContext; | |
| 22 | |
| 23 class DebugListener extends Listener { | |
| 24 void handleIdentifier(Token token, IdentifierContext context) { | |
| 25 logEvent("Identifier: ${token.value}"); | |
| 26 } | |
| 27 | |
| 28 void logEvent(String name) { | |
| 29 print(name); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 main(List<String> arguments) async { | |
| 34 for (String argument in arguments) { | |
| 35 if (argument.startsWith("@")) { | |
| 36 Uri uri = Uri.base.resolve(argument.substring(1)); | |
| 37 await for (String file in new File.fromUri(uri) | |
| 38 .openRead() | |
| 39 .transform(UTF8.decoder) | |
| 40 .transform(const LineSplitter())) { | |
| 41 outLine(uri.resolve(file)); | |
| 42 } | |
| 43 } else { | |
| 44 outLine(Uri.base.resolve(argument)); | |
| 45 } | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 void outLine(Uri uri) { | |
| 50 new TopLevelParser(new DebugListener()) | |
| 51 .parseUnit(scan(readBytesFromFileSync(uri)).tokens); | |
| 52 } | |
| OLD | NEW |