module RedParse::ListInNode::HasRescue
Public Instance Methods
parsetree_and_rescues(o)
click to toggle source
# File lib/redparse/node.rb, line 2082 def parsetree_and_rescues(o) body=body() body=body.clone if body target=result=[] #was: [:begin, ] #body,rescues,else_,ensure_=*self target.push target=[:ensure, ] if ensure_ or @empty_ensure rescues=rescues().map{|resc| resc.parsetree(o)} if rescues.empty? if else_ body= body ? SequenceNode.new(body,nil,else_) : else_ end else_=nil else target.push newtarget=[:rescue, ] else_=else_() end if body # needbegin= (BeginNode===body and body.after_equals) body=body.parsetree(o) # body=[:begin, body] if needbegin and body.first!=:begin and !o[:ruby187] (newtarget||target).push body if body end target.push ensure_.parsetree(o) if ensure_ target.push [:nil] if @empty_ensure target=newtarget if newtarget unless rescues.empty? target.push linked_list(rescues) end target.push else_.parsetree(o) if else_ #and !body result.size==0 and result=[[:nil]] if o[:ruby187] and !rescues.empty? result.unshift :begin else result=result.last end result end
unparse_and_rescues(o)
click to toggle source
# File lib/redparse/node.rb, line 2123 def unparse_and_rescues(o) result=" " result+= body.unparse(o) if body result+=unparse_nl(rescues.first,o) if rescues rescues.each{|resc| result+=resc.unparse(o) } if rescues result+=unparse_nl(else_,o)+"else "+else_.unparse(o) if else_ result+=";else" if defined? @empty_else and @empty_else result+=unparse_nl(ensure_,o)+"ensure "+ensure_.unparse(o) if ensure_ result+=";ensure" if defined? @empty_ensure and @empty_ensure return result end