print et Read en cours
This commit is contained in:
@@ -36,6 +36,7 @@ public interface Interface{
|
||||
public S visitAssign(AssignImp instr, H h);
|
||||
public S visitDeclaration(DeclarationImp instr,H h);
|
||||
public S visitPrint(PrintImp instr, H h);
|
||||
public S visitRead(ReadImp instr,H h);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,12 +61,24 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
@Override
|
||||
public String visitPrint(PrintImp instr, String indent) {
|
||||
String str = indent + "PRINT ";
|
||||
for (String elem: instr.t()){
|
||||
str += "\"" +elem +"\"";
|
||||
for(int i = 0; i<instr.t().size(); i++){
|
||||
String g = "";
|
||||
Object o = instr.t().get(i);
|
||||
if(o instanceof String){
|
||||
str += "\"" + instr.t().get(i) +"\"";
|
||||
}
|
||||
else if(o instanceof Expression){
|
||||
str += g + ((Expression)instr.t().get(i)).accept(this,"");
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitRead(ReadImp instr, String h) {
|
||||
return "Tibo, tu peux implenter le truc stp";
|
||||
}
|
||||
|
||||
//EXPRESSION
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,13 +74,20 @@ public class Program{
|
||||
}
|
||||
}
|
||||
|
||||
public static record PrintImp(ArrayList<String> t) implements Instruction{
|
||||
public static record PrintImp(ArrayList t) implements Instruction{
|
||||
@Override
|
||||
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
|
||||
return v.visitPrint(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
public static record ReadImp(ArrayList t) implements Instruction{
|
||||
@Override
|
||||
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
|
||||
return v.visitRead(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
//Type
|
||||
public static record Type_voidImp() implements Type{
|
||||
@Override
|
||||
|
||||
@@ -93,10 +93,19 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImpl>
|
||||
|
||||
@Override
|
||||
public ArrayList<InstructionLLVM> visitPrint(PrintImp instr, SymTable h) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'visitPrint'");
|
||||
ArrayList<InstructionLLVM> l = new ArrayList<>();
|
||||
l.add(new PrintLLVMImp(new ArrayList())); //TODO
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<InstructionLLVM> visitRead(ReadImp instr, SymTable h) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'visitRead'");
|
||||
}
|
||||
|
||||
//EXPRESSION
|
||||
|
||||
@Override
|
||||
public InstrAndVal visitConst(ConstImp e, SymTable h) {
|
||||
ValLLVM val = new ValLLVMImpl(new IntLLVMImpl(),e.c());
|
||||
|
||||
Reference in New Issue
Block a user