本文整理汇总了Python中pymeta.runtime.OMetaBase.exactly方法的典型用法代码示例。如果您正苦于以下问题:Python OMetaBase.exactly方法的具体用法?Python OMetaBase.exactly怎么用?Python OMetaBase.exactly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymeta.runtime.OMetaBase
的用法示例。
在下文中一共展示了OMetaBase.exactly方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_interleave
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import exactly [as 别名]
def test_interleave(self):
"""
L{OMetaBase.interleave} matched randomly mixed parts
"""
o = OMetaBase("ab")
d = dict()
v, e = o._interleave(d, '1', lambda: o.exactly('a'), None, '*', lambda: o.exactly('b'), 'x')
self.assertEqual((v, e), (['a', ['b']], [1, None]))
self.assertIn('x', d)
self.assertEqual(d['x'], ['b'])
示例2: test_consumed_by
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import exactly [as 别名]
def test_consumed_by(self):
"""
L{OMetaBase.consumed_by} return the full matched string, not each matched parts
"""
o = OMetaBase("aax")
v, e = o.consumed_by(lambda: o.many(lambda: o.exactly("a")))
self.assertEqual((v, e), ("aa", _MaybeParseError(2, [('expected', None, 'a')])))
示例3: test_listpattern
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import exactly [as 别名]
def test_listpattern(self):
"""
L{OMetaBase.rule_listpattern} matches contents of lists.
"""
o = OMetaBase([["a"]])
v, e = o.listpattern(lambda: o.exactly("a"))
self.assertEqual((v, e), (["a"], [0, None]))
示例4: test_notError
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import exactly [as 别名]
def test_notError(self):
"""
When L{OMetaBase._not} fails, its error contains the current input position and no error info.
"""
data = "xy"
o = OMetaBase(data)
e = self.assertRaises(ParseError, o._not, lambda: o.exactly("x"))
self.assertEqual(e[0], 1)
self.assertEqual(e[1], None)
示例5: test_notError
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import exactly [as 别名]
def test_notError(self):
"""
When L{OMetaBase._not} fails, its error contains the current input position and no error info.
"""
data = "xy"
o = OMetaBase(data)
try:
o._not(lambda: o.exactly("x"))
except _MaybeParseError, e:
self.assertEqual(e[0], 1)
self.assertEqual(e[1], None)