Package org.antlr.runtime

Examples of org.antlr.runtime.Token


     * @param accumulate
     * @throws org.antlr.runtime.RecognitionException
     */
    private void accumulateFunction(AccumulateDescrBuilder<?> accumulate,
            String label) throws RecognitionException {
        Token function = match(input,
                DRL6Lexer.ID,
                null,
                null,
                DroolsEditorType.KEYWORD);
        if (state.failed)
            return;

        List<String> parameters = parameters();
        if (state.failed)
            return;

        if (state.backtracking == 0) {
            accumulate.function(function.getText(),
                    label,
                    parameters.toArray(new String[parameters.size()]));
        }
    }
View Full Code Here


     * @param rule
     */
    public void defaultConsequence(RuleDescrBuilder rule) {
        try {
            int first = input.index();
            Token t = match(input,
                    DRL6Lexer.ID,
                    DroolsSoftKeywords.THEN,
                    null,
                    DroolsEditorType.KEYWORD);
            if (state.failed)
                return;

            if (state.backtracking == 0) {
                rule.getDescr().setConsequenceLocation(t.getLine(),
                        t.getCharPositionInLine());
                helper.emit(Location.LOCATION_RHS);
            }

            String chunk = getConsequenceCode(first);

View Full Code Here

            match(input,
                    DRL6Lexer.LEFT_SQUARE,
                    null,
                    null,
                    DroolsEditorType.SYMBOL);
            Token label = match(input,
                    DRL6Lexer.ID,
                    null,
                    null,
                    DroolsEditorType.SYMBOL);
            int first = input.index();
            match(input,
                    DRL6Lexer.RIGHT_SQUARE,
                    null,
                    null,
                    DroolsEditorType.SYMBOL);
            if (state.failed)
                return;

            String name = label.getText();
            String chunk = getConsequenceCode(first);

            // remove the closing squqre bracket "]" and any subsequent spaces and line breaks
            // keep indentation of 1st non-blank line
            chunk = chunk.replaceFirst("^\\]\\s*\\r?\\n?",
 
View Full Code Here

                exprParser.fullAnnotation(adb);
                exprParser.setBuildDescr(buildState);
            } else {

                // '@'
                Token at = match(input,
                        DRL6Lexer.AT,
                        null,
                        null,
                        DroolsEditorType.SYMBOL);
                if (state.failed)
View Full Code Here

     */
    public String typeArguments() throws RecognitionException {
        String typeArguments = "";
        try {
            int first = input.index();
            Token token = match(input,
                    DRL6Lexer.LESS,
                    null,
                    new int[]{DRL6Lexer.QUESTION, DRL6Lexer.ID},
                    DroolsEditorType.SYMBOL);
            if (state.failed)
                return typeArguments;

            typeArgument();
            if (state.failed)
                return typeArguments;

            while (input.LA(1) == DRL6Lexer.COMMA) {
                token = match(input,
                        DRL6Lexer.COMMA,
                        null,
                        new int[]{DRL6Lexer.QUESTION, DRL6Lexer.ID},
                        DroolsEditorType.IDENTIFIER);
                if (state.failed)
                    return typeArguments;

                typeArgument();
                if (state.failed)
                    return typeArguments;
            }

            token = match(input,
                    DRL6Lexer.GREATER,
                    null,
                    null,
                    DroolsEditorType.SYMBOL);
            if (state.failed)
                return typeArguments;
            typeArguments = input.toString(first,
                    token.getTokenIndex());

        } catch (RecognitionException re) {
            reportError(re);
        }
        return typeArguments;
View Full Code Here

     * @throws org.antlr.runtime.RecognitionException
     */
    public String qualifiedIdentifier() throws RecognitionException {
        String qi = "";
        try {
            Token first = match(input,
                    DRL6Lexer.ID,
                    null,
                    new int[]{DRL6Lexer.DOT},
                    DroolsEditorType.IDENTIFIER);
            if (state.failed)
                return qi;

            Token last = first;
            while (input.LA(1) == DRL6Lexer.DOT && input.LA(2) == DRL6Lexer.ID) {
                last = match(input,
                        DRL6Lexer.DOT,
                        null,
                        new int[]{DRL6Lexer.ID},
View Full Code Here

    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);
View Full Code Here

            e = new UnwantedTokenException(ttype,
                    input);
            input.consume(); // simply delete extra token
            reportError(e); // report after consuming so AW sees the token in the exception
            // we want to return the token we're actually matching
            Token matchedSymbol = input.LT(1);
            input.consume(); // move past ttype token as if all were ok
            return matchedSymbol;
        }
        // can't recover with single token deletion, try insertion
        if (mismatchIsMissingToken(input,
View Full Code Here

            String type = type();
            if ( state.backtracking == 0 ) global.type( type );
            if ( state.failed ) return null;

            // identifier
            Token id = match( input,
                              DRL6Lexer.ID,
                              null,
                              null,
                              DroolsEditorType.IDENTIFIER_TYPE );
            if ( state.failed ) return null;
            if ( state.backtracking == 0 ) {
                global.identifier( id.getText() );
                helper.setParaphrasesValue( DroolsParaphraseTypes.GLOBAL,
                                            id.getText() );
            }

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
View Full Code Here

                   DroolsSoftKeywords.WINDOW,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

            Token id = match( input,
                              DRL6Lexer.ID,
                              null,
                              null,
                              DroolsEditorType.IDENTIFIER );
            if ( state.failed ) return null;
            window = id.getText();

            if( state.backtracking == 0 ) {
                declare.name( window );
            }
View Full Code Here

TOP

Related Classes of org.antlr.runtime.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.