Esempio n. 1
0
def _get_python_grammar():
    here = os.path.dirname(__file__)
    fp = open(os.path.join(here, "data", "Grammar2.7"))
    try:
        gram_source = fp.read()
    finally:
        fp.close()
    pgen = metaparser.ParserGenerator(gram_source)
    return pgen.build_grammar(PythonGrammar)
Esempio n. 2
0
 def parser_for(self, gram, add_endmarker=True):
     if add_endmarker:
         gram += " NEWLINE ENDMARKER\n"
     pgen = metaparser.ParserGenerator(gram)
     g = pgen.build_grammar(MyGrammar)
     return SimpleParser(g), g