package Compiler; import java.util.List; abstract class Statement { static class MainFunction extends Statement{ MainFunction(Statement block){ this.block = block; } final Statement block; @Override public String getStatmentType() { return "main"; } } static class Function extends Statement{ Function(Token name,Statement block,List arguments,List argumentTypes,String returnType){ this.block=block; this.arguments=arguments; this.returnType=returnType; this.argumentTypes=argumentTypes; this.name=name; } final Statement block; final List arguments; final List argumentTypes; final String returnType; final Token name; @Override public String getStatmentType() { return "function"; } } static class FunctionDeclaration extends Statement{ FunctionDeclaration(Token name,List argumentTypes,String returnType){ this.returnType=returnType; this.argumentTypes=argumentTypes; this.name=name; } final List argumentTypes; final String returnType; final Token name; @Override public String getStatmentType() { return "functionDec"; } } static class ReturnStatement extends Statement{ ReturnStatement(Expression returnValue){ this.returnValue=returnValue; } final Expression returnValue; @Override public String getStatmentType() { return "return"; } } static class ExpressionStatement extends Statement{ ExpressionStatement(Expression expr){ this.expr = expr; } final Expression expr; @Override public String getStatmentType() { return "exprStmt"; } } static class BlockStatement extends Statement{ BlockStatement(List statements){ this.statements=statements; } final List statements; @Override public String getStatmentType() { return "block"; } } static class IfStatement extends Statement{ IfStatement(Expression condition, Statement ifBlock,Statement elseBlock){ this.condition=condition; this.ifBlock=ifBlock; this.elseBlock=elseBlock; } final Expression condition; final Statement ifBlock; final Statement elseBlock; @Override public String getStatmentType() { return "ifStmt"; } } static class DoStatement extends Statement{ DoStatement(Expression variable, Expression start,Expression stop,Expression step,Statement codeBlock){ this.variable=variable; this.start=start; this.stop=stop; this.step=step; this.codeBlock=codeBlock; } final Expression variable; final Expression start; final Expression stop; final Expression step; final Statement codeBlock; @Override public String getStatmentType() { return "doStmt"; } } static class DoWhileStatement extends Statement{ DoWhileStatement(Expression condition,Statement codeBlock){ this.condition=condition; this.codeBlock=codeBlock; } final Expression condition; final Statement codeBlock; @Override public String getStatmentType() { return "dowhileStmt"; } } static class VariableDeclaration extends Statement{ VariableDeclaration(Token name,String type){ this.name=name; this.type=type; } final Token name; final String type; @Override public String getStatmentType() { return "varDec"; } } static class StringDeclaration extends Statement{ StringDeclaration(Token name,Expression length){ this.name=name; this.length=length; } final Token name; final Expression length; @Override public String getStatmentType() { return "stringDec"; } } static class ArrayDeclaration extends Statement{ ArrayDeclaration(Token name,String type,List dimensions){ this.name=name; this.dimensions=dimensions; this.type=type; } final String type; final Token name; final List dimensions; @Override public String getStatmentType() { return "arrayDec"; } } static class PrintStatement extends Statement{ PrintStatement(List exprList){ this.exprList=exprList; } final List exprList; @Override public String getStatmentType() { return "print"; } } public abstract String getStatmentType(); }