Examples of ParserError


Examples of org.drools.compiler.compiler.ParserError


        private List<ParserError> errors = new ArrayList<ParserError>();

        public void reportError(RecognitionException ex) {
            errors.add(new ParserError( "DSL parser error", ex.line, ex.charPositionInLine ) );
        }
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

        private static final Pattern namePat = Pattern.compile( "[\\p{L}_$][\\p{L}_$\\d]*" );

        private void isIdentifier( Token name ){
            String nameString = name.getText();
            if( ! namePat.matcher( nameString ).matches() ){
                errors.add(new ParserError( "invalid variable identifier " + nameString,
                                            name.getLine(), name.getCharPositionInLine() ) );
            }
        }
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

    protected void markParseErrors(List<DroolsBuildMarker> markers,
                                   List<BaseKnowledgeBuilderResultImpl> parserErrors) {
        for ( Iterator<BaseKnowledgeBuilderResultImpl> iter = parserErrors.iterator(); iter.hasNext(); ) {
            Object error = iter.next();
            if ( error instanceof ParserError ) {
                ParserError err = (ParserError) error;
                markers.add( new DroolsBuildMarker( err.getMessage(),
                                                    err.getRow() ) );
            } else if ( error instanceof KnowledgeBuilderResult) {
                KnowledgeBuilderResult res = (KnowledgeBuilderResult) error;
                int[] errorLines = res.getLines();
                markers.add( new DroolsBuildMarker( res.getMessage(),
                                                    errorLines != null && errorLines.length > 0 ? errorLines[0] : -1 ) );
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

                } else {
                    markers.add( new DroolsBuildMarker( ruleError.getRule().getName() + ":" + ruleError.getMessage(),
                                                        ruleError.getLine() ) );
                }
            } else if ( error instanceof ParserError ) {
                ParserError parserError = (ParserError) error;
                // TODO try to retrieve character start-end
                markers.add( new DroolsBuildMarker( parserError.getMessage(),
                                                    parserError.getRow() ) );
            } else if ( error instanceof FunctionError ) {
                FunctionError functionError = (FunctionError) error;
                // TODO add line to function error
                // TODO try to retrieve character start-end
                if ( functionError.getObject() instanceof CompilationProblem[] ) {
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

                       parser.getErrors().size() );
         parser.parse( new InputStreamReader( getClass().getResourceAsStream( "errors_parser_multiple.drl" ) ) );
         assertTrue( parser.hasErrors() );
         assertTrue( parser.getErrors().size() > 0 );
         assertTrue( parser.getErrors().get( 0 ) instanceof ParserError);
         final ParserError first = ((ParserError) parser.getErrors().get( 0 ));
         assertTrue( first.getMessage() != null );
         assertFalse( first.getMessage().equals( "" ) );
     }
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

        this.resource = sourceResource;
        final DrlParser parser = new DrlParser(configuration.getLanguageLevel());
        final PackageDescr pkg = parser.parse(sourceResource, reader);
        this.results.addAll(parser.getErrors());
        if (pkg == null) {
            addBuilderResult(new ParserError(sourceResource, "Parser returned a null Package", 0, 0));
        }

        if (!parser.hasErrors()) {
            addPackage(pkg);
        }
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

        DrlParser parser = new DrlParser(this.configuration.getLanguageLevel());
        PackageDescr pkg = parser.parse(resource, new StringReader(generatedDrl));
        this.results.addAll(parser.getErrors());
        if (pkg == null) {
            addBuilderResult(new ParserError(resource, "Parser returned a null Package", 0, 0));
        }
        return parser.hasErrors() ? null : pkg;
    }
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

        DrlParser parser = new DrlParser(this.configuration.getLanguageLevel());
        PackageDescr pkg = parser.parse(resource, new StringReader(string));
        this.results.addAll(parser.getErrors());
        if (pkg == null) {
            addBuilderResult(new ParserError(resource, "Parser returned a null Package", 0, 0));
        }
        return parser.hasErrors() ? null : pkg;
    }
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

        } else {
            final DrlParser parser = new DrlParser(configuration.getLanguageLevel());
            pkg = parser.parse(resource);
            this.results.addAll(parser.getErrors());
            if (pkg == null) {
                addBuilderResult(new ParserError(resource, "Parser returned a null Package", 0, 0));
            }
            hasErrors = parser.hasErrors();
        }
        if (pkg != null) {
            pkg.setResource(resource);
View Full Code Here

Examples of org.drools.compiler.compiler.ParserError

        DrlParser parser = new DrlParser(configuration.getLanguageLevel());
        PackageDescr pkg = parser.parse(resource, new StringReader(theory));
        this.results.addAll(parser.getErrors());
        if (pkg == null) {
            addBuilderResult(new ParserError(resource, "Parser returned a null Package", 0, 0));
            return pkg;
        } else {
            return parser.hasErrors() ? null : pkg;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.