generators.ET0LTreeGrammar:
( { D, H, D**, D*, H*, Ha*, Hb*, Dh, Hh, Hah, Hbh  },
  { inner:0, edge:0, edge2:0, edges:0, corner:0, corner2:0, hole-corner:0, q:4, d:4, h:2, rot90:1, rot180:1, rot270:1, flip:1, empty:0 },
  {
    { % 1: Plaiting table
      %
      D -> d[inner, H, H, D],
      H -> h[inner, H],
      D** -> d[inner, Hb*, Ha*, D*],
      D* -> d[inner, H*, H*, D*],
      H* -> h[inner, H*],
      Ha* -> h[inner, Ha*],
      Hb* -> h[inner, Hb*],
      Dh -> d[empty, Hh, Hh, Dh],
      Hh -> h[empty, Hh],
      Hah -> h[rot270[edge], Hah],
      Hbh -> h[rot90[edge], Hbh]
    },
    { % 2: `mark' nonterminals to produce holes
      %
      D -> D**
    },
    { % 3: let marked nonterminals build inner edge of hole
      %
      D** -> d[hole-corner, Hbh, Hah, Dh],
      D* -> d[corner, Hh, Hh, Dh],
      H* -> h[edge, Hh],
      Ha* -> h[hole-corner, Hah],
      Hb* -> h[rot90[hole-corner], Hbh],
      H -> h[inner, H]
    },
    { % 4: build outer edge of hole
      %
      Dh -> d[rot180[hole-corner], H, H, D],
      Hh -> h[rot180[edge], H],
      Hah -> h[rot270[hole-corner], H],
      Hbh -> h[rot180[hole-corner], H],
      H -> h[inner, H]
    },
    { % 5: build outer edge of hole, continue with marked nonterminals
      %
      Dh -> d[rot180[hole-corner], H*, H*, D*],
      Hh -> h[rot180[edge], H*],
      Hah -> h[rot270[hole-corner], Ha*],
      Hbh -> h[rot180[hole-corner], Hb*],
      H -> h[inner, H]
    },
    { % 6: Terminating table
      %
      D -> corner,
      H -> edge,
      Dh -> empty,
      Hh -> empty,
      Hah -> rot270[flip[corner]],
      Hbh -> flip[corner]
    },
    { % 7: Alternative terminating table
      %
      D -> corner2,
      H -> edge2,
      Dh -> empty,
      Hh -> empty,
      Hah -> rot270[flip[corner2]],
      Hbh -> flip[corner2]
    },
    { % 8: Directly start making holes in centre
      %
      D -> Dh
    }
  },
  q[D,D,D,D],
  % Perhaps start with a hole in the centre
    [8 1* 4] 1*
  % then there may or may not be holes
    [
  %   produce at least one hole, always carrying over the markings
      2 1* 3 1* (5 1* 3 1*)*
  %   close hole, not carrying over markings, repeat arbitrarily
      (4 1* 2 1* 3 1* (5 1* 3 1*)*)*
  %   maybe close last hole
      [4]
    ]
  % terminate
    6,7
  
)
