Ast Fixes
This commit is contained in:
parent
91a3c3042d
commit
c9ec426412
@ -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());
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user