c49cbae7f0
Change-Id: Iddd1e8a795bfaed0092a30bb9d83070fe62d4a60 Reviewed-on: https://dart-review.googlesource.com/7261 Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
33 lines
1.1 KiB
Java
33 lines
1.1 KiB
Java
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import org.antlr.runtime.*;
|
|
|
|
/// Class for `main` which will parse files given as command line arguments.
|
|
public class SpecParser {
|
|
static boolean verbose = false;
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
if (args.length == 0) {
|
|
System.err.println("Expected a file path as argument.");
|
|
System.exit(1);
|
|
}
|
|
for (int i = 0; i < args.length; i++) {
|
|
String filePath = args[i];
|
|
if (filePath.equals("--verbose")) {
|
|
verbose = true;
|
|
continue;
|
|
}
|
|
CharStream charStream = new ANTLRFileStream(filePath);
|
|
DartLexer lexer = new DartLexer(charStream);
|
|
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
|
DartParser parser = new DartParser(tokens);
|
|
DartParser.filePath = filePath;
|
|
DartParser.filePathHasBeenPrinted = false;
|
|
if (verbose) System.err.println(">>> Parsing file: " + filePath);
|
|
parser.libraryDefinition();
|
|
}
|
|
}
|
|
}
|