BoolParenthesis wraps the given boolean node in parens. This is useful for grouping and avoiding ambiguity. This does not work for mathematical parenthesis to change order of operations.
(value BooleanNode)
| 12 | // This is useful for grouping and avoiding ambiguity. This does not work for |
| 13 | // mathematical parenthesis to change order of operations. |
| 14 | func BoolParenthesis(value BooleanNode) BooleanNode { |
| 15 | // Wrapping primitives is useless. |
| 16 | if IsPrimitive(value) { |
| 17 | return value |
| 18 | } |
| 19 | |
| 20 | // Unwrap any existing parens. Do not add excess parens. |
| 21 | if p, ok := value.(astParenthesis); ok { |
| 22 | return BoolParenthesis(p.Value) |
| 23 | } |
| 24 | return astParenthesis{Value: value} |
| 25 | } |
| 26 | |
| 27 | func (astParenthesis) IsBooleanNode() {} |
| 28 | func (p astParenthesis) UseAs() Node { return p.Value.UseAs() } |
no test coverage detected