-
Notifications
You must be signed in to change notification settings - Fork 756
Description
Per spec, 1 - sibling-index() should serialize with 1 - (-1 * sibling-index()).
If
rootis a Negate node, letsbe a string initially containing "(-1 * ".[...]
[...]
If
rootis a Sum node, letsbe a string initially containing "(".[...]
For each
childofrootbeyond the first:
- If
childis a Negate node, append " - " tos, then serialize the Negate’s child and append the result tos.
It should presumably serialize as is. An equivalent problem exists for 2 / sibling-index().
I think steps 4 and 5 (Negate and Invert) can be removed: steps 6 and 7 could simply serialize the child of Negate and Invert, and wrap each serialization of their child in () when it is Sum or Product node (to handle cases like 1 - (1 * sibling-index()).
Alternatively, they could wrap their own serialization only when the parent node is a Sum or Product node, which requires to pass the parent node recursively, and to remove the following from serialize a math function, which seems a little awkward:
[...] If a result of this serialization starts with a "(" (open parenthesis) and ends with a ")" (close parenthesis), remove those characters from the result. [...]