diff test/testpyy.py @ 319:8d07a4254f04

Work on burg
author Windel Bouwman
date Sat, 18 Jan 2014 18:58:43 +0100
parents e84047f29c78
children 4d204f6f7d4e
line wrap: on
line diff
--- a/test/testpyy.py	Tue Dec 31 12:38:15 2013 +0100
+++ b/test/testpyy.py	Sat Jan 18 18:58:43 2014 +0100
@@ -1,6 +1,6 @@
 import unittest
 from pyyacc import Grammar, Item, ParserGenerationException, ParserException
-from pyyacc import EPS, EOF
+from pyyacc import EPS, EOF, calculate_first_sets
 from ppci import Token
 
 
@@ -123,6 +123,18 @@
         tokens = genTokens(['id', 'id'])   # i.e. "inc rax"
         p.parse(tokens)
 
+    def testEpsSequence(self):
+        """ Test epsilon terminal for use in sequences """
+        g = Grammar(['a'])
+        g.add_production('aas', [])
+        g.add_production('aas', ['aas', 'a'])
+        g.start_symbol = 'aas'
+        p = g.genParser()
+        tokens = genTokens(['a', 'a', 'a'])
+        p.parse(tokens)
+        tokens = genTokens([])
+        p.parse(tokens)
+
     def test_cb(self):
         """ Test callback of one rule and order or parameters """
         self.cb_called = False
@@ -156,7 +168,7 @@
 
     def testFirstSimpleGrammar(self):
         # 1. define a simple grammar:
-        first = self.g.calcFirstSets()
+        first = calculate_first_sets(self.g)
         self.assertEqual(first['input'], {'identifier', '(', 'num'})
         self.assertEqual(first['term'], {'identifier', '(', 'num'})