Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: tools/spec_parser/SpecParser.java

Issue 2688903004: Creating an ANTLR grammar for Dart, potentially the syntax spec.
Patch Set: Enabled parsing many files from one JVM process Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/spec_parser/Makefile ('k') | tools/spec_parser/SpecParserRunner.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/spec_parser/SpecParser.java
diff --git a/tools/spec_parser/SpecParser.java b/tools/spec_parser/SpecParser.java
new file mode 100644
index 0000000000000000000000000000000000000000..ad08cb2349d7d19810e2b9cfecc32c30cec08987
--- /dev/null
+++ b/tools/spec_parser/SpecParser.java
@@ -0,0 +1,32 @@
+// 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();
+ }
+ }
+}
« no previous file with comments | « tools/spec_parser/Makefile ('k') | tools/spec_parser/SpecParserRunner.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698