Loading ...
Sorry, an error occurred while loading the content.

Re: [sgf-std] Extra Parens Well-Formed?

Expand Messages
  • Arno Hollosi
    Ashley, sorry for the delay in answering. ... Correct. It does not matter that a branch does not have any siblings. ... I guess this comes from the EBNF
    Message 1 of 2 , Jul 6 1:00 AM
    • 0 Attachment
      Ashley,

      sorry for the delay in answering.

      > Just to be certain, extra parenthesis are still 'well-formed' SGF?
      > (;N[A](;N[B](;N[C](;N[D]))(;N[E])))
      > is the same tree as:
      > (;N[A];N[B](;N[C];N[D])(;N[E]))
      > and should be handled correctly by all parsers?

      Correct. It does not matter that a branch does not have any siblings.

      > Not that it could possibly be changed at this point, but I'm curious:
      > Why the use of semicolons in addition to parenthesis.

      I guess this comes from the EBNF definition:

      Collection = GameTree { GameTree }
      GameTree = "(" Sequence { GameTree } ")"
      Sequence = Node { Node }
      Node = ";" { Property }

      > In the former case all of the semicolons are excessive.
      > Why not: (N[A](N[B](N[C](N[D]))(N[E])))

      Because in a game of 250 moves you would have to add 250 closing parenthesis
      at the end.

      > For non-branching game records the standard way is best. Is this savings
      > the reasoning?

      I think so. Furthermore, non-branching games are the majority of all
      game-records. Even the records of the Go Teaching Ladder contain only about 5
      branches on average.

      > The difficulty comes when trying to output SGF without requiring
      > foreknowledge of whether a particular node has siblings.

      Is that foreknowledge not always present? Don't all SGF programs have some
      internal tree structure in which they hold moves (aka XML-DOM model)? If your
      program has an internal tree-structure writing SGF is easy:

      WriteTree(Root)
      End

      WriteTree(Node)
      Write(Node)
      for each child of Node
      WriteTree(child)
      end for
      end

      In case of SGF filters (aka XML-SAX model) that don't add new branches just
      keep the paranthesis, even if they become superfluous afterwards. It doesn't
      heart the parsers.

      /Arno
    Your message has been successfully submitted and would be delivered to recipients shortly.