def parse(input_: Union[str, FileStream], default_base: Optional[str]=None) -> Optional[Schema]:
<EOL>error_listener = ParseErrorListener()<EOL>if not isinstance(input_, FileStream):<EOL><INDENT>input_ = InputStream(input_)<EOL><DEDENT>lexer = ShExDocLexer(input_)<EOL>lexer.addErrorListener(error_listener)<EOL>tokens = CommonTokenStream(lexer)<EOL>tokens.fill()<EOL>if error_listener.n_errors:         <EOL><INDENT>return None<EOL><DEDENT>parser = ShExDocParser(tokens)<EOL>parser.addErrorListener(error_listener)<EOL>parse_tree = parser.shExDoc()<EOL>if error_listener.n_errors:<EOL><INDENT>print('<STR_LIT:\n>'.join(error_listener.errors), file=sys.stderr)<EOL>return None<EOL><DEDENT>parser = ShexDocParser(default_base=default_base)<EOL>parser.visit(parse_tree)<EOL>return parser.context.schema<EOL>
Parse the text in infile and return the resulting schema
:param input_: text or input stream to parse
:param default_base_: base URI for relative URI's in schema
:return: ShExJ Schema object.  None if error.