Module: RipperRubyParser::SexpHandlers::Operators Private
- Defined in:
- lib/ripper_ruby_parser/sexp_handlers/operators.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Sexp handlers for operators
Constant Summary collapse
- BINARY_OPERATOR_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ "&&": :and, "||": :or, and: :and, or: :or }.freeze
- BINARY_LOGICAL_OPERATORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
BINARY_OPERATOR_MAP.keys.freeze
- UNARY_OPERATOR_MAP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ not: :! }.freeze
- SHIFT_OPERATORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[:<<, :>>].freeze
Instance Method Summary collapse
- #process_binary(exp) ⇒ Object private
- #process_dot2(exp) ⇒ Object private
- #process_dot3(exp) ⇒ Object private
- #process_ifop(exp) ⇒ Object private
- #process_unary(exp) ⇒ Object private
Instance Method Details
#process_binary(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 22 def process_binary(exp) _, left, op, right = exp.shift 4 case op when :=~ make_regexp_match_operator(left, op, right) when :!~ s(:not, make_regexp_match_operator(left, :=~, right)) when *BINARY_LOGICAL_OPERATORS make_boolean_operator(left, op, right) when *SHIFT_OPERATORS s(:call, unwrap_begin(process(left)), op, unwrap_begin(process(right))) when :"=>" make_rightward_assignment(left, right) else s(:call, process(left), op, process(right)) end end |
#process_dot2(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 48 def process_dot2(exp) _, left, right = exp.shift 3 left = process(left) right = process(right) if integer_literal?(left) && integer_literal?(right) with_line_number(left.line, s(:lit, Range.new(left[1], right[1]))) else s(:dot2, left, right) end end |
#process_dot3(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 59 def process_dot3(exp) _, left, right = exp.shift 3 left = process(left) right = process(right) if integer_literal?(left) && integer_literal?(right) with_line_number(left.line, s(:lit, Range.new(left[1], right[1], true))) else s(:dot3, left, right) end end |
#process_ifop(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 73 74 75 76 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 70 def process_ifop(exp) _, cond, truepart, falsepart = exp.shift 4 s(:if, process(cond), process(truepart), process(falsepart)) end |
#process_unary(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 44 45 46 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 41 def process_unary(exp) _, op, arg = exp.shift 3 arg = process(arg) op = UNARY_OPERATOR_MAP[op] || op s(:call, arg, op) end |