本文整理汇总了Python中pymeta.runtime.OMetaBase.rule_exactly方法的典型用法代码示例。如果您正苦于以下问题:Python OMetaBase.rule_exactly方法的具体用法?Python OMetaBase.rule_exactly怎么用?Python OMetaBase.rule_exactly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymeta.runtime.OMetaBase
的用法示例。
在下文中一共展示了OMetaBase.rule_exactly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_exactlyFail
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_exactly [as 别名]
def test_exactlyFail(self):
"""
L{OMetaBase.rule_exactly} raises L{_MaybeParseError} when the requested item
doesn't match the input. The error contains info on what was expected
and the position.
"""
data = "foo"
o = OMetaBase(data)
try:
o.rule_exactly("g")
except _MaybeParseError, e:
self.assertEquals(e[1], expected(None, "g"))
self.assertEquals(e[0], 0)
示例2: test_many
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_exactly [as 别名]
def test_many(self):
"""
L{OMetaBase.many} returns a list of parsed values and the error that
caused the end of the loop.
"""
data = "ooops"
o = OMetaBase(data)
self.assertEqual(o.many(lambda: o.rule_exactly('o')), (['o'] * 3, ParseError(3, expected(None, 'o'))))
示例3: test_exactly
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_exactly [as 别名]
def test_exactly(self):
"""
L{OMetaBase.rule_exactly} returns the requested item from the input
string along with its position, if it's there.
"""
data = "foo"
o = OMetaBase(data)
v, e = o.rule_exactly("f")
self.assertEqual(v, "f")
self.assertEqual(e[0], 0)