本文整理汇总了Python中pymeta.runtime.OMetaBase.many方法的典型用法代码示例。如果您正苦于以下问题:Python OMetaBase.many方法的具体用法?Python OMetaBase.many怎么用?Python OMetaBase.many使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymeta.runtime.OMetaBase
的用法示例。
在下文中一共展示了OMetaBase.many方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_end
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import many [as 别名]
def test_end(self):
"""
L{OMetaBase.rule_end} matches the end of input and raises L{ParseError}
if input is left.
"""
o = OMetaBase("abc")
e = self.assertRaises(ParseError, o.rule_end)
self.assertEqual(e, ParseError(1, None))
o.many(o.rule_anything)
self.assertEqual(o.rule_end(), (True, [3, None]))
示例2: test_end
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import many [as 别名]
def test_end(self):
"""
L{OMetaBase.rule_end} matches the end of input and raises L{_MaybeParseError}
if input is left.
"""
o = OMetaBase("abc")
try:
o.rule_end()
except _MaybeParseError as e:
self.assertEqual(e, _MaybeParseError(1, None))
else:
self.fail('_MaybeParseError not raised')
o.many(o.rule_anything)
self.assertEqual(o.rule_end(), (True, _MaybeParseError(3, None)))
示例3: test_consumed_by
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import many [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')])))
示例4: test_many
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import many [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'))))