Ast Fixes

This commit is contained in:
Purplumbi 2024-05-08 14:08:24 +02:00
parent 91a3c3042d
commit c9ec426412
4 changed files with 8 additions and 3 deletions

View File

@ -16,7 +16,7 @@ public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
CharStream codeCharStream = null; CharStream codeCharStream = null;
try { try {
codeCharStream = CharStreams.fromPath(Paths.get("src/main/java/Example.java")); codeCharStream = CharStreams.fromPath(Paths.get("./Example.java"));
parsefile(codeCharStream); parsefile(codeCharStream);
} catch (IOException e) { } catch (IOException e) {
System.err.println("Error reading the file: " + e.getMessage()); System.err.println("Error reading the file: " + e.getMessage());

View File

@ -17,7 +17,7 @@ public class ClassNode extends ASTNode{
public void ensureConstructor(){ public void ensureConstructor(){
if(!hasConstructor) { if(!hasConstructor) {
ConstructorNode constructor = new ConstructorNode("public", name); ConstructorNode constructor = new ConstructorNode(new TypeNode("public"), name);
members.add(0,constructor); members.add(0,constructor);
} }
} }

View File

@ -1,7 +1,7 @@
package ast; package ast;
public class ConstructorNode extends MethodNode{ public class ConstructorNode extends MethodNode{
public ConstructorNode(String visibility, String name) { public ConstructorNode(TypeNode visibility, String name) {
super(visibility, name); super(visibility, name);
} }
} }

View File

@ -18,4 +18,9 @@ public class MethodNode extends MemberNode{
this.parameters = parameters; this.parameters = parameters;
this.statements = statements; this.statements = statements;
} }
public MethodNode(TypeNode visibility, String name){
this.visibility = visibility;
this.name = name;
}
} }