Package org.antlr.runtime

Examples of org.antlr.runtime.Token


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

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

        if ( state.backtracking == 0 ) {
            pattern.from().window( window );
            if ( input.LA( 1 ) != DRL5Lexer.EOF ) {
                helper.emit( Location.LOCATION_LHS_BEGIN_OF_CONDITION );
View Full Code Here


     * @param accumulate
     * @throws RecognitionException
     */
    private void accumulateFunction( AccumulateDescrBuilder< ? > accumulate,
                                     String label ) throws RecognitionException {
        Token function = match( input,
                                DRL5Lexer.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,
                             DRL5Lexer.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,
                   DRL5Lexer.LEFT_SQUARE,
                   null,
                   null,
                   DroolsEditorType.SYMBOL );
            Token label = match( input,
                                 DRL5Lexer.ID,
                                 null,
                                 null,
                                 DroolsEditorType.SYMBOL );
            int first = input.index();
            match( input,
                    DRL5Lexer.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,
                                  DRL5Lexer.AT,
                                  null,
                                  null,
                                  DroolsEditorType.SYMBOL );
                if ( state.failed ) return;

                // identifier
                Token id = match( input,
                                  DRL5Lexer.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

     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    private String stringId() throws RecognitionException {
        if ( input.LA( 1 ) == DRL6Lexer.ID ) {
            Token id = match( input,
                              DRL6Lexer.ID,
                              null,
                              null,
                              DroolsEditorType.IDENTIFIER );
            if ( state.failed ) return null;
            return id.getText();
        } else if ( input.LA( 1 ) == DRL6Lexer.STRING ) {
            Token id = match( input,
                              DRL6Lexer.STRING,
                              null,
                              null,
                              DroolsEditorType.IDENTIFIER );
            if ( state.failed ) return null;
            return StringUtils.unescapeJava( safeStripStringDelimiters( id.getText() ) );
        } else {
            throw new MismatchedTokenException( DRL6Lexer.ID,
                                                input );
        }
    }
View Full Code Here

                                          builder.toString() );
            }

            String value = "true";
            if ( input.LA( 1 ) == DRL6Lexer.BOOL ) {
                Token bool = match( input,
                                    DRL6Lexer.BOOL,
                                    null,
                                    null,
                                    DroolsEditorType.KEYWORD );
                if ( state.failed ) return null;
                value = bool.getText();
            }
            if ( state.backtracking == 0 ) {
                attribute.value( value );
                attribute.type( AttributeDescr.Type.BOOLEAN );
            }
View Full Code Here

                attribute = helper.start( (DescrBuilder< ? , ? >) as,
                                          AttributeDescrBuilder.class,
                                          builder.toString() );
            }

            Token value = match( input,
                                 DRL6Lexer.STRING,
                                 null,
                                 null,
                                 DroolsEditorType.STRING_CONST );
            if ( state.failed ) return null;
            if ( state.backtracking == 0 ) {
                attribute.value( StringUtils.unescapeJava( safeStripStringDelimiters( value.getText() ) ) );
                attribute.type( AttributeDescr.Type.STRING );
            }
        } finally {
            if ( attribute != null ) {
                helper.end( AttributeDescrBuilder.class,
View Full Code Here

                                          builder.toString() );
            }

            builder = new StringBuilder();
            builder.append( "[ " );
            Token value = match( input,
                                 DRL6Lexer.STRING,
                                 null,
                                 null,
                                 DroolsEditorType.STRING_CONST );
            if ( state.failed ) return null;
            builder.append( value.getText() );

            while ( input.LA( 1 ) == DRL6Lexer.COMMA ) {
                match( input,
                       DRL6Lexer.COMMA,
                       null,
                       null,
                       DroolsEditorType.SYMBOL );
                if ( state.failed ) return null;
                builder.append( ", " );
                value = match( input,
                               DRL6Lexer.STRING,
                               null,
                               null,
                               DroolsEditorType.STRING_CONST );
                if ( state.failed ) return null;
                builder.append( value.getText() );
            }
            builder.append( " ]" );
            if ( state.backtracking == 0 ) {
                attribute.value( builder.toString() );
                attribute.type( AttributeDescr.Type.LIST );
View Full Code Here

                    attribute.type( AttributeDescr.Type.EXPRESSION );
                }
            } else {
                String value = "";
                if ( input.LA( 1 ) == DRL6Lexer.PLUS ) {
                    Token sign = match( input,
                                        DRL6Lexer.PLUS,
                                        null,
                                        null,
                                        DroolsEditorType.NUMERIC_CONST );
                    if ( state.failed ) return null;
                    value += sign.getText();
                } else if ( input.LA( 1 ) == DRL6Lexer.MINUS ) {
                    Token sign = match( input,
                                        DRL6Lexer.MINUS,
                                        null,
                                        null,
                                        DroolsEditorType.NUMERIC_CONST );
                    if ( state.failed ) return null;
                    value += sign.getText();
                }
                Token nbr = match( input,
                                   DRL6Lexer.DECIMAL,
                                   null,
                                   null,
                                   DroolsEditorType.NUMERIC_CONST );
                if ( state.failed ) return null;
                value += nbr.getText();
                if ( state.backtracking == 0 ) {
                    attribute.value( value );
                    attribute.type( AttributeDescr.Type.NUMBER );
                }
            }
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.