private final ParserAction getAction(ParserActionSet actionSet) throws GrammarException {
	if (actionSet.getActionNumber() == 1) {
	    /*
	     * action is not ambiguous, therefore, the action is easily returned...
	     */
	    return actionSet.getAction();
	}
	if (!backtrackEnabled) {
	    /*
	     * Backtracking is disabled and action set is ambiguous. Throw exception due to
	     * illegal state...
	     */
	    logger.trace("Action set '" + actionSet + "' is ambiguous and back tracking is disabled!");
	    throw new GrammarException("Grammar is ambiguous!");
	}
	if ((!backtrackStack.isEmpty()) && (backtrackStack.peek().getStepCounter() == stepCounter)) {
	    /*
	     * We are currently at a step with stored backtracking information, so we just
	     * returned from a backtrack. Trying next alternative...
	     */
	    if (logger.isTraceEnabled()) {
		logger.trace("Action set '" + actionSet
			+ "' is ambiguous and back tracking was performed already. Trying new alternative...");
	    }
	    BacktrackLocation location = backtrackStack.pop();
	    int stepAhead = 1;
	    if (location.getLastAlternative() + stepAhead >= actionSet.getActionNumber()) {
		logger.trace("No alternative left. Abort.");
		return new ParserAction(ActionType.ERROR, -1);
	    }
	    addBacktrackLocation(location.getLastAlternative() + stepAhead);
	    return actionSet.getAction(location.getLastAlternative() + stepAhead);
	}
	/*
	 * We have a new ambiguous state. We store backtracking information and try
	 * first alternative...
	 */
	if (logger.isTraceEnabled()) {
	    logger.trace("Action set '" + actionSet + "' is ambiguous. Installing back tracking location in stack...");
	}
	addBacktrackLocation(0);
	return actionSet.getAction(0);
    }
private final ParserAction getAction ( ParserActionSet actionSet ) throws GrammarException { if ( actionSet . getActionNumber ( ) == 1 ) { return actionSet . getAction ( ) ; } if ( ! backtrackEnabled ) { logger . trace ( "Action set '" + actionSet + "' is ambiguous and back tracking is disabled!" ) ; throw new GrammarException ( "Grammar is ambiguous!" ) ; } if ( ( ! backtrackStack . isEmpty ( ) ) && ( backtrackStack . peek ( ) . getStepCounter ( ) == stepCounter ) ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Action set '" + actionSet + "' is ambiguous and back tracking was performed already. Trying new alternative..." ) ; } BacktrackLocation location = backtrackStack . pop ( ) ; int stepAhead = 1 ; if ( location . getLastAlternative ( ) + stepAhead >= actionSet . getActionNumber ( ) ) { logger . trace ( "No alternative left. Abort." ) ; return new ParserAction ( ActionType . ERROR , - 1 ) ; } addBacktrackLocation ( location . getLastAlternative ( ) + stepAhead ) ; return actionSet . getAction ( location . getLastAlternative ( ) + stepAhead ) ; } if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Action set '" + actionSet + "' is ambiguous. Installing back tracking location in stack..." ) ; } addBacktrackLocation ( 0 ) ; return actionSet . getAction ( 0 ) ; }
This mehtod returns the currently to be processed action. This method also
takes care for ambiguous grammars and backtracking.

@param actionSet
@return
@throws GrammarException