Skip to content

Commit

Permalink
Merge branch 'main' into check-semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
L0P0P authored Jun 27, 2024
2 parents 3c4229f + 7125bb2 commit 8101f3f
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,23 @@
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);
Python3Lexer lexer = new Python3Lexer(cs);
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()),
Expand Down Expand Up @@ -71,7 +66,6 @@ public static void main(String[] args) {
} catch (Exception e) {
e.printStackTrace();
}
// }
}

private static String readFile(String filePath) throws IOException {
Expand Down

0 comments on commit 8101f3f

Please sign in to comment.