Class: RedParse::StringCatNode
- Defined in:
- lib/redparse/node.rb,
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 RedParse::Stackable::Meta
#boolean_identity_params, #identity_params
Instance Method Summary collapse
-
#initialize(*strses) ⇒ StringCatNode
constructor
A new instance of StringCatNode.
- #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, #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!
Methods included from RedParse::Stackable::Meta
#build_exemplars, #enumerate_exemplars, #identity_param
Methods included from FlattenedIvars
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
Constructor Details
#initialize(*strses) ⇒ StringCatNode
Returns a new instance of StringCatNode.
1641 1642 1643 1644 1645 1646 1647 |
# File 'lib/redparse/node.rb', line 1641 def initialize(*strses) strs=strses.pop.unshift( *strses ) hd=strs.shift if HereDocNode===strs.first strs.map!{|str| StringNode.new(str)} strs.unshift hd if hd super( *strs ) end |
Instance Method Details
#parsetree(o) ⇒ Object
1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 |
# File 'lib/redparse/node.rb', line 1648 def parsetree(o) result=map{|str| str.parsetree(o)} sum='' type=:str tree=i=nil result.each_with_index{|tree2,i2| tree,i=tree2,i2 sum+=tree[1] tree.first==:str or break(type=:dstr) } [type,sum,*tree[2..-1]+result[i+1..-1].inject([]){|cat,x| if x.first==:dstr x.shift x0=x[0] if x0=='' and x.size==2 x.shift else x[0]=[:str,x0] end cat+x elsif x.last.empty? cat else cat+[x] end } ] end |
#reducer_ident ⇒ Object
17550 17551 17552 |
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17550 def reducer_ident :StringCatNode end |
#unparse(o = default_unparse_options) ⇒ Object
1676 1677 1678 |
# File 'lib/redparse/node.rb', line 1676 def unparse o= map{|ss| ss.unparse(o)}.join ' ' end |