Exemple #1
0
    def test_factory(self):
        g = GrammaGrammar.of("start:='a';")
        self.assertEqual(str(g.ruledefs['start'].rhs), "'a'")

        fileobj = StringIO("start:='a';")
        g = GrammaGrammar.of(fileobj)
        self.assertEqual(str(g.ruledefs['start'].rhs), "'a'")

        g = GrammaGrammar.of(g)
        self.assertEqual(str(g.ruledefs['start'].rhs), "'a'")
Exemple #2
0
 def test_grammar_of(self):
     with self.assertRaises(TypeError):
         GrammaGrammar.of(17)