package Compiler; import java.util.List; abstract class Statement { 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, BlockStatement ifBlock,BlockStatement elseBlock){ this.condition=condition; this.ifBlock=ifBlock; this.elseBlock=elseBlock; } final Expression condition; final BlockStatement ifBlock; final BlockStatement elseBlock; @Override public String getStatmentType() { return "ifStmt"; } } static class DoStatement extends Statement{ DoStatement(Expression variable, Expression start,Expression stop,Expression step,BlockStatement 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 BlockStatement codeBlock; @Override public String getStatmentType() { return "doStmt"; } } static class DoWhileStatement extends Statement{ DoWhileStatement(Expression condition,BlockStatement codeBlock){ this.condition=condition; this.codeBlock=codeBlock; } final Expression condition; final BlockStatement 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 PrintStatement extends Statement{ PrintStatement(List exprList){ this.exprList=exprList; } final List exprList; @Override public String getStatmentType() { return "print"; } } public abstract String getStatmentType(); }