Java Code Examples for org.antlr.runtime.TokenStream#consume()

The following examples show how to use org.antlr.runtime.TokenStream#consume() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DRL6StrictParser.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
/** 
 *  Match current input symbol against ttype and optionally
 *  check the text of the token against text.  Attempt
 *  single token insertion or deletion error recovery.  If
 *  that fails, throw MismatchedTokenException.
 */
Token match( TokenStream input,
             int ttype,
             String text,
             int[] follow,
             DroolsEditorType etype ) throws RecognitionException {
    Token matchedSymbol = null;
    matchedSymbol = input.LT(1);
    if (input.LA(1) == ttype && (text == null || text.equals(matchedSymbol.getText()))) {
        input.consume();
        state.errorRecovery = false;
        state.failed = false;
        helper.emit(matchedSymbol,
                etype);
        return matchedSymbol;
    }
    if (state.backtracking > 0) {
        state.failed = true;
        return matchedSymbol;
    }
    matchedSymbol = recoverFromMismatchedToken(input,
            ttype,
            text,
            follow);
    helper.emit(matchedSymbol,
            etype);
    return matchedSymbol;
}
 
Example 2
Source File: DRL6Parser.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
/** 
 *  Match current input symbol against ttype and optionally
 *  check the text of the token against text.  Attempt
 *  single token insertion or deletion error recovery.  If
 *  that fails, throw MismatchedTokenException.
 */
Token match( TokenStream input,
             int ttype,
             String text,
             int[] follow,
             DroolsEditorType etype ) throws RecognitionException {
    Token matchedSymbol = null;
    matchedSymbol = input.LT(1);
    if (input.LA(1) == ttype && (text == null || text.equals(matchedSymbol.getText()))) {
        input.consume();
        state.errorRecovery = false;
        state.failed = false;
        helper.emit(matchedSymbol,
                etype);
        return matchedSymbol;
    }
    if (state.backtracking > 0) {
        state.failed = true;
        return matchedSymbol;
    }
    matchedSymbol = recoverFromMismatchedToken(input,
            ttype,
            text,
            follow);
    helper.emit(matchedSymbol,
            etype);
    return matchedSymbol;
}
 
Example 3
Source File: DRL5Parser.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
/** 
 *  Match current input symbol against ttype and optionally
 *  check the text of the token against text.  Attempt
 *  single token insertion or deletion error recovery.  If
 *  that fails, throw MismatchedTokenException.
 */
private Token match( TokenStream input,
                     int ttype,
                     String text,
                     int[] follow,
                     DroolsEditorType etype ) throws RecognitionException {
    Token matchedSymbol = null;
    matchedSymbol = input.LT( 1 );
    if ( input.LA( 1 ) == ttype && (text == null || text.equals( matchedSymbol.getText() )) ) {
        input.consume();
        state.errorRecovery = false;
        state.failed = false;
        helper.emit( matchedSymbol,
                     etype );
        return matchedSymbol;
    }
    if ( state.backtracking > 0 ) {
        state.failed = true;
        return matchedSymbol;
    }
    matchedSymbol = recoverFromMismatchedToken( input,
                                                ttype,
                                                text,
                                                follow );
    helper.emit( matchedSymbol,
                 etype );
    return matchedSymbol;
}