This commit is contained in:
Vu Tuan Minh
2025-04-09 16:32:19 +02:00
4 changed files with 6 additions and 6 deletions

View File

@@ -110,7 +110,7 @@ instruction returns [Instruction out]:
read.add(new VarImp($i1.out)); read.add(new VarImp($i1.out));
}(VIRGULE i2=ident }(VIRGULE i2=ident
{ {
read.add(new VarImp($i1.out)); read.add(new VarImp($i2.out));
})* })*
{$out = new ReadImp(read);} {$out = new ReadImp(read);}

View File

@@ -78,7 +78,7 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
public String visitRead(ReadImp instr, String indent) { public String visitRead(ReadImp instr, String indent) {
String str = indent+"READ "; String str = indent+"READ ";
for(int i = 0; i<instr.t().size(); i++){ for(int i = 0; i<instr.t().size(); i++){
str += instr.t().get(i);//.accept(this,h); str += instr.t().get(i).accept(this,indent);
if(i<instr.t().size()-1) str += ", "; if(i<instr.t().size()-1) str += ", ";
} }
return str; return str;

View File

@@ -43,7 +43,7 @@ public class SymTable {
public Result addNewTempVar(/*Type type*/){ public Result addNewTempVar(/*Type type*/){
//TODO //TODO
String newVar = "temp"+getNewId(); String newVar = "temp"+id;
SymTable newSymTab = this.addVar(newVar,new Type_intImp()); //TODO SymTable newSymTab = this.addVar(newVar,new Type_intImp()); //TODO
return new Result(newSymTab,newVar); return new Result(newSymTab,newVar);
} }
@@ -72,7 +72,7 @@ public class SymTable {
pmap= pmap.plus(s/*+"_"+this.id*/,new ValueTable(t, getNewId())); pmap= pmap.plus(s/*+"_"+this.id*/,new ValueTable(t, getNewId()));
//this.id++; //this.id++;
//Delete old ones //Delete old ones
newpstack = newpstack.minus(stackMap.indexOf(stackMap.getLast())); newpstack = newpstack.minus(newpstack.indexOf(newpstack.getLast()));
//Push the new one //Push the new one
newpstack = newpstack.plus(pmap); newpstack = newpstack.plus(pmap);
return new SymTable(newpstack,this.id); return new SymTable(newpstack,this.id);

View File

@@ -2,6 +2,6 @@ FUNC INT main() {
INT a,b,c INT a,b,c
b:=3 b:=3
c:=1 c:=1
PRINT "coucou, tu peux réparer le visitPrint dans LLVM stp","il manque virgule au milieu" PRINT "coucou, tu peux réparer le visitPrint dans LLVM stp","il manque virgule au milieu", c*5+b
READ a, b READ a, b, n, t, m
RETURN 4 + 6 * 5 + 2 } RETURN 4 + 6 * 5 + 2 }