mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Cache the output of the parsed express schema as a Python pickle stream for speedier code generation
This commit is contained in:
@@ -158,30 +158,42 @@ for id in to_emit:
|
|||||||
stmt = "Suppress%s" % stmt
|
stmt = "Suppress%s" % stmt
|
||||||
statements.append("%s << %s" % (id, stmt))
|
statements.append("%s << %s" % (id, stmt))
|
||||||
|
|
||||||
print ("""import sys
|
print ("""import os
|
||||||
from pyparsing import *
|
import sys
|
||||||
from nodes import *
|
import pickle
|
||||||
|
|
||||||
%s
|
cache_file = sys.argv[1] + ".cache.dat"
|
||||||
|
if os.path.exists(cache_file):
|
||||||
|
with open(cache_file, "rb") as f:
|
||||||
|
mapping = pickle.load(f)
|
||||||
|
else:
|
||||||
|
from pyparsing import *
|
||||||
|
from nodes import *
|
||||||
|
|
||||||
import schema
|
import schema
|
||||||
import mapping
|
import mapping
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
|
syntax.ignore(Regex(r"\((?:\*(?:[^*]*\*+)+?\))"))
|
||||||
|
ast = syntax.parseFile(sys.argv[1])
|
||||||
|
schema = schema.Schema(ast)
|
||||||
|
mapping = mapping.Mapping(schema)
|
||||||
|
|
||||||
|
with open(cache_file, "wb") as f:
|
||||||
|
pickle.dump(mapping, f, protocol=0)
|
||||||
|
|
||||||
import header
|
import header
|
||||||
import enum_header
|
import enum_header
|
||||||
import implementation
|
import implementation
|
||||||
import latebound_header
|
import latebound_header
|
||||||
import latebound_implementation
|
import latebound_implementation
|
||||||
|
import schema_class
|
||||||
syntax.ignore("--" + restOfLine)
|
|
||||||
syntax.ignore(Regex(r"\((?:\*(?:[^*]*\*+)+?\))"))
|
|
||||||
ast = syntax.parseFile(sys.argv[1])
|
|
||||||
schema = schema.Schema(ast)
|
|
||||||
mapping = mapping.Mapping(schema)
|
|
||||||
|
|
||||||
header.Header(mapping).emit()
|
header.Header(mapping).emit()
|
||||||
enum_header.EnumHeader(mapping).emit()
|
enum_header.EnumHeader(mapping).emit()
|
||||||
implementation.Implementation(mapping).emit()
|
implementation.Implementation(mapping).emit()
|
||||||
latebound_header.LateBoundHeader(mapping).emit()
|
latebound_header.LateBoundHeader(mapping).emit()
|
||||||
latebound_implementation.LateBoundImplementation(mapping).emit()
|
latebound_implementation.LateBoundImplementation(mapping).emit()
|
||||||
"""%('\n'.join(statements)))
|
schema_class.SchemaClass(mapping).emit()
|
||||||
|
"""%('\n '.join(statements)))
|
||||||
|
|||||||
Reference in New Issue
Block a user