tested print
This commit is contained in:
@@ -35,6 +35,7 @@ public interface Interface{
|
||||
public S visitReturn(Return_instrImp instr, H h);
|
||||
public S visitAssign(AssignImp instr, H h);
|
||||
public S visitDeclaration(DeclarationImp instr,H h);
|
||||
public S visitPrint(PrintImp instr, H h);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,11 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitPrint(PrintImp instr, String indent) {
|
||||
return indent+ "PRINT \""+instr.t() +"\"";
|
||||
}
|
||||
|
||||
//EXPRESSION
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@ import TP2.asd.Interface.*;
|
||||
import TP2.llvm.ProgramLLVM.*;
|
||||
|
||||
public class Program{
|
||||
|
||||
//Prog
|
||||
public static record ProgramImp(ArrayList<Function> fonctions) implements ProgramI{
|
||||
public <H, S> S accept(ProgramVisitor<H, S> v, H h) {
|
||||
return v.visitProgram(this, h);
|
||||
@@ -23,7 +23,7 @@ public class Program{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Fonction
|
||||
public static record FunctionImp(Type type, String nom, ArrayList<Instruction> instructions)implements Function {
|
||||
public FunctionImp(Type type, String name, Instruction instruction) {
|
||||
this(type, name, new ArrayList<>() {{ add(instruction); }});
|
||||
@@ -34,14 +34,13 @@ public class Program{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Expression
|
||||
public static record ConstImp(int c) implements Expression{
|
||||
public <H, S> S accept(ExprVisitor<H, S> v, H h) {
|
||||
return v.visitConst(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static record BinopExpressionImp(Op op,Expression e1, Expression e2) implements Expression{
|
||||
public <H, S> S accept(ExprVisitor<H, S> v, H h) {
|
||||
return v.visitBinOp(this, h);
|
||||
@@ -54,15 +53,13 @@ public class Program{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Instructions
|
||||
public static record Return_instrImp(Expression e) implements Instruction{
|
||||
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
|
||||
return v.visitReturn(this,h);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static record AssignImp(String t, Expression e) implements Instruction{
|
||||
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
|
||||
return v.visitAssign(this, h);
|
||||
@@ -76,6 +73,13 @@ public class Program{
|
||||
}
|
||||
}
|
||||
|
||||
public static record PrintImp(String t) implements Instruction{
|
||||
@Override
|
||||
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
|
||||
return v.visitPrint(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
//Type
|
||||
public static record Type_voidImp() implements Type{
|
||||
@Override
|
||||
|
||||
@@ -11,5 +11,7 @@ public class test_symtable{
|
||||
//test_symTable.peppapeek();
|
||||
test_symTable.addVar("a", Type_intImp);
|
||||
System.out.print(test_symTable.print_all());
|
||||
String a =" addsqdqsdqs";
|
||||
a.substring(1, a.length()-1);
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,12 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImpl>
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<InstructionLLVM> visitPrint(PrintImp instr, SymTable h) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'visitPrint'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstrOrVal visitConst(ConstImp e, SymTable h) {
|
||||
ValLLVM val = new ValLLVMImpl(new IntLLVMImpl(),e.c());
|
||||
|
||||
Reference in New Issue
Block a user