def do_parse(infilename: str, jsonfilename: Optional[str], rdffilename: Optional[str], rdffmt: str,
             context: Optional[str] = None) -> bool:
    """
    Parse the jsg in infilename and save the results in outfilename
    :param infilename: name of the file containing the ShExC
    :param jsonfilename: target ShExJ equivalent
    :param rdffilename: target ShExR equivalent
    :param rdffmt: target RDF format
    :param context: @context to use for rdf generation. If None use what is in the file
    :return: true if success
    """
    shexj = parse(FileStream(infilename, encoding="utf-8"))
    if shexj is not None:
        shexj['@context'] = context if context else "http://www.w3.org/ns/shex.jsonld"
        if jsonfilename:
            with open(jsonfilename, 'w') as outfile:
                outfile.write(shexj._as_json_dumps())
        if rdffilename:
            g = Graph().parse(data=shexj._as_json, format="json-ld")
            g.serialize(open(rdffilename, "wb"), format=rdffmt)
        return True
    return False