Package org.drools.lang

Examples of org.drools.lang.ExpanderException


                        countNewlines( fragment ) + 1 ) ); // adding expanded LHS
                expanded.append( m.group( 9 ) ); // adding query trailer
                expanded.append( "\n" );
            } else {
                // strange behavior
                this.addError( new ExpanderException( "Unable to expand statement: " + constr,
                        0 ) );
            }
            m.appendReplacement( buf,
                    expanded.toString().replaceAll( "\\$",
                    "\\\\\\$" ) );
View Full Code Here


                }

                // do we need to report errors for that?
                if ( lines[i].equals( expanded[lastExpanded] ) ) {
                    // report error
                    this.addError( new ExpanderException( "Unable to expand: " + lines[i].replaceAll( "[\n\r]",
                    "" ).trim(),
                    i + lineOffset ) );
                }
                // but if the original starts with a "-", it means we need to add it
                // as a constraint to the previous pattern
                if ( trimmed.startsWith( "-" ) && (!lines[i].equals( expanded[lastExpanded] )) ) {
                    int lastMatchStart = -1;
                    int lastMatchEnd = -1;
                    String constraints = "";
                    if ( lastPattern >= 0 ) {
                        final Matcher m2 = patternFinder.matcher( expanded[lastPattern] );
                        while ( m2.find() ) {
                            lastMatchStart = m2.start();
                            lastMatchEnd = m2.end();
                            constraints = m2.group( 1 ).trim();
                        }
                    }
                    if ( lastMatchStart > -1 ) {
                        // rebuilding previous pattern structure
                        expanded[lastPattern] = expanded[lastPattern].substring( 0,
                                lastMatchStart ) + "( " + constraints + ((constraints.length() == 0) ? "" : ", ") + expanded[lastExpanded].trim() + " )"
                                + expanded[lastPattern].substring( lastMatchEnd );
                    } else {
                        // error, pattern not found to add constraint to
                        this.addError( new ExpanderException( "No pattern was found to add the constraint to: " + lines[i].trim(),
                                i + lineOffset ) );
                    }
                    lastExpanded--;
                } else {
                    lastPattern = lastExpanded;
View Full Code Here

                }
                buf.append( expanded );
                // do we need to report errors for that?
                if ( lines[i].equals( expanded ) ) {
                    // report error
                    this.addError( new ExpanderException( "Unable to expand: " + lines[i],
                            i + lineOffset ) );
                }
            }
            buf.append( "\n" );
        }
View Full Code Here

                expanded.append( lhsFragment );
                expanded.append( m.group( 8 ) ); // adding query trailer

            } else {
                // strange behavior
                this.addError( new ExpanderException( "Unable to expand statement: " + constr, 0 ) );
            }
            m.appendReplacement( buf, Matcher.quoteReplacement( expanded.toString() ) );
        }
        m.appendTail( buf );
        return buf;
