summaryrefslogtreecommitdiffstats
path: root/src/Compiler/Environment.java
diff options
context:
space:
mode:
authorAidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>2021-11-22 16:30:45 +0000
committerAidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>2021-11-22 16:30:45 +0000
commit8e368b67de60442c483bd9def7036e52562ccc81 (patch)
tree947d775285ad2df464177df8ec9e1d63e99cae0d /src/Compiler/Environment.java
parentab5584190b83a8cda9cbb3469ce841dbaa3aa38a (diff)
downloadesotericFORTRAN-8e368b67de60442c483bd9def7036e52562ccc81.tar.gz
esotericFORTRAN-8e368b67de60442c483bd9def7036e52562ccc81.zip
Improved error handing and added logical statements
Diffstat (limited to 'src/Compiler/Environment.java')
-rw-r--r--src/Compiler/Environment.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Compiler/Environment.java b/src/Compiler/Environment.java
index 3ccf425..1bb0e88 100644
--- a/src/Compiler/Environment.java
+++ b/src/Compiler/Environment.java
@@ -12,21 +12,20 @@ public class Environment {
}
//Get a variable if it is defined, or report an error
- public Object getVariable(String name){
- if(variableMap.containsKey(name)){
- return variableMap.get(name);
+ public Object getVariable(Token token){
+ if(variableMap.containsKey(token.text)){
+ return variableMap.get(token.text);
}
- Language.displayError("Undefined Variable");
+ Language.displayError(token,"Undefined Variable");
throw new Error();
}
- //Assign a value to an existing variable
- public void assignVariable(String name,Object value){
- if(variableMap.containsKey(name)){
- variableMap.put(name, value);
- return;
+ //Get a variable if it is defined, or report an error
+ public Boolean checkVariable(Token token){
+ if(variableMap.containsKey(token.text)){
+ return true;
}
- Language.displayError("Variable undefined");
+ Language.displayError(token,"Undefined Variable");
throw new Error();
}
}