diff options
author | Emanuele Grasso <96300448+L0P0P@users.noreply.github.com> | 2024-06-27 12:05:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-27 12:05:17 +0200 |
commit | 8101f3f591f025c808084093d3f84b0eca0e67e5 (patch) | |
tree | 83186b06c304c24e2cee31762596c3eececb1862 | |
parent | 3c4229fc9e0ec6da9a7f60b57b9e93c49d1b6b6c (diff) | |
parent | 7125bb27fedaafd5a56b5122e4251b182448ddac (diff) |
Merge branch 'main' into check-semantics
-rw-r--r-- | src/Main.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/Main.java b/src/Main.java index c3c1cdd..24f4c4e 100644 --- a/src/Main.java +++ b/src/Main.java @@ -15,12 +15,15 @@ import semanticanalysis.*; public class Main { public static void main(String[] args) { + if (args.length != 1) { + System.err + .println( + "You must execute this program with a file parameter.\nUsage: java -cp lib/antlr-4.13.1-complete.jar:out Main <file.py>"); + return; + } - // for (File file : Objects.requireNonNull(new File("./progs/").listFiles())) { try { - // String fileStr = file.getPath(); - // FIXME: use the fileStr above - String fileStr = "./progs/a600.py"; + String fileStr = args[0]; System.out.println(fileStr); System.out.println(readFile(fileStr)); CharStream cs = CharStreams.fromFileName(fileStr); @@ -28,15 +31,7 @@ public class Main { CommonTokenStream tokens = new CommonTokenStream(lexer); Python3Parser parser = new Python3Parser(tokens); Python3Parser.RootContext tree = parser.root(); - // DEBUG - // { - // tokens.fill(); - // for (Token token : tokens.getTokens()) { - // System.out.println(token.toString()); - // } - // - // System.out.println("Tree: " + tree); - // } + JFrame frame = new JFrame("Parse Tree"); JPanel panel = new JPanel(); TreeViewer viewer = new TreeViewer(Arrays.asList(parser.getRuleNames()), @@ -71,7 +66,6 @@ public class Main { } catch (Exception e) { e.printStackTrace(); } - // } } private static String readFile(String filePath) throws IOException { |