Mercurial > lcfOS
diff python/testpyy.py @ 195:37ac6c016e0f
Expanded asm subsystem
author | Windel Bouwman |
---|---|
date | Fri, 31 May 2013 21:06:44 +0200 |
parents | b01429a5d695 |
children |
line wrap: on
line diff
--- a/python/testpyy.py Wed May 29 22:36:37 2013 +0200 +++ b/python/testpyy.py Fri May 31 21:06:44 2013 +0200 @@ -48,7 +48,7 @@ g.start_symbol = 'stmt' p = g.genParser() # Ambiguous program: - tokens = genTokens(['if', 'then','if', 'then', 'ass', 'else', 'ass' ]) + tokens = genTokens(['if', 'then','if', 'then', 'ass', 'else', 'ass']) p.parse(tokens) def testUndefinedTerminal(self): @@ -104,6 +104,22 @@ tokens = genTokens(['id', 'id']) # i.e. "inc rax" p.parse(tokens) + def test_cb(self): + """ Test callback of one rule and order or parameters """ + self.cb_called = False + def cb(a, c, b): + self.cb_called = True + self.assertEqual(a, 'a') + self.assertEqual(b, 'b') + self.assertEqual(c, 'c') + g = Grammar(['a', 'b', 'c']) + g.add_production('goal', ['a', 'c', 'b'], cb) + g.start_symbol = 'goal' + p = g.genParser() + tokens = genTokens(['a', 'c', 'b']) + p.parse(tokens) + self.assertTrue(self.cb_called) + class testExpressionGrammar(unittest.TestCase): def setUp(self):