Class: RedParse::ElsifNode

Inherits:
Node
  • Object
show all
Defined in:
lib/redparse/node.rb,
lib/redparse/ReduceWithsFor_RedParse_1_9.rb,
lib/redparse/ReduceWithsFor_RedParse_1_8.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 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, #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(elsifword, condition, thenword, consequent) ⇒ ElsifNode

Returns a new instance of ElsifNode.



4406
4407
4408
4409
4410
# File 'lib/redparse/node.rb', line 4406

def initialize(elsifword,condition,thenword,consequent)
  @offset=elsifword.offset
  condition.special_conditions! if condition.respond_to? :special_conditions!
  super(condition,consequent)
end

Instance Method Details

#imageObject



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

def image; "(elsif)" end

#parsetree(o) ⇒ Object

obsolete?



4426
4427
4428
# File 'lib/redparse/node.rb', line 4426

def parsetree(o) #obsolete?
  [:if, condition.rescue_parsetree(o), consequent&&consequent.parsetree(o), ]
end

#reducer_identObject



17248
17249
17250
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17248

def reducer_ident
  :ElsifNode
end

#reducer_method(stack) ⇒ Object



17245
17246
17247
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17245

def reducer_method(stack)
  :reduce_with_tos_ElsifNode
end

#to_lispObject



4422
4423
4424
# File 'lib/redparse/node.rb', line 4422

def to_lisp
  "("+condition.to_lisp+" "+consequent.to_lisp+")"
end

#unparse(o = default_unparse_options) ⇒ Object



4418
4419
4420
# File 'lib/redparse/node.rb', line 4418

def unparse o=default_unparse_options
  "elsif #{condition.unparse o}#{unparse_nl(consequent,o)}#{consequent.unparse o if consequent};"
end