HW08-JRollinson/Parser.java
public void advance()
    {

        currentCommand = commands.nextLine();
        argument1 = ""; //initialize arg1
        argument2 = -1; //initialize arg2

        String[] segment = currentCommand.split(" ");

        if (segment.length > 3)
        {
            throw new IllegalArgumentException("ERROR: Too many arguments!");
        }
        if (arithmeticCmds.contains(segment[0]))
        {
            argumentType = ARITHMETIC;
            argument1 = segment[0];
        }
        else if (segment[0].equals("return")) 
        {
            argumentType = RETURN;
            argument1 = segment[0];
        }
        else 
        {
            argument1 = segment[1];

            if(segment[0].equals("push"))
            {
                argumentType = PUSH;
            }
            else if(segment[0].equals("pop"))
            {
                argumentType = POP;
            }
            else if(segment[0].equals("label"))
            {
                argumentType = LABEL;
            }
            else if(segment[0].equals("if"))
            {
                argumentType = IF;
            }
            else if (segment[0].equals("goto"))
            {
                argumentType = GOTO;
            }
            else if (segment[0].equals("function"))
            {
                argumentType = FUNCTION;
            }
            else if (segment[0].equals("call"))
            {
                argumentType = CALL;
            }
            else 
            {
                throw new IllegalArgumentException("Unknown Command Type!");
            }
            if (argumentType == PUSH || argumentType == POP || argumentType == FUNCTION || argumentType == CALL)
            {
                try 
                {
                    argument2 = Integer.parseInt(segment[2]);
                }
                catch (Exception e)
                {
                	e.getMessage();
                	e.printStackTrace();
                    throw new IllegalArgumentException("ERROR: argument2 is not an integer!");
                }
            }
        }
    }
// POST-CONDITION: currentCommand has been updated to the line that was just read.

POST-CONDITION: currentCommand has been updated to the line that was just read.
POST - CONDITION : currentCommand has been updated to the line that was just read .
public void advance()
    {
        currentCommand = commands.nextLine();
        argument1 = ""; 
        argument2 = -1; 
        String[] segment = currentCommand.split(" ");
        if (segment.length > 3)
        {
            throw new IllegalArgumentException("ERROR: Too many arguments!");
        }
        if (arithmeticCmds.contains(segment[0]))
        {
            argumentType = ARITHMETIC;
            argument1 = segment[0];
        }
        else if (segment[0].equals("return")) 
        {
            argumentType = RETURN;
            argument1 = segment[0];
        }
        else 
        {
            argument1 = segment[1];
            if(segment[0].equals("push"))
            {
                argumentType = PUSH;
            }
            else if(segment[0].equals("pop"))
            {
                argumentType = POP;
            }
            else if(segment[0].equals("label"))
            {
                argumentType = LABEL;
            }
            else if(segment[0].equals("if"))
            {
                argumentType = IF;
            }
            else if (segment[0].equals("goto"))
            {
                argumentType = GOTO;
            }
            else if (segment[0].equals("function"))
            {
                argumentType = FUNCTION;
            }
            else if (segment[0].equals("call"))
            {
                argumentType = CALL;
            }
            else 
            {
                throw new IllegalArgumentException("Unknown Command Type!");
            }
            if (argumentType == PUSH || argumentType == POP || argumentType == FUNCTION || argumentType == CALL)
            {
                try 
                {
                    argument2 = Integer.parseInt(segment[2]);
                }
                catch (Exception e)
                {
                	e.getMessage();
                	e.printStackTrace();
                    throw new IllegalArgumentException("ERROR: argument2 is not an integer!");
                }
            }
        }
    }
public void advance ( ) { currentCommand = commands . nextLine ( ) ; argument1 = "" ; argument2 = - 1 ; String [ ] segment = currentCommand . split ( " " ) ; if ( segment . length > 3 ) { throw new IllegalArgumentException ( "ERROR: Too many arguments!" ) ; } if ( arithmeticCmds . contains ( segment [ 0 ] ) ) { argumentType = ARITHMETIC ; argument1 = segment [ 0 ] ; } else if ( segment [ 0 ] . equals ( "return" ) ) { argumentType = RETURN ; argument1 = segment [ 0 ] ; } else { argument1 = segment [ 1 ] ; if ( segment [ 0 ] . equals ( "push" ) ) { argumentType = PUSH ; } else if ( segment [ 0 ] . equals ( "pop" ) ) { argumentType = POP ; } else if ( segment [ 0 ] . equals ( "label" ) ) { argumentType = LABEL ; } else if ( segment [ 0 ] . equals ( "if" ) ) { argumentType = IF ; } else if ( segment [ 0 ] . equals ( "goto" ) ) { argumentType = GOTO ; } else if ( segment [ 0 ] . equals ( "function" ) ) { argumentType = FUNCTION ; } else if ( segment [ 0 ] . equals ( "call" ) ) { argumentType = CALL ; } else { throw new IllegalArgumentException ( "Unknown Command Type!" ) ; } if ( argumentType == PUSH || argumentType == POP || argumentType == FUNCTION || argumentType == CALL ) { try { argument2 = Integer . parseInt ( segment [ 2 ] ) ; } catch ( Exception e ) { e . getMessage ( ) ; e . printStackTrace ( ) ; throw new IllegalArgumentException ( "ERROR: argument2 is not an integer!" ) ; } } } }
POST-CONDITION: currentCommand has been updated to the line that was just read.
POST - CONDITION : currentCommand has been updated to the line that was just read .
//initialize arg1
 //initialize arg2
