Class: RedParse::OpNode
- 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
Direct Known Subclasses
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
-
#initialize(left, op, right) ⇒ OpNode
constructor
A new instance of OpNode.
- #parsetree(o) ⇒ Object (also: #opnode_parsetree)
- #reducer_ident ⇒ Object
- #rip(p) ⇒ Object
- #to_lisp ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
Methods inherited from RawOpNode
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 Stackable::Meta
#build_exemplars, #enumerate_exemplars, #identity_param
Methods included from FlattenedIvars
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
Constructor Details
#initialize(left, op, right) ⇒ OpNode
Returns a new instance of OpNode.
1395 1396 1397 1398 1399 |
# File 'lib/redparse/node.rb', line 1395 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
1404 1405 1406 1407 1408 1409 1410 |
# File 'lib/redparse/node.rb', line 1404 def parsetree(o) [:call, left.rescue_parsetree(o), op.to_sym, [:array, right.rescue_parsetree(o)] ] end |
#reducer_ident ⇒ Object
17465 17466 17467 |
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17465 def reducer_ident :OpNode end |
#rip(p) ⇒ Object
109 110 111 |
# File 'lib/redparse/ripper.rb', line 109 def rip p p.on_binary(left.rip(p), op.to_sym, right.rip(p)) end |
#to_lisp ⇒ Object
1400 1401 1402 |
# File 'lib/redparse/node.rb', line 1400 def to_lisp "(#{op} #{left.to_lisp} #{right.to_lisp})" end |
#unparse(o = default_unparse_options) ⇒ Object
1413 1414 1415 1416 1417 1418 1419 |
# File 'lib/redparse/node.rb', line 1413 def unparse o= 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 |