package com.example;

import com.example.Models.Expressions.ArithmeticExpression;
import com.example.Models.Expressions.ReadHeap;
import com.example.Models.Expressions.RelationalExpression;
import com.example.Models.Expressions.ValueExpression;
import com.example.Models.Expressions.VariableExpression;
import com.example.Models.Statements.AquireStatement;
import com.example.Models.Statements.AssignmentStatement;
import com.example.Models.Statements.CloseReadFileStatement;
import com.example.Models.Statements.CompoundStatement;
import com.example.Models.Statements.CreateSemaphore;
import com.example.Models.Statements.ForkStatement;
import com.example.Models.Statements.IStatement;
import com.example.Models.Statements.IfStatement;
import com.example.Models.Statements.NewStatement;
import com.example.Models.Statements.OpenReadFileStatement;
import com.example.Models.Statements.PrintStatement;
import com.example.Models.Statements.ReadFileStatement;
import com.example.Models.Statements.ReleaseStatement;
import com.example.Models.Statements.SwitchStatement;
import com.example.Models.Statements.VariableDeclarationStatement;
import com.example.Models.Statements.WhileStatement;
import com.example.Models.Statements.WriteHeap;
import com.example.Models.Types.BooleanType;
import com.example.Models.Types.IntegerType;
import com.example.Models.Types.ReferenceType;
import com.example.Models.Types.StringType;
import com.example.Models.Values.BooleanValue;
import com.example.Models.Values.IntegerValue;
import com.example.Models.Values.StringValue;

