error 3
This commit is contained in:
@@ -8,7 +8,7 @@ import org.antlr.runtime.CharStream;
|
||||
import org.antlr.runtime.CommonTokenStream;
|
||||
import org.antlr.runtime.RecognitionException;
|
||||
|
||||
import TP2.asd.*;
|
||||
import TP2.asd.Program.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
@@ -32,7 +32,7 @@ public class Main {
|
||||
VSLParser parser = new VSLParser(tokens);
|
||||
|
||||
// Parse
|
||||
ProgramImpl ast = parser.program();
|
||||
ProgramImp ast = parser.program();
|
||||
|
||||
// Pretty-print the program (to debug parsing)
|
||||
System.err.println("todo " + ast);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package TP2.asd;
|
||||
|
||||
import java.util.Map;
|
||||
import TP2.asd.Program.*;
|
||||
|
||||
public interface Interface{
|
||||
public interface Expression {
|
||||
@@ -12,17 +13,17 @@ public interface Interface{
|
||||
}
|
||||
|
||||
public interface ProgramVisitor<H,S> {
|
||||
public S visitProgram(Program p, H h);
|
||||
public S visitFunction(Program.Function f, H h);
|
||||
public S visitProgram(ProgramImp p, H h);
|
||||
public S visitFunction(Function f, H h);
|
||||
}
|
||||
|
||||
public interface InstrVisitor<H,S>{
|
||||
public S visitReturn(Program.Return_instr e, H h);
|
||||
public S visitReturn(Return_instr e, H h);
|
||||
}
|
||||
|
||||
public interface ExprVisitor<H,S> {
|
||||
public S visitConst(Program.Const e,H h);
|
||||
public S visitBinOp(Program.BinopExpression e, H h);
|
||||
public S visitConst(Const e,H h);
|
||||
public S visitBinOp(BinopExpression e, H h);
|
||||
}
|
||||
|
||||
public interface Type{
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package TP2.asd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import TP2.asd.Interface.*;
|
||||
|
||||
public class Program{
|
||||
public static record ProgramImp(ArrayList<Instruction> instructions){
|
||||
public <H, S> S accept(ProgramVisitor<H, S> v, H h) {
|
||||
return v.visitProgram(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
public static record Function(Type type, String nom, ArrayList<Instruction> instructions){
|
||||
public Function(Type type, String name, Instruction instruction) {
|
||||
this(type, name, new ArrayList<>() {{ add(instruction); }});
|
||||
|
||||
Reference in New Issue
Block a user