def print_grammar(grammar_txt, grammar_fname): g_parser = HandRolledGrammarParser(grammar_txt, grammar_fname) g_ast, err = g_parser.parse() if err: return None, err g, _ = Analyzer(g_ast).analyze() printer = GrammarPrinter(g) return printer.parse()
def __init__(self, grammar, classname, package, inline_base): self.grammar = grammar self.classname = classname self.package = package self.inline_base = inline_base self.printer = GrammarPrinter(grammar) self.val = None self.err = None self.indent = 0 self.shiftwidth = 4 self.istr = ' ' * self.shiftwidth