Class: RedParse::BlockNode

Inherits:
ValueNode show all
Defined in:
lib/redparse/node.rb,
lib/redparse/ReduceWithsFor_RedParse_1_9.rb,
lib/redparse/ReduceWithsFor_RedParse_1_8.rb

Overview

not to appear in final parse tree

Constant Summary

Constants included from FlattenedIvars

FlattenedIvars::EXCLUDED_IVARS

Instance Attribute Summary collapse

Attributes inherited from Node

#endline, #errors, #offset, #parent, #startline

Attributes included from Stackable::Meta

#boolean_identity_params, #identity_params

Instance Method Summary collapse

Methods inherited from ValueNode

#lvalue, #reducer_method

Methods inherited from Node

#+, #+@, #==, [], #[]=, #add_parent_links!, #args_rip, #begin_parsetree, #classic_inspect, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #force_stmt_list_rip, #image, #initialize_ivars, inline_symbols, #inspect, #lhs_unparse, #linerange, #lvalue, #lvars_defined_in, #merge_replacement_session, namelist, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #rescue_parsetree, #rfind, #rfind_all, #rgrep, #rip_and_rescues, #rip_explode!, #short_inspect, #stmts_rip, #to_parsetree, #to_parsetree_and_warnings, #to_ruby, #to_s, #unary, #walk, #xform_tree!

Methods included from Stackable::Meta

#build_exemplars, #enumerate_exemplars, #identity_param

Methods included from FlattenedIvars

#flattened_ivars, #flattened_ivars_equal?

Methods included from Stackable

#identity_name

Constructor Details

#initialize(open_brace, formals, stmts, close_brace) ⇒ BlockNode

Returns a new instance of BlockNode.



3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
# File 'lib/redparse/node.rb', line 3414

def initialize(open_brace,formals,stmts,close_brace)
  stmts||=SequenceNode[{:@offset => open_brace.offset, :@startline=>open_brace.startline}]
  stmts=SequenceNode[stmts,{:@offset => open_brace.offset, :@startline=>open_brace.startline}] unless SequenceNode===stmts
  
  if formals and formals.size==1 and SequenceNode===formals[0]
    formals,blocklocals,* = formals[0]
    formals&&=BlockParams[formals]
    if CommaOpNode===blocklocals
      blocklocals=Array(blocklocals)
    else
      blocklocals=[blocklocals]
    end
    blocklocals.map!{|bl| bl.ident}
    blocklocals.extend ListInNode
  end

  formals&&=BlockParams.new(Array.new(formals))
  @do_end=true unless open_brace.not_real?
  super(formals,blocklocals,stmts)
end

Instance Attribute Details

#do_endObject (readonly)

Returns the value of attribute do_end.



3435
3436
3437
# File 'lib/redparse/node.rb', line 3435

def do_end
  @do_end
end

Instance Method Details

#parsetree(o) ⇒ Object

obsolete



3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
# File 'lib/redparse/node.rb', line 3441

def parsetree(o) #obsolete
  callsite=@data[0].parsetree(o)
  call=@data[0].data[0]
  callsite[0]=:fcall  if call.respond_to? :ident
  if call.respond_to? :ident
    case call.ident
    when "BEGIN" 
      if o[:quirks]
        return []
      else
        callsite=[:preexe] 
      end
    when "END"; callsite=[:postexe]
    end
  end
  result=[:iter, callsite, @data[1].parsetree(o)]
  result.push @data[2].parsetree(o) if @data[2]
  result
end

#reducer_identObject



17400
17401
17402
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17400

def reducer_ident
  :BlockNode
end

#to_lispObject



3437
3438
3439
# File 'lib/redparse/node.rb', line 3437

def to_lisp
  "(#{params.to_lisp} #{body.to_lisp})"
end