Work on more readable ast for express schema parser

This commit is contained in:
Thomas Krijnen
2022-07-10 21:51:25 +02:00
parent 443af3f7e7
commit bab6313313
4 changed files with 375 additions and 1339 deletions
@@ -161,7 +161,7 @@ statements = []
terminals = reduce(lambda x, y: x | y, (find_bytype(e, Terminal) for id, e in express))
keywords = list(filter(operator.attrgetter("is_keyword"), terminals))
negated_keywords = map(lambda s: "~%s" % s, keywords)
no_action = {"letter", "digit", "digits", "real_literal", "integer_literal"}
no_action = {"letter", "digit", "digits", "real_literal", "integer_literal", "string_literal", "simple_string_literal", "letter", "not_quote", "not_paren_star_quote_special"}
while True:
emitted_in_loop = set()
@@ -199,8 +199,8 @@ for id in to_emit:
stmt = "(%s)%s" % (stmt, action)
statements.append("%s << %s" % (id, stmt))
print(
"""
if __name__ == "__main__":
print("""
# This file is generated by IfcOpenShell ifcexpressparser bootstrap.py
import os
@@ -238,6 +238,5 @@ if __name__ == "__main__":
mdl = importlib.import_module(output)
mdl.Generator(m).emit()
sys.stdout.write(m.schema.name)
"""
% ("\n ".join(statements))
)
""" % ("\n ".join(statements))
)