Class: RedParse::UntilOpNode
- Inherits:
-
RawOpNode
show all
- Includes:
- KeywordOpNode
- Defined in:
- lib/redparse/node.rb,
lib/redparse/node.rb,
lib/redparse/ripper.rb,
lib/redparse/ReduceWithsFor_RedParse_1_9.rb,
lib/redparse/ReduceWithsFor_RedParse_1_8.rb
Constant Summary
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
#boolean_identity_params, #identity_params
Instance Method Summary
collapse
#unparse
Methods inherited from RawOpNode
create, #image, #raw_unparse
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!
#build_exemplars, #enumerate_exemplars, #identity_param
#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.
2960
2961
2962
2963
2964
2965
2966
2967
2968
|
# File 'lib/redparse/node.rb', line 2960
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
#condition ⇒ Object
2958
|
# File 'lib/redparse/node.rb', line 2958
def condition; right end
|
#consequent ⇒ Object
2959
|
# File 'lib/redparse/node.rb', line 2959
def consequent; left end
|
#do ⇒ Object
Also known as:
body
2971
|
# File 'lib/redparse/node.rb', line 2971
def do; consequent end
|
#op ⇒ Object
2973
|
# File 'lib/redparse/node.rb', line 2973
def op; "until" end
|
#parsetree(o) ⇒ Object
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
|
# File 'lib/redparse/node.rb', line 2976
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]
[kw, cond, body, tf]
end
|
#reducer_ident ⇒ Object
17555
17556
17557
|
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17555
def reducer_ident
:UntilOpNode
end
|
#reversed ⇒ Object
2974
|
# File 'lib/redparse/node.rb', line 2974
def reversed; true end
|
#rip(p) ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/redparse/ripper.rb', line 158
def rip p
if BeginNode===consequent
if @quirks
p.on_until_mod( condition.rip(p), consequent.rip(p) )
else
p.on_until_mod( consequent.rip(p), condition.rip(p), :loop_first )
end
else
p.on_until_mod( consequent.rip(p), condition.rip(p) )
end
end
|
#while ⇒ Object
2970
|
# File 'lib/redparse/node.rb', line 2970
def while; negate condition end
|