diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 10322be..87d9828 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -16,7 +16,7 @@ public class Main { public static void main(String[] args) throws Exception { CharStream codeCharStream = null; try { - codeCharStream = CharStreams.fromPath(Paths.get("src/main/java/Example.java")); + codeCharStream = CharStreams.fromPath(Paths.get("./Example.java")); parsefile(codeCharStream); } catch (IOException e) { System.err.println("Error reading the file: " + e.getMessage()); diff --git a/src/main/java/ast/ClassNode.java b/src/main/java/ast/ClassNode.java index d9e2f04..7943b5a 100644 --- a/src/main/java/ast/ClassNode.java +++ b/src/main/java/ast/ClassNode.java @@ -17,7 +17,7 @@ public class ClassNode extends ASTNode{ public void ensureConstructor(){ if(!hasConstructor) { - ConstructorNode constructor = new ConstructorNode("public", name); + ConstructorNode constructor = new ConstructorNode(new TypeNode("public"), name); members.add(0,constructor); } } diff --git a/src/main/java/ast/ConstructorNode.java b/src/main/java/ast/ConstructorNode.java index 21c73ea..4aa194f 100644 --- a/src/main/java/ast/ConstructorNode.java +++ b/src/main/java/ast/ConstructorNode.java @@ -1,7 +1,7 @@ package ast; public class ConstructorNode extends MethodNode{ - public ConstructorNode(String visibility, String name) { + public ConstructorNode(TypeNode visibility, String name) { super(visibility, name); } } diff --git a/src/main/java/ast/MethodNode.java b/src/main/java/ast/MethodNode.java index daa970c..b8e15f2 100644 --- a/src/main/java/ast/MethodNode.java +++ b/src/main/java/ast/MethodNode.java @@ -18,4 +18,9 @@ public class MethodNode extends MemberNode{ this.parameters = parameters; this.statements = statements; } + + public MethodNode(TypeNode visibility, String name){ + this.visibility = visibility; + this.name = name; + } }