src/main/java/ca/gobits/bnf/parser/BNFParserImpl.java
private BNFParseResultImpl parseSequences(final BNFToken startToken) {

        boolean success = false;
        BNFToken maxMatchToken = startToken;
        BNFToken errorToken = null;

        BNFParseResultImpl result = new BNFParseResultImpl();
        result.setTop(startToken);

        while (!this.stack.isEmpty()) {

            BNFParserState holder = this.stack.peek();

            if (holder.getState() == ParserState.EMPTY) {

                this.stack.pop();
                BNFToken token = this.stack.peek().getCurrentToken();
                if (!isEmpty(token)) {
                    rewindToNextSymbol();
                } else {
                    success = true;
                    errorToken = null;
                    rewindToNextSequence();
                }

            } else if (holder.getState() == ParserState.NO_MATCH_WITH_ZERO_REPETITION) {

                processNoMatchWithZeroRepetition();

            } else if (holder.getState() == ParserState.MATCH_WITH_ZERO_REPETITION) {

                processMatchWithZeroRepetition();

            } else if (holder.getState() == ParserState.NO_MATCH_WITH_ZERO_REPETITION_LOOKING_FOR_FIRST_MATCH) {

                maxMatchToken = processNoMatchWithZeroRepetitionLookingForFirstMatch();
                errorToken = null;
                success = true;

            } else if (holder.getState() == ParserState.MATCH) {

                maxMatchToken = processMatch();
                errorToken = null;
                success = true;

            } else if (holder.getState() == ParserState.NO_MATCH) {

                BNFToken eToken = processNoMatch();
                errorToken = updateErrorToken(errorToken, eToken);
                success = false;

            } else {
                processStack();
            }
        }

        updateResult(result, maxMatchToken, errorToken, success);

        return result;
    }
/**
     * Main loop for parsing.
     * @param startToken -
     * @return BNFParseResultImpl
     */
Main loop for parsing.
@param startToken
@return BNFParseResultImpl
Main loop for parsing . @param startToken @return BNFParseResultImpl
private BNFParseResultImpl parseSequences(final BNFToken startToken) {
        boolean success = false;
        BNFToken maxMatchToken = startToken;
        BNFToken errorToken = null;
        BNFParseResultImpl result = new BNFParseResultImpl();
        result.setTop(startToken);
        while (!this.stack.isEmpty()) {
            BNFParserState holder = this.stack.peek();
            if (holder.getState() == ParserState.EMPTY) {
                this.stack.pop();
                BNFToken token = this.stack.peek().getCurrentToken();
                if (!isEmpty(token)) {
                    rewindToNextSymbol();
                } else {
                    success = true;
                    errorToken = null;
                    rewindToNextSequence();
                }
            } else if (holder.getState() == ParserState.NO_MATCH_WITH_ZERO_REPETITION) {
                processNoMatchWithZeroRepetition();
            } else if (holder.getState() == ParserState.MATCH_WITH_ZERO_REPETITION) {
                processMatchWithZeroRepetition();
            } else if (holder.getState() == ParserState.NO_MATCH_WITH_ZERO_REPETITION_LOOKING_FOR_FIRST_MATCH) {
                maxMatchToken = processNoMatchWithZeroRepetitionLookingForFirstMatch();
                errorToken = null;
                success = true;
            } else if (holder.getState() == ParserState.MATCH) {
                maxMatchToken = processMatch();
                errorToken = null;
                success = true;
            } else if (holder.getState() == ParserState.NO_MATCH) {
                BNFToken eToken = processNoMatch();
                errorToken = updateErrorToken(errorToken, eToken);
                success = false;
            } else {
                processStack();
            }
        }
        updateResult(result, maxMatchToken, errorToken, success);
        return result;
    }
private BNFParseResultImpl parseSequences ( final BNFToken startToken ) { boolean success = false ; BNFToken maxMatchToken = startToken ; BNFToken errorToken = null ; BNFParseResultImpl result = new BNFParseResultImpl ( ) ; result . setTop ( startToken ) ; while ( ! this . stack . isEmpty ( ) ) { BNFParserState holder = this . stack . peek ( ) ; if ( holder . getState ( ) == ParserState . EMPTY ) { this . stack . pop ( ) ; BNFToken token = this . stack . peek ( ) . getCurrentToken ( ) ; if ( ! isEmpty ( token ) ) { rewindToNextSymbol ( ) ; } else { success = true ; errorToken = null ; rewindToNextSequence ( ) ; } } else if ( holder . getState ( ) == ParserState . NO_MATCH_WITH_ZERO_REPETITION ) { processNoMatchWithZeroRepetition ( ) ; } else if ( holder . getState ( ) == ParserState . MATCH_WITH_ZERO_REPETITION ) { processMatchWithZeroRepetition ( ) ; } else if ( holder . getState ( ) == ParserState . NO_MATCH_WITH_ZERO_REPETITION_LOOKING_FOR_FIRST_MATCH ) { maxMatchToken = processNoMatchWithZeroRepetitionLookingForFirstMatch ( ) ; errorToken = null ; success = true ; } else if ( holder . getState ( ) == ParserState . MATCH ) { maxMatchToken = processMatch ( ) ; errorToken = null ; success = true ; } else if ( holder . getState ( ) == ParserState . NO_MATCH ) { BNFToken eToken = processNoMatch ( ) ; errorToken = updateErrorToken ( errorToken , eToken ) ; success = false ; } else { processStack ( ) ; } } updateResult ( result , maxMatchToken , errorToken , success ) ; return result ; }
Main loop for parsing.
Main loop for parsing .