def test_parseDtab(self): self.assertTrue(NameTreeParsers.parseDtab("") == Dtab.empty) self.assertTrue( NameTreeParsers.parseDtab(" /=>! ") == Dtab( [Dentry(Path.empty, NameTree.Fail)])) self.assertTrue( NameTreeParsers.parseDtab("/=>!;") == Dtab( [Dentry(Path.empty, NameTree.Fail)])) self.assertTrue( NameTreeParsers.parseDtab("/=>!;/foo=>/bar") == Dtab([ Dentry(Path.empty, NameTree.Fail), Dentry(Path.Utf8("foo"), NameTree.Leaf(Path.Utf8("bar"))) ]))
def test_parseDtab(self): self.assertTrue(NameTreeParsers.parseDtab("") == Dtab.empty) self.assertTrue( NameTreeParsers.parseDtab(" /=>! ") == Dtab( [Dentry(Path.empty, NameTree.Fail)] ) ) self.assertTrue(NameTreeParsers.parseDtab("/=>!;") == Dtab( [Dentry(Path.empty, NameTree.Fail)] )) self.assertTrue(NameTreeParsers.parseDtab("/=>!;/foo=>/bar") == Dtab([ Dentry(Path.empty, NameTree.Fail), Dentry(Path.Utf8("foo"), NameTree.Leaf(Path.Utf8("bar"))) ]))
def read(cls, s): """Parse a Dtab from string `s` whit concrete syntax {{{ dtab ::= dentry ';' dtab | dentry }}} where the production `dentry` is from the grammar documented in dtab.Dentry.read """ return NameTreeParsers.parseDtab(s)