From 9e6c89f1fa93287104381e02f0bbbdd6060a9382 Mon Sep 17 00:00:00 2001 From: AidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com> Date: Sun, 5 Dec 2021 03:27:18 +0000 Subject: Added subroutines and comments for most files --- src/Compiler/Environment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Compiler/Environment.java') diff --git a/src/Compiler/Environment.java b/src/Compiler/Environment.java index 1bb0e88..8ae8724 100644 --- a/src/Compiler/Environment.java +++ b/src/Compiler/Environment.java @@ -2,11 +2,13 @@ package Compiler; import java.util.HashMap; import java.util.Map; +/** + * Class to record defined variables during the translation stage + */ public class Environment { private final Map variableMap = new HashMap<>(); //Define a variable inside the current environment - //Maybe check if variable is already defined? public void defineVariable(String name,Object value){ variableMap.put(name, value); } @@ -20,7 +22,7 @@ public class Environment { throw new Error(); } - //Get a variable if it is defined, or report an error + //Check if a variable is defined, or report an error public Boolean checkVariable(Token token){ if(variableMap.containsKey(token.text)){ return true; -- cgit v1.2.3