@@ -58,17 +58,43 @@ func (n *UnaryNode) String() string {
5858}
5959
6060func (n * BinaryNode ) String () string {
61+ if n .Operator == ".." {
62+ return fmt .Sprintf ("%s..%s" , n .Left , n .Right )
63+ }
64+
6165 var lhs , rhs string
66+ var lwrap , rwrap bool
6267
6368 lb , ok := n .Left .(* BinaryNode )
64- if ok && (operator .Less (lb .Operator , n .Operator ) || lb .Operator == "??" ) {
69+ if ok {
70+ if operator .Less (lb .Operator , n .Operator ) {
71+ lwrap = true
72+ }
73+ if lb .Operator == "??" {
74+ lwrap = true
75+ }
76+ if operator .IsBoolean (lb .Operator ) && n .Operator != lb .Operator {
77+ lwrap = true
78+ }
79+ }
80+
81+ rb , ok := n .Right .(* BinaryNode )
82+ if ok {
83+ if operator .Less (rb .Operator , n .Operator ) {
84+ rwrap = true
85+ }
86+ if operator .IsBoolean (rb .Operator ) && n .Operator != rb .Operator {
87+ rwrap = true
88+ }
89+ }
90+
91+ if lwrap {
6592 lhs = fmt .Sprintf ("(%s)" , n .Left .String ())
6693 } else {
6794 lhs = n .Left .String ()
6895 }
6996
70- rb , ok := n .Right .(* BinaryNode )
71- if ok && operator .Less (rb .Operator , n .Operator ) {
97+ if rwrap {
7298 rhs = fmt .Sprintf ("(%s)" , n .Right .String ())
7399 } else {
74100 rhs = n .Right .String ()
@@ -132,7 +158,7 @@ func (n *ClosureNode) String() string {
132158}
133159
134160func (n * PointerNode ) String () string {
135- return "#"
161+ return fmt . Sprintf ( "#%s" , n . Name )
136162}
137163
138164func (n * VariableDeclaratorNode ) String () string {
0 commit comments