better printing for OpNodes with running with --nodes

This commit is contained in:
Jeremy Ashkenas
2010-07-10 11:17:44 -04:00
parent 6f32fe27f8
commit 49020208f9

View File

@@ -111,9 +111,10 @@ exports.BaseNode: class BaseNode
# `toString` representation of the node, for inspecting the parse tree.
# This is what `coffee --nodes` prints out.
toString: (idt) ->
toString: (idt, override) ->
idt: or ''
'\n' + idt + @class + (child.toString(idt + TAB) for child in @collectChildren()).join('')
children: (child.toString idt + TAB for child in @collectChildren()).join('')
'\n' + idt + (override or @class) + children
eachChild: (func) ->
return unless @children
@@ -1014,6 +1015,9 @@ exports.OpNode: class OpNode extends BaseNode
isChainable: ->
indexOf(@CHAINABLE, @operator) >= 0
toString: (idt) ->
super(idt, @class + ' ' + @operator)
compileNode: (o) ->
o.operation: true
return @compileChain(o) if @isChainable() and @first.unwrap() instanceof OpNode and @first.unwrap().isChainable()