Class: RedParse::HereDocNode

Inherits:
StringNode 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 inherited from StringNode

StringNode::CHAROPT2NUM, StringNode::CHARSETFLAG2NUM, StringNode::DOWNSHIFT_STRING_TYPE, StringNode::DQ_ESC, StringNode::DQ_EVEN, StringNode::DQ_ODD, StringNode::ESCAPABLES, StringNode::EVEN_BSS, StringNode::EVEN_NUM_BSLASHES, StringNode::LETTER2ENCODING, StringNode::SQ_ESC, StringNode::SQ_EVEN, StringNode::SQ_ODD

Constants included from FlattenedIvars

FlattenedIvars::EXCLUDED_IVARS

Instance Attribute Summary collapse

Attributes inherited from StringNode

#char, #modifiers

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 StringNode

#Regexp_new, #depthwalk, #endline=, #escapable, #image, #initialize_ivars, #old_cat_initialize, #parsetree, #rip, #special_conditions!, #split_into_words, #to_lisp, #unparse_interior, #walk, #with_string_data

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, #parsetree, #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

Methods included from Stackable

#identity_name

Constructor Details

#initialize(token) ⇒ HereDocNode

Returns a new instance of HereDocNode.



4029
4030
4031
4032
4033
# File 'lib/redparse/node.rb', line 4029

def initialize(token)
  token.node=self
  super(token)
  @startline=token.string.startline
end

Instance Attribute Details

#list_to_appendObject

Returns the value of attribute list_to_append.



4034
4035
4036
# File 'lib/redparse/node.rb', line 4034

def list_to_append
  @list_to_append
end

Instance Method Details

#flattened_ivars_equal?(other) ⇒ Boolean

ignore instance vars in here documents when testing equality

Returns:

  • (Boolean)


4054
4055
4056
# File 'lib/redparse/node.rb', line 4054

def flattened_ivars_equal?(other) 
  StringNode===other
end

#reducer_identObject



17490
17491
17492
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17490

def reducer_ident
  :HereDocNode
end

#saw_body!Object

attr :token



4037
4038
4039
4040
4041
4042
4043
4044
4045
# File 'lib/redparse/node.rb', line 4037

def saw_body!     #not used
  replace with_string_data(token)
  @char=token.quote
  if @list_to_append
    size%2==1 and token << @list_to_append.shift
    push( *@list_to_append )
    remove_instance_variable :@list_to_append
  end
end

#translate_escapes(x) ⇒ Object



4047
4048
4049
4050
# File 'lib/redparse/node.rb', line 4047

def translate_escapes x
  return x if @char=="'"
  super
end

#unparse(o = default_unparse_options) ⇒ Object



4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
# File 'lib/redparse/node.rb', line 4058

def unparse o=default_unparse_options
  lead=unparse_nl(self,o,'',"\\\n")
  inner=unparse_interior o,@char,@char,
          case @char
          when "'" #single-quoted here doc is a special case; 
                   #\ and ' are not special within it
                   #(and therefore always escaped if converted to normal squote str)
                   /['\\]/ 
          when '"'; /#{DQ_EVEN}"/
          when "`"; /#{DQ_EVEN}`/
          else fail
          end 
  
  [lead,@char, inner, @char].join
end