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


Python treewizard.TreeWizard类代码示例

本文整理汇总了Python中antlr3.treewizard.TreeWizard的典型用法代码示例。如果您正苦于以下问题:Python TreeWizard类的具体用法?Python TreeWizard怎么用?Python TreeWizard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testRepeatsIndex

 def testRepeatsIndex(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     tree = wiz.create("(A B (A C B) B D D)")
     indexMap = wiz.index(tree)
     found = self.__simplifyIndexMap(indexMap)
     expecting = { 8: ['D', 'D'], 6: ['B', 'B', 'B'], 7: ['C'], 5: ['A', 'A'] }
     self.failUnlessEqual(expecting, found)
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:7,代码来源:testtreewizard.py

示例2: testParseWithText

 def testParseWithText(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     t = wiz.create("(A B[foo] C[bar])")
     # C pattern has no text arg so despite [bar] in t, no need
     # to match text--check structure only.
     valid = wiz.parse(t, "(A B[foo] C)")
     self.failUnless(valid)
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:7,代码来源:testtreewizard.py

示例3: testFindPattern

 def testFindPattern(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     t = wiz.create("(A B C (A[foo] B[bar]) (D (A[big] B[dog])))")
     subtrees = wiz.find(t, "(A B)")
     found = [str(node) for node in subtrees]
     expecting = ['foo', 'big']
     self.assertEqual(expecting, found)
开发者ID:166MMX,项目名称:antlr3,代码行数:7,代码来源:testtreewizard.py

示例4: testSingleNodeIndex

 def testSingleNodeIndex(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     tree = wiz.create("ID")
     indexMap = wiz.index(tree)
     found = self.__simplifyIndexMap(indexMap)
     expecting = { 10: ["ID"] }
     self.failUnlessEqual(expecting, found)
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:7,代码来源:testtreewizard.py

示例5: testParseWithText2

 def testParseWithText2(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     t = wiz.create("(A B[T__32] (C (D E[a])))")
     # C pattern has no text arg so despite [bar] in t, no need
     # to match text--check structure only.
     valid = wiz.parse(t, "(A B[foo] C)")
     self.assertEquals("(A T__32 (C (D a)))", t.toStringTree())
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:7,代码来源:testtreewizard.py

示例6: testNoRepeatsIndex

 def testNoRepeatsIndex(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     tree = wiz.create("(A B C D)")
     indexMap = wiz.index(tree)
     found = self.__simplifyIndexMap(indexMap)
     expecting = { 8:['D'], 6:['B'], 7:['C'], 5:['A'] }
     self.assertEqual(expecting, found)
开发者ID:166MMX,项目名称:antlr3,代码行数:7,代码来源:testtreewizard.py

示例7: testFindTokenType

 def testFindTokenType(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     t = wiz.create("(A B C (A[foo] B[bar]) (D (A[big] B[dog])))")
     subtrees = wiz.find(t, wiz.getTokenType('A'))
     found = [str(node) for node in subtrees]
     expecting = ['A', 'foo', 'big']
     self.failUnlessEqual(expecting, found)
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:7,代码来源:testtreewizard.py

示例8: testComplex

 def testComplex(self):
     adaptor = CommonTreeAdaptor()
     wiz = TreeWizard(adaptor, self.tokens)
     t = wiz.create("(A (B (C D E) F) G)")
     it = TreeIterator(t)
     expecting = "A DOWN B DOWN C DOWN D E UP F UP G UP EOF"
     found = self.toString(it)
     self.assertEquals(expecting, found)
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:8,代码来源:testtree.py

示例9: testNode

 def testNode(self):
     adaptor = CommonTreeAdaptor()
     wiz = TreeWizard(adaptor, self.tokens)
     t = wiz.create("A")
     it = TreeIterator(t)
     expecting = "A EOF"
     found = self.toString(it)
     self.assertEquals(expecting, found)
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:8,代码来源:testtree.py

示例10: testABC

 def testABC(self):
     adaptor = CommonTreeAdaptor()
     wiz = TreeWizard(adaptor, self.tokens)
     t = wiz.create("(A B C)")
     it = TreeIterator(t)
     expecting = "A DOWN B C UP EOF"
     found = self.toString(it)
     self.assertEqual(expecting, found)
开发者ID:166MMX,项目名称:antlr3,代码行数:8,代码来源:testtree.py

示例11: testFlatAB

 def testFlatAB(self):
     adaptor = CommonTreeAdaptor()
     wiz = TreeWizard(adaptor, self.tokens)
     t = wiz.create("(nil A B)")
     it = TreeIterator(t)
     expecting = "nil DOWN A B UP EOF"
     found = self.toString(it)
     self.assertEquals(expecting, found)
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:8,代码来源:testtree.py

示例12: testParseWithWildcardLabels

 def testParseWithWildcardLabels(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     t = wiz.create("(A B C)")
     labels = {}
     valid = wiz.parse(t, "(A %b:. %c:.)", labels)
     self.failUnless(valid)
     self.failUnlessEqual("B", str(labels["b"]))
     self.failUnlessEqual("C", str(labels["c"]))
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:8,代码来源:testtreewizard.py

示例13: testVerticalList

 def testVerticalList(self):
     adaptor = CommonTreeAdaptor()
     wiz = TreeWizard(adaptor, self.tokens)
     t = wiz.create("(A (B C))")
     it = TreeIterator(t)
     expecting = "A DOWN B DOWN C UP UP EOF"
     found = self.toString(it)
     self.assertEquals(expecting, found)
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:8,代码来源:testtree.py

示例14: testParseLabels

 def testParseLabels(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     t = wiz.create("(A B C)")
     labels = {}
     valid = wiz.parse(t, "(%a:A %b:B %c:C)", labels)
     self.assertTrue(valid)
     self.assertEqual("A", str(labels["a"]))
     self.assertEqual("B", str(labels["b"]))
     self.assertEqual("C", str(labels["c"]))
开发者ID:166MMX,项目名称:antlr3,代码行数:9,代码来源:testtreewizard.py

示例15: testParseLabelsAndTestText

 def testParseLabelsAndTestText(self):
     wiz = TreeWizard(self.adaptor, self.tokens)
     t = wiz.create("(A B[foo] C)")
     labels = {}
     valid = wiz.parse(t, "(%a:A %b:B[foo] %c:C)", labels)
     self.failUnless(valid)
     self.failUnlessEqual("A", str(labels["a"]))
     self.failUnlessEqual("foo", str(labels["b"]))
     self.failUnlessEqual("C", str(labels["c"]))
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:9,代码来源:testtreewizard.py


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