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
- 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
- NEGATED_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.
{ '!~': :=~ }.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 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 22 def process_binary(exp) _, left, op, right = exp.shift 4 if op == :=~ make_regexp_match_operator(op, left, right) elsif (mapped = NEGATED_BINARY_OPERATOR_MAP[op]) s(:not, make_regexp_match_operator(mapped, left, right)) elsif (mapped = BINARY_OPERATOR_MAP[op]) make_boolean_operator(mapped, left, right) elsif SHIFT_OPERATORS.include? op s(:call, process(left), op, process(right)) else s(:call, handle_operator_argument(left), op, handle_operator_argument(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.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 45 def process_dot2(exp) _, left, right = exp.shift 3 left = process(left) right = process(right) if literal?(left) && literal?(right) 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.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 56 def process_dot3(exp) _, left, right = exp.shift 3 left = process(left) right = process(right) if literal?(left) && literal?(right) 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.
67 68 69 70 71 72 73 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 67 def process_ifop(exp) _, cond, truepart, falsepart = exp.shift 4 s(:if, handle_operator_argument(cond), handle_operator_argument(truepart), handle_operator_argument(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.
38 39 40 41 42 43 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 38 def process_unary(exp) _, op, arg = exp.shift 3 arg = handle_operator_argument(arg) op = UNARY_OPERATOR_MAP[op] || op s(:call, arg, op) end |