pyrser/grammar.py
def from_file(fn: str, entry=None, *optional_inherit) -> Grammar:
    """
    Create a Grammar from a file
    """
    import os.path
    if os.path.exists(fn):
        f = open(fn, 'r')
        bnf = f.read()
        f.close()
        inherit = [Grammar] + list(optional_inherit)
        scope = {'grammar': bnf, 'entry': entry, 'source': fn}
        return build_grammar(tuple(inherit), scope)
    raise Exception("File not Found!")
def from_file(fn: str, entry=None, *optional_inherit) -> Grammar:
    import os.path
    if os.path.exists(fn):
        f = open(fn, 'r')
        bnf = f.read()
        f.close()
        inherit = [Grammar] + list(optional_inherit)
        scope = {'grammar': bnf, 'entry': entry, 'source': fn}
        return build_grammar(tuple(inherit), scope)
    raise Exception("File not Found!")
def from_file ( fn : str , entry = None , * optional_inherit ) -> Grammar : import os . path if os . path . exists ( fn ) : f = open ( fn , 'r' ) bnf = f . read ( ) f . close ( ) inherit = [ Grammar ] + list ( optional_inherit ) scope = { 'grammar' : bnf , 'entry' : entry , 'source' : fn } return build_grammar ( tuple ( inherit ) , scope ) raise Exception ( "File not Found!" )
Create a Grammar from a file
Create a Grammar from a file