Beautiful SGF indentation
Posted: Wed Mar 04, 2015 11:43 pm
Hi,
I'm writing a JavaScript SGF parser/stringifier that supports FF[1], FF[3] and FF[4].
The stringify method takes optional "space" parameter that is used to insert white space into
the output SGF string, though it's not implemented yet.
I want the output SGF string to satisfy the SGF specification:
FF[1]
FF[3]
FF[4]
[off topic]
By the way, the above description is a little bit ambiguous for me.
I'm not sure about where I can/can't insert white spaces exactly.
Do all of the following strings satisfy the specification?
FF[1]
FF[3]
FF[4]
[/off topic]
What is your favorite SGF indentation?
My favorite one is something like this, while I'm not sure about whether it's valid SGF or not
I'm writing a JavaScript SGF parser/stringifier that supports FF[1], FF[3] and FF[4].
The stringify method takes optional "space" parameter that is used to insert white space into
the output SGF string, though it's not implemented yet.
I want the output SGF string to satisfy the SGF specification:
FF[1]
Spaces, tabs, line breaks and so on can be inserted anywhere between properties and are also ignored.
http://www.red-bean.com/sgf/ff1_3/ff1.html
FF[3]
"White space" (Spaces, tabs, carriage return, line feed, line breaks, vertical tab and so on) can be inserted before the first opening parenthesis or anywhere between properties and are ignored when reading a file.
http://www.red-bean.com/sgf/ff1_3/ff3.html
FF[4]
White space (space, tab, carriage return, line feed, vertical tab and so on) may appear anywhere between PropValues, Properties, Nodes, Sequences and GameTrees.
http://www.red-bean.com/sgf/sgf4.html
[off topic]
By the way, the above description is a little bit ambiguous for me.
I'm not sure about where I can/can't insert white spaces exactly.
Do all of the following strings satisfy the specification?
FF[1]
Code: Select all
( ; B [pd] ( ; W [qp] ) ) FF[3]
Code: Select all
( ; FF [3] B [pd] ( ; W [qp] ) ) FF[4]
Code: Select all
( ; FF [4] B [pd] ( ; W [qp] ) ) [/off topic]
What is your favorite SGF indentation?
My favorite one is something like this, while I'm not sure about whether it's valid SGF or not
Code: Select all
(
;FF[4]
C[root]
B[pd]
;C[a]
W[qp]
(
;C[b]
B[cd]
;C[c]
W[dp]
)
)