| Class | WadlerExample::Tree |
| In: |
lib/prettyprint.rb
|
| Parent: | Object |
# File lib/prettyprint.rb, line 578
578: def initialize(string, *children)
579: @string = string
580: @children = children
581: end
# File lib/prettyprint.rb, line 607
607: def altshow(q)
608: q.group {
609: q.text @string
610: unless @children.empty?
611: q.text '['
612: q.nest(2) {
613: q.breakable
614: first = true
615: @children.each {|t|
616: if first
617: first = false
618: else
619: q.text ','
620: q.breakable
621: end
622: t.altshow(q)
623: }
624: }
625: q.breakable
626: q.text ']'
627: end
628: }
629: end
# File lib/prettyprint.rb, line 583
583: def show(q)
584: q.group {
585: q.text @string
586: q.nest(@string.length) {
587: unless @children.empty?
588: q.text '['
589: q.nest(1) {
590: first = true
591: @children.each {|t|
592: if first
593: first = false
594: else
595: q.text ','
596: q.breakable
597: end
598: t.show(q)
599: }
600: }
601: q.text ']'
602: end
603: }
604: }
605: end