Search in sources :

Example 1 with ParseException

use of org.apache.jena.shex.parser.javacc.ParseException in project jena by apache.

the class ShExC method parseShapeMap$.

private static ShexMap parseShapeMap$(ShExJavacc parser, String baseURI, Context context) {
    ParserProfile profile = new ParserProfileStd(RiotLib.factoryRDF(), ErrorHandlerFactory.errorHandlerStd, IRIxResolver.create(baseURI).build(), PrefixMapFactory.create(), context, false, false);
    // addStandardPrefixes(profile.getPrefixMap());
    parser.setProfile(profile);
    // We don't use the StreamRDF.
    parser.setDest(StreamRDFLib.sinkNull());
    try {
        parser.parseShapeMapStart();
        parser.UnitShapeMap();
        ShexMap map = parser.parseShapeMapFinish();
        return map;
    } catch (ParseException ex) {
        throw new ShexParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (TokenMgrError tErr) {
        int col = parser.token.endColumn;
        int line = parser.token.endLine;
        throw new ShexParseException(tErr.getMessage(), line, col);
    }
}
Also used : ShexMap(org.apache.jena.shex.ShexMap) TokenMgrError(org.apache.jena.shex.parser.javacc.TokenMgrError) ParseException(org.apache.jena.shex.parser.javacc.ParseException)

Example 2 with ParseException

use of org.apache.jena.shex.parser.javacc.ParseException in project jena by apache.

the class ShExC method parse$.

// --------
private static ShexSchema parse$(ShExJavacc parser, String sourceURI, String baseURI, Context context) {
    ParserProfile profile = new ParserProfileStd(RiotLib.factoryRDF(), ErrorHandlerFactory.errorHandlerStd, IRIxResolver.create(baseURI).build(), PrefixMapFactory.create(), context, false, false);
    // addStandardPrefixes(profile.getPrefixMap());
    sourceURI = IRILib.filenameToIRI(sourceURI);
    parser.setProfile(profile);
    // We don't use the StreamRDF.
    parser.setDest(StreamRDFLib.sinkNull());
    parser.setSourceAndBase(sourceURI, baseURI);
    try {
        parser.parseShapesStart();
        parser.UnitShapes();
        ShexSchema shapes = parser.parseShapesFinish();
        validatePhase2(shapes);
        return shapes;
    } catch (ParseException ex) {
        throw new ShexParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
    } catch (TokenMgrError tErr) {
        int col = parser.token.endColumn;
        int line = parser.token.endLine;
        throw new ShexParseException(tErr.getMessage(), line, col);
    }
}
Also used : TokenMgrError(org.apache.jena.shex.parser.javacc.TokenMgrError) ParseException(org.apache.jena.shex.parser.javacc.ParseException) ShexSchema(org.apache.jena.shex.ShexSchema)

Aggregations

ParseException (org.apache.jena.shex.parser.javacc.ParseException)2 TokenMgrError (org.apache.jena.shex.parser.javacc.TokenMgrError)2 ShexMap (org.apache.jena.shex.ShexMap)1 ShexSchema (org.apache.jena.shex.ShexSchema)1