import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Compiler {
	static Pattern relation_pattern = Pattern.compile("(.+)(>|<|>=|<=|==|!=)+(.+)");
	static Pattern expression_pattern = Pattern.compile("([a-zA-Z0-9+-*/()]+)");

	Scanner scanner;
	int[] memory;
	ArrayList<Integer> constants;
	HashMap<Integer, Integer> line_numbers;
	HashMap<String, Integer> variables;
	int line_number, pointer, data_pointer;

	public Compiler(File file) throws FileNotFoundException {
		scanner = new Scanner(file);
		memory = new int[100];
		constants = new ArrayList<Integer>();
		line_numbers = new HashMap<Integer, Integer>();
		variables = new HashMap<String, Integer>();
		line_number = 0;
		pointer = 0;
		data_pointer = 99;
	}

	public int[] compile() {
		while(scanner.hasNextLine()) {
			if(pointer >= data_pointer)
				throw new OutOfMemoryException();

			String[] command = scanner.nextLine().split(" ");

			int next_line_number = Integer.parseInt(command[0]);
			if(next_line_number <= line_number)
				throw new LineNumberException();
			line_numbers.put(next_line_number, pointer);
			line_number = next_line_number;

			if(command[1].equalsIgnoreCase("rem")) //Ingore comment lines
				continue;
			else if(command[1].equalsIgnoreCase("input")) { //Make a new variable and remember it
				if(!Character.isLetter(command[2].charAt(0)))
					throw new InvalidVariableException();

				variables.put(command[2], data_pointer);
				memory[pointer] = 1000 + data_pointer;
				data_pointer--;
			}
			else if(command[1].equalsIgnoreCase("print")) { //Simply print variable
				if(!variables.containsKey(command[2]))
					throw new UndefinedVariableException();

				memory[pointer] = 1100 + variables.get(command[2]);
			}
			else if(command[1].equalsIgnoreCase("let")) { //If a variable doesn't exist, create it then parse the expression
				if(!variables.containsKey(command[2])) {
					variables.put(command[2], data_pointer);
					data_pointer--;
				}

				parseExpression(command[3], variables.get(command[2]));
			}
			else if(command[1].equalsIgnoreCase("goto")) { //Put a new goto
				memory[pointer] = 4000 + Integer.parseInt(command[2]);
			}
			else if(command[1].equalsIgnoreCase("if")) { //Yay for if's
				if(!command[3].equalsIgnoreCase("goto"))
					throw new IllegalArgumentException();
				parseRelation(command[2]);//Call parse relation
				memory[pointer] = 4100 + Integer.parseInt(command[4]);//Branch 0 to "goto"
			}
			else if(command[1].equalsIgnoreCase("end")) //Put a halt
				memory[pointer] = 4300;

			pointer++;
		}
	}

	private void parseRelation(String relation) {
		Matcher matcher = relation_pattern.matcher(relation);
		if(!matcher.matches())
			throw new SyntaxException();
	}

	private void parseExpression(String expression, int value_pointer) {
		Matcher matcher = expression_pattern.matcher(expression);
		if(!matcher.matches())
			throw new SyntaxException();
	}
}

@@ -1057,17 +1057,114 @@
 it(%22 %22);
-%0A
+ //Everything is separated by spaces%0A%0A%09%09%09//Double check line numbers and save each one as a symbol
 %0A%09%09%09int 
@@ -1417,18 +1417,18 @@
 m%22)) //I
-n
 g
+n
 ore comm
@@ -2554,16 +2554,17 @@
 tion();%0A
+%0A
 %09%09%09%09pars
@@ -2585,16 +2585,17 @@
 and%5B2%5D);
+ 
 //Call p
@@ -2666,16 +2666,17 @@
 and%5B4%5D);
+ 
 //Branch
@@ -2847,24 +2847,61 @@
 relation) %7B%0A
+%09%09//Check relations based on regexes%0A
 %09%09Matcher ma
@@ -3001,24 +3001,24 @@
 tion();%0A%09%7D%0A%0A
-
 %09private voi
@@ -3075,16 +3075,55 @@
 nter) %7B%0A
+%09%09//Check expressions based on regexes%0A
 %09%09Matche

Tidy up