prettyprinter en Visitor

This commit is contained in:
Rochas
2025-04-05 19:15:38 +02:00
parent 0a48bf22bf
commit 3f0ca04b19
3 changed files with 125 additions and 62 deletions

View File

@@ -16,24 +16,24 @@ public interface Interface{
}
public interface ProgramVisitor<H,S> {
public S visitProgram(ProgramImp programImp, H h);
public S visitProgram(ProgramImp prog, H h);
}
//////////Function
public interface Function {
public <H,S> S accept(FunctionVisitor<H,S> v, H h);
public String prettyprinter(String indent);
public DefineLLVM toLLVM();
}
public interface FunctionVisitor<H,S> {
public S visitFunction(FunctionImp e, H h);
public S visitFunction(FunctionImp fun, H h);
}
//////////Instruction
public interface Instruction {
public <H,S> S accept(InstrVisitor<H,S> v, H h);
public String prettyprinter(String indent);
public ArrayList<InstructionLLVM> toLLVM();
}
@@ -43,18 +43,19 @@ public interface Interface{
public S visitDeclaration(DeclarationImp e,H h);
}
//////////Expression
//We put prettyprinter here beause each expr will have to implement it like accept visitor
//but each implement will be different for prettyprinter
public interface Expression {
public <H,S> S accept(ExprVisitor<H,S> v, H h);
public String prettyprinter();
public ArrayList<AssignLVMImp> toLLVM();
}
public interface Val extends Expression{
public ValLLVM getValLLVM();
}
public ValLLVM getValLLVM();
}
public interface ExprVisitor<H,S> {
public S visitConst(ConstImp e,H h);
@@ -63,9 +64,17 @@ public interface Interface{
}
public interface Type{
public String prettyprinter();
public <H,S> S accept(TypeVisitor<H,S> v, H h);
public TypeLLVM toLLVM();
}
public interface TypeVisitor<H,S>{
public S visitInt(Type_intImp t, H h);
public S visitVoid(Type_voidImp t, H h);
}
public enum Op {PLUS, MINUS, TIMES, DIV, MOD}
}