public static void main(String[] args){

		//The program take an optional command line parameter as base.
		if(args.length == 0){ // If the parameter is not specified, then use 10 as default value for base B.
			BASE = 10;
		} else { // If specified, use the parameter as the value for base B.
			BASE = Integer.parseInt(args[0]);
		}

		//Print which base the program use to do arithmetic operation.
		System.out.println("Now you are in base " + BASE);
		System.out.println("Please type in '-1' to end your input");
		
		int linenum; // Line number for command
		String cmd;	 // Command from console

		//Create a scanner object to take input from console
		Scanner in = new Scanner(System.in);

		while(in.hasNext()) {
			linenum = in.nextInt();  // Get the line number
			if(linenum == -1) break; // If input is -1, stop taking input 
			cmd = in.next();	// Get the next command
			cmdList.add(cmd);	// Add the command to command list
		}

		try {
			in.close();	// Close scanner after taking the input from console
		} catch (Exception e) {
			e.printStackTrace();
		}

		int line = 1; int repeat = 0; // Let line be the line number, repeat be the line number where a loop begins

		// Parse the commands from the first line to the last line
		while(line <= cmdList.size()){ 

			repeat = parse(cmdList.get(line-1)); // Parse one line of command

			if(repeat != 0) { // If there is a loop in the command, go to the line where the loop begins
				line = repeat;
			} else line++;   // Otherwise go to the next line
		}
	}