本文整理汇总了Python中pymeta.runtime.OMetaBase.rule_letter方法的典型用法代码示例。如果您正苦于以下问题:Python OMetaBase.rule_letter方法的具体用法?Python OMetaBase.rule_letter怎么用?Python OMetaBase.rule_letter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymeta.runtime.OMetaBase
的用法示例。
在下文中一共展示了OMetaBase.rule_letter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_letter
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_letter [as 别名]
def test_letter(self):
"""
L{OMetaBase.rule_letter} matches letters.
"""
o = OMetaBase("a1")
v, e = o.rule_letter()
self.assertEqual((v, e), ("a", [0, None]))
try:
o.rule_letter()
except _MaybeParseError, e:
self.assertEqual(e, _MaybeParseError(1, expected("letter")))
示例2: test_letter
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_letter [as 别名]
def test_letter(self):
"""
L{OMetaBase.rule_letter} matches letters.
"""
o = OMetaBase("a1")
v, e = o.rule_letter()
self.assertEqual((v, e), ("a", [0, None]))
e = self.assertRaises(ParseError, o.rule_letter)
self.assertEqual(e, ParseError(1, expected("letter")))
示例3: OMetaBase
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_letter [as 别名]
o = OMetaBase(u"a1")
v, e = o.rule_letter()
self.assertEqual((v, e), ("a", [0, None]))
try:
o.rule_letter()
except _MaybeParseError, e:
self.assertEqual(e, _MaybeParseError(1, expected("letter")))
else:
self.fail('_MaybeParseError not raised')
data = u"fooåßæøπœ∑" #TODO greek letter rule
data = u"fooåßæø"
o = OMetaBase(data)
for i, c in enumerate(data):
v, e = o.rule_letter()
self.assertEqual((c, i), (v, e[0]))
def test_letterOrDigit(self):
"""
L{OMetaBase.rule_letterOrDigit} matches alphanumerics.
"""
o = OMetaBase("[email protected]")
v, e = o.rule_letterOrDigit()
self.assertEqual((v, e), ("a", [0, None]))
v, e = o.rule_letterOrDigit()
self.assertEqual((v, e), ("1", [1, None]))
try:
o.rule_letterOrDigit()
except _MaybeParseError, e: