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


Python CommonTree.getChild方法代码示例

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


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

示例1: test4Nodes

# 需要导入模块: from antlr3.tree import CommonTree [as 别名]
# 或者: from antlr3.tree.CommonTree import getChild [as 别名]
    def test4Nodes(self):
        # ^(101 ^(102 103) 104)
        r0 = CommonTree(CommonToken(101))
        r0.addChild(CommonTree(CommonToken(102)))
        r0.getChild(0).addChild(CommonTree(CommonToken(103)))
        r0.addChild(CommonTree(CommonToken(104)))

        self.failUnless(r0.parent is None)
        self.failUnlessEqual(-1, r0.childIndex)
开发者ID:aopui,项目名称:antlr,代码行数:11,代码来源:testtree.py

示例2: test4Nodes

# 需要导入模块: from antlr3.tree import CommonTree [as 别名]
# 或者: from antlr3.tree.CommonTree import getChild [as 别名]
    def test4Nodes(self):
        # ^(101 ^(102 103) 104)
        r0 = CommonTree(CommonToken(101))
        r0.addChild(CommonTree(CommonToken(102)))
        r0.getChild(0).addChild(CommonTree(CommonToken(103)))
        r0.addChild(CommonTree(CommonToken(104)))

        self.assertIsNone(r0.parent)
        self.assertEqual(-1, r0.childIndex)
开发者ID:166MMX,项目名称:antlr3,代码行数:11,代码来源:testtree.py

示例3: testLT

# 需要导入模块: from antlr3.tree import CommonTree [as 别名]
# 或者: from antlr3.tree.CommonTree import getChild [as 别名]
    def testLT(self):
        # ^(101 ^(102 103) 104)
        t = CommonTree(CommonToken(101))
        t.addChild(CommonTree(CommonToken(102)))
        t.getChild(0).addChild(CommonTree(CommonToken(103)))
        t.addChild(CommonTree(CommonToken(104)))

        stream = self.newStream(t)
        self.failUnlessEqual(101, stream.LT(1).getType())
        self.failUnlessEqual(DOWN, stream.LT(2).getType())
        self.failUnlessEqual(102, stream.LT(3).getType())
        self.failUnlessEqual(DOWN, stream.LT(4).getType())
        self.failUnlessEqual(103, stream.LT(5).getType())
        self.failUnlessEqual(UP, stream.LT(6).getType())
        self.failUnlessEqual(104, stream.LT(7).getType())
        self.failUnlessEqual(UP, stream.LT(8).getType())
        self.failUnlessEqual(EOF, stream.LT(9).getType())
        # check way ahead
        self.failUnlessEqual(EOF, stream.LT(100).getType())
开发者ID:aopui,项目名称:antlr,代码行数:21,代码来源:testtree.py

示例4: testList

# 需要导入模块: from antlr3.tree import CommonTree [as 别名]
# 或者: from antlr3.tree.CommonTree import getChild [as 别名]
    def testList(self):
        root = CommonTree(None)

        t = CommonTree(CommonToken(101))
        t.addChild(CommonTree(CommonToken(102)))
        t.getChild(0).addChild(CommonTree(CommonToken(103)))
        t.addChild(CommonTree(CommonToken(104)))

        u = CommonTree(CommonToken(105))

        root.addChild(t)
        root.addChild(u)

        stream = CommonTreeNodeStream(root)
        expecting = "101 102 103 104 105"
        found = self.toNodesOnlyString(stream)
        self.failUnlessEqual(expecting, found)

        expecting = "101 2 102 2 103 3 104 3 105"
        found = str(stream)
        self.failUnlessEqual(expecting, found)
开发者ID:aopui,项目名称:antlr,代码行数:23,代码来源:testtree.py


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