Class: RedParse::WhileOpNode
- 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
- #condition ⇒ Object
- #consequent ⇒ Object
- #do ⇒ Object
-
#initialize(val1, op, val2 = nil) ⇒ WhileOpNode
constructor
A new instance of WhileOpNode.
- #op ⇒ Object
- #parsetree(o) ⇒ Object
- #while ⇒ Object
Methods included from KeywordOpNode
Methods inherited from RawOpNode
Methods inherited from ValueNode
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
Constructor Details
#initialize(val1, op, val2 = nil) ⇒ WhileOpNode
Returns a new instance of WhileOpNode.
2748 2749 2750 2751 2752 2753 2754 2755 2756 |
# File 'lib/redparse/node.rb', line 2748 def initialize(val1,op,val2=nil) op,val2=nil,op unless val2 op=op.ident if op.respond_to? :ident @reverse=false @loop=true @test_first= !( BeginNode===val1 ) replace [val1,val2] condition.special_conditions! if condition.respond_to? :special_conditions! end |
Instance Method Details
#condition ⇒ Object
2746 |
# File 'lib/redparse/node.rb', line 2746 def condition; right end |
#consequent ⇒ Object
2747 |
# File 'lib/redparse/node.rb', line 2747 def consequent; left end |
#do ⇒ Object
2759 |
# File 'lib/redparse/node.rb', line 2759 def do; consequent end |
#op ⇒ Object
2760 |
# File 'lib/redparse/node.rb', line 2760 def op; "while" end |
#parsetree(o) ⇒ Object
2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 |
# File 'lib/redparse/node.rb', line 2762 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=:until cond=cond.last else kw=:while end [kw, cond, body, (@test_first or body==[:nil])] end |
#while ⇒ Object
2758 |
# File 'lib/redparse/node.rb', line 2758 def while; condition end |