diff options
author | AidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com> | 2021-12-04 05:24:43 +0000 |
---|---|---|
committer | AidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com> | 2021-12-04 05:24:43 +0000 |
commit | 43909b350b9084ed33f121a15c5770224cbdc79f (patch) | |
tree | aff7f471784fbb1d1a3597acfeb43624d4ed94ad /src/Compiler/Statement.java | |
parent | cc1f6e712520793d5a8c638a6e995c018917eadb (diff) | |
download | esotericFORTRAN-43909b350b9084ed33f121a15c5770224cbdc79f.tar.gz esotericFORTRAN-43909b350b9084ed33f121a15c5770224cbdc79f.zip |
Added basic function support
Diffstat (limited to 'src/Compiler/Statement.java')
-rw-r--r-- | src/Compiler/Statement.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/Compiler/Statement.java b/src/Compiler/Statement.java index a4fbff7..dd3ff04 100644 --- a/src/Compiler/Statement.java +++ b/src/Compiler/Statement.java @@ -4,6 +4,73 @@ 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<Expression> arguments,List<String> argumentTypes,String returnType){ + this.block=block; + this.arguments=arguments; + this.returnType=returnType; + this.argumentTypes=argumentTypes; + this.name=name; + } + + final Statement block; + final List<Expression> arguments; + final List<String> argumentTypes; + final String returnType; + final Token name; + + @Override + public String getStatmentType() { + return "function"; + } + } + + static class FunctionDeclaration extends Statement{ + FunctionDeclaration(Token name,List<String> argumentTypes,String returnType){ + this.returnType=returnType; + this.argumentTypes=argumentTypes; + this.name=name; + } + + final List<String> 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; |