Class: RedParse::OpNode

Inherits:
RawOpNode show all
Defined in:
lib/redparse/node.rb,
lib/redparse/node.rb

Direct Known Subclasses

MatchNode, NotEqualNode, NotMatchNode

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

Methods inherited from RawOpNode

create, #image, #raw_unparse

Methods inherited from ValueNode

#lvalue

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

#identity_name

Constructor Details

#initialize(left, op, right) ⇒ OpNode

Returns a new instance of OpNode.



1303
1304
1305
1306
1307
# File 'lib/redparse/node.rb', line 1303

def initialize(left,op,right)
  #@negative_of="="+$1 if /^!([=~])$/===op
  op=op.ident if op.respond_to? :ident
  super left,op,right      
end

Instance Method Details

#parsetree(o) ⇒ Object Also known as: opnode_parsetree



1312
1313
1314
1315
1316
1317
1318
# File 'lib/redparse/node.rb', line 1312

def parsetree(o)
  [:call, 
     left.rescue_parsetree(o), 
     op.to_sym, 
     [:array, right.rescue_parsetree(o)]
  ]
end

#to_lispObject



1308
1309
1310
# File 'lib/redparse/node.rb', line 1308

def to_lisp
  "(#{op} #{left.to_lisp} #{right.to_lisp})"
end

#unparse(o = default_unparse_options) ⇒ Object



1321
1322
1323
1324
1325
1326
1327
# File 'lib/redparse/node.rb', line 1321

def unparse o=default_unparse_options
  result=l=left.unparse(o)
  result+=" " if /\A(?:!|#{LCLETTER})/o===op
  result+=op
  result+=" " if /#{LETTER_DIGIT}\Z/o===op or / \Z/===l
  result+=right.unparse(o)      
end