本文整理汇总了Python中context.Context.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Context.bind方法的具体用法?Python Context.bind怎么用?Python Context.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.bind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_context
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import bind [as 别名]
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
示例2: Context
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import bind [as 别名]
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):