Package org.antlr.runtime

Examples of org.antlr.runtime.Token


            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 ) return;

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

                if ( state.backtracking == 0 ) {
                    annotation = adb.newAnnotation( id.getText() );
                    helper.setStart( annotation,
                                     at );
                }

                try {
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

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

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

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

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

            token = match( input,
                           DRL5Lexer.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 RecognitionException
     */
    public String qualifiedIdentifier() throws RecognitionException {
        String qi = "";
        try {
            Token first = match( input,
                                 DRL5Lexer.ID,
                                 null,
                                 new int[]{DRL5Lexer.DOT},
                                 DroolsEditorType.IDENTIFIER );
            if ( state.failed ) return qi;

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

    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 );
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

     */
    public boolean ignoreToken(Token t) {
        if(!XJSystem.isWindows())
            return false;

        Token ct = getCurrentToken();
        if(ct == null)
            return false;

        return ct.getText().equals("\r") && t.getText().equals("\n");
    }
View Full Code Here

    /** This method keeps track of the last consumed index in order to display
     * useful information if an invalid index is detected
     */
    public void recordIndexes(DBEvent event) {
        Token t = null;
        if(event instanceof DBEventConsumeToken) {
            DBEventConsumeToken e = (DBEventConsumeToken) event;
            t = e.token;
        }
        if(event instanceof DBEventConsumeHiddenToken) {
            DBEventConsumeHiddenToken e = (DBEventConsumeHiddenToken) event;
            t = e.token;
        }

        if(t != null) {
            lastTokenIndexEventNumber = currentTokenIndexEventNumber;
            currentTokenIndexEventNumber = events.size()-1;
            currentTokenIndex = t.getTokenIndex();
        }
    }
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.