View Full Code Here

     */
    private String substitute( String exp, List<DSLMappingEntry> entries, int line,
            Map<String,Integer> use, boolean showSingleSteps ){
        if( entries.size() == 0 ){
            if( line > 0 ){
                this.addError( new ExpanderException( "No mapping entries for expanding: " + exp, line ) );
            }
            return exp;
        }
        if( showSingleSteps ){
            System.out.println("to expand: |" + exp + "|");
View Full Code Here

                    substitute( expanded[lastExpanded], this.condition, i + lineOffset, useWhen, showSteps );

                // do we need to report errors for that?
                if ( lines[i].equals( expanded[lastExpanded] ) ) {
                    // report error
                    this.addError( new ExpanderException( "Unable to expand: " + lines[i].replaceAll( "[\n\r]", "" ).trim(),
                                                          i + lineOffset ) );
                }
                // but if the original starts with a "-", it means we need to add it
                // as a constraint to the previous pattern
                if ( trimmed.startsWith( "-" ) && (!lines[i].equals( expanded[lastExpanded] )) ) {
                    int lastMatchStart = -1;
                    int lastMatchEnd = -1;
                    String constraints = "";
                    if ( lastPattern >= 0 ) {
                        final Matcher m2 = constraintFinder.matcher( expanded[lastPattern] );
                        while ( m2.find() ) {
                            lastMatchStart = m2.start();
                            lastMatchEnd = m2.end();
                            constraints = m2.group( 1 ).trim();
                        }
                    }
                    if ( lastMatchStart > -1 ) {
                        // rebuilding previous pattern structure
                        expanded[lastPattern] = expanded[lastPattern].substring( 0,
                                lastMatchStart ) + "( " + constraints + ((constraints.length() == 0) ? "" : ", ") + expanded[lastExpanded].trim() + " )"
                                + expanded[lastPattern].substring( lastMatchEnd );
                    } else {
                        // error, pattern not found to add constraint to
                        this.addError( new ExpanderException( "No pattern was found to add the constraint to: " + lines[i].trim(),
                                i + lineOffset ) );
                    }
                    lastExpanded--;
                } else {
                    lastPattern = lastExpanded;
View Full Code Here

                    substitute( expanded[lastExpanded], this.consequence, i + lineOffset, useThen, showSteps );

                // do we need to report errors for that?
                if ( lines[i].equalsexpanded[lastExpanded] ) ) {
                    // report error
                    this.addError( new ExpanderException( "Unable to expand: " + lines[i],
                                                          i + lineOffset ) );
                }
               
                // If the original starts with a "-", it means we need to add it
                // as a modify term to the previous pattern
                if ( trimmed.startsWith( "-" ) && ( ! lines[i].equals( expanded[lastExpanded] )) ) {
                    int lastMatchStart = -1;
                    int lastMatchEnd = -1;
                    String modifiers = "";
                    if ( lastPattern >= 0 ) {
                        final Matcher m2 = modifyFinder.matcher( expanded[lastPattern] );
                        while ( m2.find() ) {
                            lastMatchStart = m2.start();
                            lastMatchEnd = m2.end();
                            modifiers = m2.group( 1 ).trim();
                        }
                    }
                    if ( lastMatchStart > -1 ) {
                        // rebuilding previous modify structure
                        expanded[lastPattern] = expanded[lastPattern].substring( 0, lastMatchStart )
                                                + "{ " + modifiers +
                                                ((modifiers.length() == 0) ? "" : ", ") +
                                                expanded[lastExpanded].trim() + " }" +
                                                expanded[lastPattern].substring( lastMatchEnd );
                    } else {
                        // error, pattern not found to add constraint to
                        this.addError( new ExpanderException( "No modify was found to add the modifier to: " + lines[i].trim(),
                                i + lineOffset ) );
                    }
                    lastExpanded--;
                } else {
                    lastPattern = lastExpanded;
View Full Code Here

            if ( error instanceof ParserError ) {
                ParserError err = (ParserError) error;
                markers.add( new DroolsBuildMarker( err.getMessage(),
                                                    err.getRow() ) );
            } else if ( error instanceof ExpanderException ) {
                ExpanderException exc = (ExpanderException) error;
                // TODO line mapping is incorrect
                markers.add( new DroolsBuildMarker( exc.getMessage(),
                                                    -1 ) );
            } else {
                markers.add( new DroolsBuildMarker( error.toString() ) );
            }
        }
View Full Code Here

                "then" + NL + "    bar 42" + NL + "\tgoober" + NL + "end";
        ex.expand( source );
        assertTrue( ex.hasErrors() );
        assertEquals( 2,
                      ex.getErrors().size() );
        ExpanderException err = (ExpanderException) ex.getErrors().get( 0 );
        assertEquals( 4,
                      err.getLine() );
        err = (ExpanderException) ex.getErrors().get( 1 );
        assertEquals( 7,
                      err.getLine() );

    }
View Full Code Here

                "then" + NL + "    bar 42" + NL + "\tgoober" + NL + "end";
        ex.expand( source );
        assertTrue( ex.hasErrors() );
        assertEquals( 2,
                      ex.getErrors().size() );
        ExpanderException err = (ExpanderException) ex.getErrors().get( 0 );
        assertEquals( 4,
                      err.getLine() );
        err = (ExpanderException) ex.getErrors().get( 1 );
        assertEquals( 7,
                      err.getLine() );

    }
View Full Code Here

TOP

Related Classes of org.drools.lang.ExpanderException

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.