summaryrefslogtreecommitdiffstats
path: root/src/Compiler/Environment.java
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2021-11-22 18:46:42 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2021-11-22 18:46:42 +0000
commitde5022e778c12a8b91b905473f2f74bf7172eac3 (patch)
tree4f16f1cb0b6b75c0e8975bb77f432071684e57ed /src/Compiler/Environment.java
parent6557b7b080abab676cc15774bb4b4428e776cd03 (diff)
parent424ac34886895756525fbf5ddd704976e2e7d7dc (diff)
downloadesotericFORTRAN-de5022e778c12a8b91b905473f2f74bf7172eac3.tar.gz
esotericFORTRAN-de5022e778c12a8b91b905473f2f74bf7172eac3.zip
Merge branch 'main' of https://github.com/AlfieEagleton/EsotericProject into argparse
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();
}
}