本文整理汇总了Python中pymeta.runtime.OMetaBase.rule_digit方法的典型用法代码示例。如果您正苦于以下问题:Python OMetaBase.rule_digit方法的具体用法?Python OMetaBase.rule_digit怎么用?Python OMetaBase.rule_digit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymeta.runtime.OMetaBase
的用法示例。
在下文中一共展示了OMetaBase.rule_digit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_digit
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_digit [as 别名]
def test_digit(self):
"""
L{OMetaBase.rule_digit} matches digits.
"""
o = OMetaBase("1a")
v, e = o.rule_digit()
self.assertEqual((v, e), ("1", [0, None]))
try:
o.rule_digit()
except _MaybeParseError, e:
self.assertEqual(e, _MaybeParseError(1, expected("digit")))
示例2: test_digit
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_digit [as 别名]
def test_digit(self):
"""
L{OMetaBase.rule_digit} matches digits.
"""
o = OMetaBase("1a")
v, e = o.rule_digit()
self.assertEqual((v, e), ("1", [0, None]))
e = self.assertRaises(ParseError, o.rule_digit)
self.assertEqual(e, ParseError(1, expected("digit")))
示例3: test_digit
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_digit [as 别名]
self.assertEqual((c, i), (v, e[0]))
def test_digit(self):
"""
L{OMetaBase.rule_digit} matches digits.
"""
o = OMetaBase("1a")
v, e = o.rule_digit()
self.assertEqual((v, e), ("1", [0, None]))
try:
o.rule_digit()
except _MaybeParseError, e:
self.assertEqual(e, _MaybeParseError(1, expected("digit")))
else:
self.fail('_MaybeParseError not raised')
data = u"1234⁰¹²³⁴₀₁₂₃"
o = OMetaBase(data)
for i, c in enumerate(data):
v, e = o.rule_digit()
self.assertEqual((c, i), (v, e[0]))
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]))