当前位置: 首页>>代码示例>>Python>>正文


Python OMetaBase.token方法代码示例

本文整理汇总了Python中pymeta.runtime.OMetaBase.token方法的典型用法代码示例。如果您正苦于以下问题:Python OMetaBase.token方法的具体用法?Python OMetaBase.token怎么用?Python OMetaBase.token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymeta.runtime.OMetaBase的用法示例。


在下文中一共展示了OMetaBase.token方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_orErrorTie

# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import token [as 别名]
    def test_orErrorTie(self):
        """
        When branches of L{OMetaBase._or} produce errors that tie for rightmost
        position, they are merged.
        """

        data = "foozle"
        o = OMetaBase(data)

        v, e = o._or([lambda: o.token("fog"),
                      lambda: o.token("foz"),
                      lambda: o.token("f")])
        self.assertEqual(e[0], 2)
        self.assertEqual(e[1], [expected("token", "fog")[0], expected("token", "foz")[0]])
开发者ID:bdauvergne,项目名称:pymeta,代码行数:16,代码来源:test_runtime.py

示例2: test_orFalseSuccess

# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import token [as 别名]
    def test_orFalseSuccess(self):
        """
        When a failing branch of L{OMetaBase._or} gets further than a
        succeeding one, its error is returned instead of the success branch's.
        """

        data = "foozle"
        o = OMetaBase(data)

        v, e = o._or([lambda: o.token("fog"),
                      lambda: o.token("foozik"),
                      lambda: o.token("f")])
        self.assertEqual(e[0], 4)
        self.assertEqual(e[1], expected("token", "foozik"))
开发者ID:bdauvergne,项目名称:pymeta,代码行数:16,代码来源:test_runtime.py

示例3: test_orSimpleFailure

# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import token [as 别名]
    def test_orSimpleFailure(self):
        """
        When none of the alternatives passed to L{OMetaBase._or} succeed, the
        one that got the furthest is returned.
        """

        data = "foozle"
        o = OMetaBase(data)

        e = self.assertRaises(ParseError, o._or,
                              [lambda: o.token("fog"),
                               lambda: o.token("foozik"),
                               lambda: o.token("woozle")])
        self.assertEqual(e[0], 4)
        self.assertEqual(e[1], expected("token",  "foozik"))
开发者ID:jskopek,项目名称:pmtest,代码行数:17,代码来源:test_runtime.py

示例4: test_orSimpleFailure

# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import token [as 别名]
    def test_orSimpleFailure(self):
        """
        When none of the alternatives passed to L{OMetaBase._or} succeed, the
        one that got the furthest is returned.
        """

        data = "foozle"
        o = OMetaBase(data)

        try:
            o._or([lambda: o.token("fog"),
                   lambda: o.token("foozik"),
                   lambda: o.token("woozle")])
        except _MaybeParseError as e:
            self.assertEqual(e[0], 4)
            self.assertEqual(e[1], expected("token", "foozik"))
        else:
            self.fail('_MaybeParseError not raised')
开发者ID:regimantas,项目名称:nova-pyvascript,代码行数:20,代码来源:test_runtime.py


注:本文中的pymeta.runtime.OMetaBase.token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。