Search in sources :

Example 1 with ShaclcParseException

use of org.apache.jena.shacl.compact.reader.ShaclcParseException in project jena by apache.

the class shacl_parse method exec.

private void exec(String fn, boolean multipleFiles) {
    Shapes shapes;
    PrintStream out = System.out;
    PrintStream err = System.err;
    try {
        Graph g = parseFile(fn);
        shapes = Shapes.parse(g);
    } catch (RiotException ex) {
        /*ErrorHandler logged this */
        return;
    } catch (ShaclParseException | ShaclcParseException ex) {
        // Errors parsing SHACL Compact Syntax.
        if (multipleFiles)
            err.println(fn + " : ");
        err.println(ex.getMessage());
        return;
    }
    boolean outputByPrev = false;
    if (printText) {
        outputByPrev = printText(out, err, shapes);
    }
    if (printCompact) {
        if (outputByPrev) {
            out.println("- - - - - - - -");
            outputByPrev = false;
        }
        outputByPrev = printCompact(out, err, shapes);
    }
    if (printRDF) {
        if (outputByPrev) {
            out.println("- - - - - - - -");
            outputByPrev = false;
        }
        outputByPrev = printRDF(out, err, shapes);
    }
}
Also used : PrintStream(java.io.PrintStream) ShaclParseException(org.apache.jena.shacl.parser.ShaclParseException) Graph(org.apache.jena.graph.Graph) ShaclcParseException(org.apache.jena.shacl.compact.reader.ShaclcParseException) Shapes(org.apache.jena.shacl.Shapes)

Example 2 with ShaclcParseException

use of org.apache.jena.shacl.compact.reader.ShaclcParseException in project jena by apache.

the class ShaclcParser method parse$.

private static void parse$(ShaclCompactParserJJ parser, StreamRDF stream, String baseURI, Context context) {
    ParserProfile profile = new ParserProfileStd(RiotLib.factoryRDF(), ErrorHandlerFactory.errorHandlerStd, IRIxResolver.create(baseURI).build(), PrefixMapFactory.create(), context, false, false);
    SHACLC.addStandardPrefixes(profile.getPrefixMap());
    stream.start();
    parser.setDest(stream);
    parser.setProfile(profile);
    parser.start();
    try {
        parser.Unit();
    } catch (ParseException ex) {
        throw new ShaclcParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (TokenMgrError tErr) {
        int col = parser.token.endColumn;
        int line = parser.token.endLine;
        throw new ShaclcParseException(tErr.getMessage(), line, col);
    }
    parser.finish();
    stream.finish();
}
Also used : ShaclcParseException(org.apache.jena.shacl.compact.reader.ShaclcParseException) TokenMgrError(org.apache.jena.shacl.compact.reader.parser.TokenMgrError) ShaclcParseException(org.apache.jena.shacl.compact.reader.ShaclcParseException) ParseException(org.apache.jena.shacl.compact.reader.parser.ParseException)

Aggregations

ShaclcParseException (org.apache.jena.shacl.compact.reader.ShaclcParseException)2 PrintStream (java.io.PrintStream)1 Graph (org.apache.jena.graph.Graph)1 Shapes (org.apache.jena.shacl.Shapes)1 ParseException (org.apache.jena.shacl.compact.reader.parser.ParseException)1 TokenMgrError (org.apache.jena.shacl.compact.reader.parser.TokenMgrError)1 ShaclParseException (org.apache.jena.shacl.parser.ShaclParseException)1