def testLabel(self):
     """TreePatternParser: '(%a:A)'"""
     lexer = TreePatternLexer('(%a:A)')
     parser = TreePatternParser(lexer, self.wizard, TreePatternTreeAdaptor())
     tree = parser.pattern()
     self.failUnless(isinstance(tree, TreePattern))
     self.failUnlessEqual(tree.label, 'a')
Exemple #2
0
 def testNil(self):
     """TreePatternParser: 'nil'"""
     lexer = TreePatternLexer('nil')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.assertIsInstance(tree, CommonTree)
     self.assertEqual(tree.getType(), 0)
     self.assertIsNone(tree.getText())
 def testNil(self):
     """TreePatternParser: 'nil'"""
     lexer = TreePatternLexer('nil')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.failUnless(isinstance(tree, CommonTree))
     self.failUnlessEqual(tree.getType(), 0)
     self.failUnlessEqual(tree.getText(), None)
 def testSingleNodeWithArg(self):
     """TreePatternParser: 'ID[foo]'"""
     lexer = TreePatternLexer('ID[foo]')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.failUnless(isinstance(tree, CommonTree))
     self.failUnlessEqual(tree.getType(), 10)
     self.failUnlessEqual(tree.getText(), 'foo')
Exemple #5
0
 def testSingleNode(self):
     """TreePatternParser: 'ID'"""
     lexer = TreePatternLexer('ID')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.assertIsInstance(tree, CommonTree)
     self.assertEqual(tree.getType(), 10)
     self.assertEqual(tree.getText(), 'ID')
Exemple #6
0
 def testNil(self):
     """TreePatternParser: 'nil'"""
     lexer = TreePatternLexer('nil')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.assertIsInstance(tree, CommonTree)
     self.assertEqual(tree.getType(), 0)
     self.assertIsNone(tree.getText())
Exemple #7
0
 def testSingleNode(self):
     """TreePatternParser: 'ID'"""
     lexer = TreePatternLexer('ID')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.assertIsInstance(tree, CommonTree)
     self.assertEqual(tree.getType(), 10)
     self.assertEqual(tree.getText(), 'ID')
 def testSingleLevelTree(self):
     """TreePatternParser: '(A B)'"""
     lexer = TreePatternLexer('(A B)')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.failUnless(isinstance(tree, CommonTree))
     self.failUnlessEqual(tree.getType(), 5)
     self.failUnlessEqual(tree.getText(), 'A')
     self.failUnlessEqual(tree.getChildCount(), 1)
     self.failUnlessEqual(tree.getChild(0).getType(), 6)
     self.failUnlessEqual(tree.getChild(0).getText(), 'B')
 def testError3(self):
     """TreePatternParser: '(A ])'"""
     lexer = TreePatternLexer('(A ])')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.failUnless(tree is None)
 def testWildcard(self):
     """TreePatternParser: '(.)'"""
     lexer = TreePatternLexer('(.)')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.failUnless(isinstance(tree, WildcardTreePattern))
Exemple #11
0
 def testError2(self):
     """TreePatternParser: '()'"""
     lexer = TreePatternLexer('()')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.assertIsNone(tree)
Exemple #12
0
 def testError2(self):
     """TreePatternParser: '()'"""
     lexer = TreePatternLexer('()')
     parser = TreePatternParser(lexer, self.wizard, self.adaptor)
     tree = parser.pattern()
     self.assertIsNone(tree)