Class: RedParse::ForNode
- 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
RedParse::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
- #image ⇒ Object
-
#initialize(forword, for_, inword, in_, doword, do_, endword) ⇒ ForNode
constructor
A new instance of ForNode.
- #parsetree(o) ⇒ Object
- #reducer_ident ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
Methods inherited from ValueNode
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
Constructor Details
#initialize(forword, for_, inword, in_, doword, do_, endword) ⇒ ForNode
Returns a new instance of ForNode.
4594 4595 4596 4597 4598 4599 4600 |
# File 'lib/redparse/node.rb', line 4594 def initialize(forword,for_,inword,in_,doword,do_,endword) @offset=forword.offset #elide 1 layer of parens if present for_=for_.first if ParenedNode===for_ for_=CommaOpNode===for_ ? Array.new(for_) : [for_] super(BlockParams.new(for_),in_,do_) end |
Instance Method Details
#image ⇒ Object
4606 |
# File 'lib/redparse/node.rb', line 4606 def image; "(for)" end |
#parsetree(o) ⇒ Object
4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 |
# File 'lib/redparse/node.rb', line 4614 def parsetree(o) =begin case vars=@data[0] when Node: vars=vars.parsetree(o) if vars.first==:call vars[0]=:attrasgn vars[2]="#{vars[2]}=".to_sym end vars when Array: vars=[:masgn, [:array, *vars.map{|lval| res=lval.parsetree(o) res[0]=lval.varname2assigntype if VarNode===lval res } ]] when VarNode ident=vars.ident vars=vars.parsetree(o) (vars[0]=vars.varname2assigntype) rescue nil else fail end =end vars=self.for.lvalue_parsetree(o) collection= self.in.begin_parsetree(o) if ParenedNode===self.in and collection.first==:begin assert collection.size==2 collection=collection[1] end result=[:for, collection, vars] result.push self.do.parsetree(o) if self.do result end |
#reducer_ident ⇒ Object
17505 17506 17507 |
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17505 def reducer_ident :ForNode end |
#unparse(o = default_unparse_options) ⇒ Object
4608 4609 4610 4611 4612 |
# File 'lib/redparse/node.rb', line 4608 def unparse o= result=unparse_nl(self,o,"")+" for #{iterator.lhs_unparse(o)[1...-1]} in #{enumerable.unparse o}" result+=unparse_nl(body,o)+" #{body.unparse(o)}" if body result+=";end" end |