Esempio n. 1
0
    def test_parseDentry(self):
        self.assertTrue(
            NameTreeParsers.parseDentry("/=>!") == Dentry(
                Path.empty, NameTree.Fail))

        self.assertTrue(
            NameTreeParsers.parseDentry("/ => !") == Dentry(
                Path.empty, NameTree.Fail))

        self.assertTrue(
            NameTreeParsers.parseDentry("/foo/*/bar => !") == Dentry(
                Dentry.Prefix(
                    Dentry.Prefix.Label("foo"), Dentry.Prefix.AnyElem,
                    Dentry.Prefix.Label("bar")), NameTree.Fail))

        self.assertTrue(
            NameTreeParsers.parseDentry("/foo/bar/baz => !") == Dentry(
                Dentry.Prefix(Dentry.Prefix.Label("foo"),
                              Dentry.Prefix.Label("bar"),
                              Dentry.Prefix.Label("baz")), NameTree.Fail))

        with self.assertRaises(IllegalArgumentException):
            NameTreeParsers.parseDentry("/foo/*bar/baz => !")

        with self.assertRaises(IllegalArgumentException):
            NameTreeParsers.parseDentry("/&!")
Esempio n. 2
0
    def read(cls, s):
        """Parse a Dentry from the string `s` with concrete syntax:
       {{{
       dentry	::= prefix '=>' tree
       }}}

       where the production `prefix` is from the grammar documented in
       Prefix.read and the production `tree` is from the grammar
       documented in dtab.tree.NameTree.read.
    """
        return NameTreeParsers.parseDentry(s)
Esempio n. 3
0
  def read(cls, s):
    """Parse a Dentry from the string `s` with concrete syntax:
       {{{
       dentry	::= prefix '=>' tree
       }}}

       where the production `prefix` is from the grammar documented in
       Prefix.read and the production `tree` is from the grammar
       documented in dtab.tree.NameTree.read.
    """
    return NameTreeParsers.parseDentry(s)
Esempio n. 4
0
  def test_parseDentry(self):
    self.assertTrue(NameTreeParsers.parseDentry("/=>!") == Dentry(Path.empty, NameTree.Fail))

    self.assertTrue(NameTreeParsers.parseDentry("/ => !") == Dentry(Path.empty, NameTree.Fail))

    self.assertTrue(NameTreeParsers.parseDentry("/foo/*/bar => !") == Dentry(
        Dentry.Prefix(
            Dentry.Prefix.Label("foo"),
            Dentry.Prefix.AnyElem,
            Dentry.Prefix.Label("bar")),
        NameTree.Fail))

    self.assertTrue(NameTreeParsers.parseDentry("/foo/bar/baz => !") == Dentry(
        Dentry.Prefix(
            Dentry.Prefix.Label("foo"),
            Dentry.Prefix.Label("bar"),
            Dentry.Prefix.Label("baz")),
        NameTree.Fail))

    with self.assertRaises(IllegalArgumentException):
      NameTreeParsers.parseDentry("/foo/*bar/baz => !")

    with self.assertRaises(IllegalArgumentException):
      NameTreeParsers.parseDentry("/&!")