def make_context(self): c = Context() for name, recordset in self._db.items(): for r in recordset: if hasattr(r, 'fixity'): c.bind_operator(name, r.graph, r.assoc, r.prec, r.fixity) else: c.bind(name, r.graph) return c
from graph import NodePtr, PrimitiveNode, LabelledValue from utils import rset from context import Context, OperatorRecord default_context = Context() #---------------------------# # builtin type objects # #---------------------------# # type is a weird object; it is its own type _type = LabelledValue('type') _type.add_type(_type) default_context.bind('type', _type) def _make_primitive_type(name): tmp = LabelledValue(name) tmp.add_type(_type) default_context.bind(name, tmp) return tmp def _make_primitive_types(*names): return map(_make_primitive_type, names) int_type, char_type, str_type = _make_primitive_types('int', 'char', 'string') # The unit and bool types are special; instances of them are not constructed # at runtime, they already exist. def _make_enum_type(overall_type_name, *constructor_names):