Hi all... I've been working on this project for a while and now I think I need some help sorting out what I'm doing since I seem to have lost track of my original idea and gotten a bit mixed up. >.< I'm tring to create an interpreter for a basic programming language, which has 8 reserved words and is strictly linear. So I have the source file read into an ArrayList with each line being a String, and then split each String with String.split() into 2 and stored in the array called parts; the first word which is always a reserved word and the second bit holds everything else. Basically each line in the program to be interpreted can be boiled down to KEYWORD+ instructions e.g. LET myString="xxx" or INTEGER myInt. The program only deals with ints and Strings.

Right now I've got it designed so that when the parser method gets the reserved word, it maps to a HashMap with classes that are supposed to continue the processing of the instructions, e.g. the PRINTLN keyword when found by the parser maps to the PRINTLN class that will print out whatever is after the PRINTLN keyword. All variables must be declared before being assigned a value. The program needs to be able to store and remember values for previously declared variables e.g. it has to remember that the variable x has the value of 10-- so now I have another HashMap called variables for that.

My current issue is that I need to get it to auto-populate the variables hashmap with the name of the variable and the value whenever the program finds a variable to instantiate; not too sure how I'm supposed to get that working. I know I should make a call to the addVariables() method everytime that happens, but where is the proper place for hte method, inside the keyword statement classes, or inside the class that instantiates the variables HashMap? Any help is much appreciated.

Java Code:
/*--------------------------------------------------------------------------------------------------------------------
*							 HashMap for variables
*---------------------------------------------------------------------------------------------------------------------
*/
	
	class TPLVariables  
	{  
		private Map<String, TPLVariable> variables = new HashMap<String, TPLVariable>();  
  
		public void addVariable(String declaration)  
		{  
        // Parses the declaration String, create a TPLVariable of the appropriate type   
        // and add it to the map using the variable name as the key 
		
		if(//insert some condition here)
		{
			TPLString stringDeclaration= new TPLString(declaration);
		}
		else
		{
			TPLInteger integerDeclaration= new TPLInteger(declaration);
		}
		
			
		}  
  
		public TPLVariable getVariable(String name)  
		{  
			// This will return the requested variable or null if it doesn't exist 
			variables.get(declaration, ());	
		}
		
		public void storeVariables()
		variables.put(declaration, new TPLVariable());
	}  



public class StringStatement implements Directive
	{	/**	StringStatement implements the STRING keyword as defined in class TPLString.
		*	This keyword declares a String variable.
		*	A declared String is empty when first instantiated.
		*/
	
		public void execute(String[] parts)
		{
			//instantiate a TPLString
			String declaration=parts[1];
			
			variables.addVariable(declaration);//add variable to variables hashmap
		}
	}