Class: RedParse::UntilOpNode

Inherits:
RawOpNode show all
Includes:
KeywordOpNode
Defined in:
lib/redparse/node.rb,
lib/redparse/node.rb

Constant Summary

Constants included from FlattenedIvars

FlattenedIvars::EXCLUDED_IVARS

Instance Attribute Summary

Attributes inherited from Node

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

Attributes included from Stackable::Meta

#boolean_identity_params, #identity_params

Instance Method Summary collapse

Methods included from KeywordOpNode

#unparse

Methods inherited from RawOpNode

create, #image, #raw_unparse

Methods inherited from ValueNode

#lvalue

Methods inherited from Node

#+, #+@, #==, [], #[]=, #add_parent_links!, #begin_parsetree, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #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, #to_parsetree, #to_parsetree_and_warnings, #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(val1, op, val2 = nil) ⇒ UntilOpNode

Returns a new instance of UntilOpNode.



2786
2787
2788
2789
2790
2791
2792
2793
2794
# File 'lib/redparse/node.rb', line 2786

def initialize(val1,op,val2=nil)
  op,val2=nil,op unless val2
  op=op.ident if op.respond_to? :ident
  @reverse=true
  @loop=true
  @test_first= !( BeginNode===val1 ) 
  replace [val1,val2]
  condition.special_conditions! if condition.respond_to? :special_conditions!
end

Instance Method Details

#conditionObject



2784
# File 'lib/redparse/node.rb', line 2784

def condition; right end

#consequentObject



2785
# File 'lib/redparse/node.rb', line 2785

def consequent; left end

#doObject



2797
# File 'lib/redparse/node.rb', line 2797

def do; consequent end

#opObject



2798
# File 'lib/redparse/node.rb', line 2798

def op; "until" end

#parsetree(o) ⇒ Object



2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
# File 'lib/redparse/node.rb', line 2800

def parsetree(o)
  cond=condition.rescue_parsetree(o)
  body=consequent.parsetree(o)
  !@test_first and
    body.size == 2 and
      body.first == :begin and
        body=body.last
  if cond.first==:not
    kw=:while
    cond=cond.last
  else
    kw=:until
  end
  tf=@test_first||body==[:nil]
#        tf||= (!consequent.body and !consequent.else and #!consequent.empty_else and
#               !consequent.ensure and !consequent.empty_ensure and consequent.rescues.empty?
#              ) if BeginNode===consequent
  [kw, cond, body, tf]
end

#whileObject



2796
# File 'lib/redparse/node.rb', line 2796

def while; negate condition end