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.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 24 def process_binary(exp) _, left, op, right = exp.shift 4 if op == :=~ make_regexp_match_operator(left, op, right) elsif (mapped = NEGATED_BINARY_OPERATOR_MAP[op]) s(:not, make_regexp_match_operator(left, mapped, right)) elsif (mapped = BINARY_OPERATOR_MAP[op]) make_boolean_operator(left, mapped, right) elsif SHIFT_OPERATORS.include? op s(:call, unwrap_begin(process(left)), op, unwrap_begin(process(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.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 47 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.
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 58 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.
69 70 71 72 73 74 75 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 69 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.
40 41 42 43 44 45 |
# File 'lib/ripper_ruby_parser/sexp_handlers/operators.rb', line 40 def process_unary(exp) _, op, arg = exp.shift 3 arg = process(arg) op = UNARY_OPERATOR_MAP[op] || op s(:call, arg, op) end |