moitie gragment 0
This commit is contained in:
@@ -17,6 +17,7 @@ public class Eval {
|
||||
case Op.MINUS: return e.e1().accept(this, h)-e.e2().accept(this, h);
|
||||
case Op.TIMES: return e.e1().accept(this, h)*e.e2().accept(this, h);
|
||||
case Op.DIV: return e.e1().accept(this, h)/e.e2().accept(this, h);
|
||||
case Op.MOD: return e.e1().accept(this, h)%e.e2().accept(this, h);
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
@@ -29,6 +30,13 @@ public class Eval {
|
||||
ExprEval exprEval = new ExprEval();
|
||||
return e.e().accept(exprEval, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitAssign(AssignImp e, Map<String, Integer> h) {
|
||||
//h.put(e.i(), e.t());
|
||||
//TODO
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public interface Interface{
|
||||
|
||||
public interface InstrVisitor<H,S>{
|
||||
public S visitReturn(Return_instrImp e, H h);
|
||||
public S visitAssign(AssignImp e, H h);
|
||||
}
|
||||
|
||||
public interface ExprVisitor<H,S> {
|
||||
@@ -41,12 +42,5 @@ public interface Interface{
|
||||
public String prettyprinter();
|
||||
}
|
||||
|
||||
public enum Op {PLUS, MINUS, TIMES, DIV,MOD}
|
||||
|
||||
//Eval
|
||||
public interface ExprEval extends ExprVisitor<Map<String, Integer>, Integer> {
|
||||
}
|
||||
|
||||
public interface TypeCheck extends ExprVisitor<Map<String, Type>, Type> {
|
||||
}
|
||||
public enum Op {PLUS, MINUS, TIMES, DIV, MOD}
|
||||
}
|
||||
@@ -42,6 +42,11 @@ public class Program{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static record Type_voidImp() implements Type{
|
||||
public String prettyprinter() {
|
||||
@@ -88,6 +93,12 @@ public class Program{
|
||||
ExprEval exprEval = new ExprEval();
|
||||
return e.e().accept(exprEval, h);
|
||||
}
|
||||
@Override
|
||||
public Integer visitAssign(AssignImp e, Map<String, Integer> h) {
|
||||
//h.put(e.t(), e.e());
|
||||
//TODO
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExprEval implements ExprVisitor<Map<String,Integer>,Integer>{
|
||||
|
||||
Reference in New Issue
Block a user