Commits

Maciej Fijalkowski committed 85950d4

add boilerplate for the sourceparser

Comments (0)

Files changed (2)

kermit/__init__.py

+
+import os
+kermitdir = os.path.dirname(os.path.abspath(__file__))

kermit/sourceparser.py

+
+import py
+from pypy.rlib.parsing.ebnfparse import parse_ebnf, make_parse_function
+from kermit import kermitdir
+
+grammar = py.path.local(kermitdir).join('grammar.txt').read("rt")
+regexs, rules, ToAST = parse_ebnf(grammar)
+_parse = make_parse_function(regexs, rules, eof=True)
+
+class Transformer(object):
+    def visit_main(self, node):
+        xxx
+
+transformer = Transformer()
+
+def parse(source):
+    return transformer.visit_main(_parse(source))