| 49 | } |
| 50 | |
| 51 | func (n *UnaryNode) String() string { |
| 52 | op := n.Operator |
| 53 | if n.Operator == "not" { |
| 54 | op = fmt.Sprintf("%s ", n.Operator) |
| 55 | } |
| 56 | wrap := false |
| 57 | switch b := n.Node.(type) { |
| 58 | case *BinaryNode: |
| 59 | if operator.Binary[b.Operator].Precedence < |
| 60 | operator.Unary[n.Operator].Precedence { |
| 61 | wrap = true |
| 62 | } |
| 63 | case *ConditionalNode: |
| 64 | wrap = true |
| 65 | } |
| 66 | if wrap { |
| 67 | return fmt.Sprintf("%s(%s)", op, n.Node.String()) |
| 68 | } |
| 69 | return fmt.Sprintf("%s%s", op, n.Node.String()) |
| 70 | } |
| 71 | |
| 72 | func (n *BinaryNode) String() string { |
| 73 | if n.Operator == ".." { |