public class Examples{
    public static IStatement[] exampleList() {
        IStatement ex1= new CompoundStatement(new VariableDeclarationStatement("v", new IntegerType()), new CompoundStatement(new AssignmentStatement("v", new ValueExpression(new IntegerValue((2)))), new PrintStatement(new VariableExpression(("v")))));
        
        IStatement ex2 = new CompoundStatement( new VariableDeclarationStatement("a",new IntegerType()),
        new CompoundStatement(new VariableDeclarationStatement("b",new IntegerType()),
        new CompoundStatement(new AssignmentStatement("a", new ArithmeticExpression('+',new ValueExpression(new IntegerValue(2)),new
        ArithmeticExpression('*',new ValueExpression(new IntegerValue(3)), new ValueExpression(new IntegerValue(5))))),
            new CompoundStatement(new AssignmentStatement("b",new ArithmeticExpression('+',new VariableExpression("a"), new ValueExpression(new
        IntegerValue(1)))), new PrintStatement(new VariableExpression("b"))))));
         
        IStatement ex3 = new CompoundStatement(new VariableDeclarationStatement("a",new BooleanType()),
        new CompoundStatement(new VariableDeclarationStatement("v", new IntegerType()),
        new CompoundStatement(new AssignmentStatement("a", new ValueExpression(new BooleanValue(true))),
        new CompoundStatement(new IfStatement(new VariableExpression("a"),new AssignmentStatement("v",new ValueExpression(new
        IntegerValue(2))), new AssignmentStatement("v", new ValueExpression(new IntegerValue(3)))), new PrintStatement(new
        VariableExpression("v"))))));

        IStatement ex4 = new CompoundStatement(new VariableDeclarationStatement("varf", new StringType()), new CompoundStatement(new AssignmentStatement("varf", new ValueExpression(new StringValue("test.in"))), new CompoundStatement(new OpenReadFileStatement(new VariableExpression("varf")), new CompoundStatement(new VariableDeclarationStatement("varc", new IntegerType()), new CompoundStatement(new ReadFileStatement(new VariableExpression("varf"), "varc"), new CompoundStatement(new PrintStatement(new VariableExpression("varc")), new CompoundStatement(new ReadFileStatement(new VariableExpression("varf"), "varc"), new CompoundStatement(new PrintStatement(new VariableExpression("varc")), new CloseReadFileStatement(new VariableExpression("varf"))))))))));
        
        IStatement ex5 = new CompoundStatement(new IfStatement(new RelationalExpression(new ValueExpression(new IntegerValue(1)), new ValueExpression(new IntegerValue(2)), "<"), new PrintStatement(new ValueExpression(new IntegerValue(1))),new PrintStatement(new ValueExpression(new IntegerValue(2)))), new PrintStatement(new ValueExpression(new IntegerValue(3))));
        
        IStatement ex6 = new CompoundStatement(new VariableDeclarationStatement("v", new ReferenceType(new IntegerType())), new CompoundStatement(new NewStatement("v", new ValueExpression(new IntegerValue(20))), new CompoundStatement(new VariableDeclarationStatement("a", new ReferenceType(new ReferenceType(new IntegerType()))), new CompoundStatement(new NewStatement("a", new VariableExpression("v")), new CompoundStatement(new NewStatement("v", new ValueExpression(new IntegerValue(30))), new PrintStatement(new ReadHeap(new ReadHeap(new VariableExpression("a")))))))));
        
        IStatement ex7 = new CompoundStatement(new VariableDeclarationStatement("v", new ReferenceType(new IntegerType())), new CompoundStatement(new NewStatement("v", new ValueExpression(new IntegerValue(10))), new CompoundStatement(new NewStatement("v", new ValueExpression(new IntegerValue(20))), new PrintStatement(new VariableExpression("v")))));
        
        IStatement ex8 = new CompoundStatement(new VariableDeclarationStatement("v", new IntegerType()), new CompoundStatement(new AssignmentStatement("v", new ValueExpression(new IntegerValue(4))), new CompoundStatement(new WhileStatement(new CompoundStatement(new PrintStatement(new VariableExpression("v")), new AssignmentStatement("v", new ArithmeticExpression('-', new VariableExpression("v"), new ValueExpression(new IntegerValue(1))))), new RelationalExpression(new VariableExpression("v"), new ValueExpression(new IntegerValue(0)), ">")), new PrintStatement(new VariableExpression("v")))));
        
        IStatement ex9 = new CompoundStatement(new VariableDeclarationStatement("v", new IntegerType()), new CompoundStatement(new VariableDeclarationStatement("a", new ReferenceType(new IntegerType())), new CompoundStatement(new AssignmentStatement("v", new ValueExpression(new IntegerValue(10))), new CompoundStatement(new NewStatement("a", new ValueExpression(new IntegerValue(22))), new CompoundStatement(new ForkStatement(new CompoundStatement(new WriteHeap("a", new ValueExpression(new IntegerValue(30))), new CompoundStatement(new AssignmentStatement("v", new ValueExpression(new IntegerValue(32))), new CompoundStatement(new PrintStatement(new VariableExpression("v")), new PrintStatement(new ReadHeap(new VariableExpression("a"))))))), new CompoundStatement(new PrintStatement(new VariableExpression("v")), new PrintStatement(new ReadHeap(new VariableExpression("a")))))))));
        
        IStatement ex10 = new CompoundStatement(new VariableDeclarationStatement("v1", new ReferenceType(new IntegerType())), new CompoundStatement(new VariableDeclarationStatement("cnt", new IntegerType()), new CompoundStatement(new NewStatement("v1", new ValueExpression(new IntegerValue(1))), new CompoundStatement(new CreateSemaphore("cnt", new ReadHeap(new VariableExpression("v1"))), new CompoundStatement(new ForkStatement(new CompoundStatement(new AquireStatement("cnt"), new CompoundStatement(new WriteHeap("v1", new ArithmeticExpression('*', new ReadHeap(new VariableExpression("v1")), new ValueExpression(new IntegerValue(10)))), new CompoundStatement(new PrintStatement(new ReadHeap(new VariableExpression("v1"))), new ReleaseStatement("cnt"))))), new CompoundStatement(new ForkStatement(new CompoundStatement(new AquireStatement("cnt"), new CompoundStatement(new WriteHeap("v1",new ArithmeticExpression('*', new ReadHeap(new VariableExpression("v1")), new ValueExpression(new IntegerValue(10)))), new CompoundStatement(new WriteHeap("v1", new ArithmeticExpression('*', new ReadHeap(new VariableExpression("v1")), new ValueExpression(new IntegerValue(2)))), new CompoundStatement(new PrintStatement(new ReadHeap(new VariableExpression("v1"))), new ReleaseStatement("cnt")))))), new CompoundStatement(new AquireStatement("cnt"), new CompoundStatement(new PrintStatement(new ArithmeticExpression('-', new ReadHeap(new VariableExpression("v1")), new ValueExpression(new IntegerValue(1)))), new ReleaseStatement("cnt")))))))));

        IStatement ex11 = new CompoundStatement(new VariableDeclarationStatement("a", new IntegerType()), new CompoundStatement(new VariableDeclarationStatement("b", new IntegerType()), new CompoundStatement(new VariableDeclarationStatement("c", new IntegerType()), new CompoundStatement(new AssignmentStatement("a", new ValueExpression(new IntegerValue(1))), new CompoundStatement(new AssignmentStatement("b", new ValueExpression(new IntegerValue(2))), new CompoundStatement(new AssignmentStatement("c", new ValueExpression(new IntegerValue(5))), new CompoundStatement(new SwitchStatement(new ArithmeticExpression('*', new VariableExpression("a"), new ValueExpression(new IntegerValue(10))), new ArithmeticExpression('*', new VariableExpression("b"), new VariableExpression("c")), new ValueExpression(new IntegerValue(10)), new CompoundStatement(new PrintStatement(new VariableExpression("a")), new PrintStatement(new VariableExpression("b"))), new CompoundStatement(new PrintStatement(new ValueExpression(new IntegerValue(100))), new PrintStatement(new ValueExpression(new IntegerValue(200)))), new PrintStatement(new ValueExpression(new IntegerValue(300)))), new PrintStatement(new ValueExpression(new IntegerValue(300))))))))));

        return new IStatement[]{ex1, ex2, ex3, ex4, ex5, ex6, ex7, ex8, ex9, ex10, ex11};

    }
}