2013-01-03 18:18:48 -05:00
|
|
|
module Mutant
|
|
|
|
|
2013-02-22 14:46:22 -05:00
|
|
|
METHOD_POSTFIX_EXPANSIONS = {
|
|
|
|
'?' => '_predicate',
|
|
|
|
'=' => '_writer',
|
|
|
|
'!' => '_bang'
|
2013-01-13 16:24:14 -05:00
|
|
|
}.freeze
|
|
|
|
|
2013-06-24 16:10:40 -04:00
|
|
|
OPERATOR_EXPANSIONS = {
|
2013-01-03 18:18:48 -05:00
|
|
|
:<=> => :spaceship_operator,
|
|
|
|
:=== => :case_equality_operator,
|
|
|
|
:[]= => :element_writer,
|
|
|
|
:[] => :element_reader,
|
|
|
|
:<= => :less_than_or_equal_to_operator,
|
|
|
|
:>= => :greater_than_or_equal_to_operator,
|
|
|
|
:== => :equality_operator,
|
|
|
|
:'!~' => :nomatch_operator,
|
|
|
|
:'!=' => :inequality_operator,
|
|
|
|
:=~ => :match_operator,
|
|
|
|
:<< => :left_shift_operator,
|
|
|
|
:>> => :right_shift_operator,
|
|
|
|
:** => :exponentation_operator,
|
|
|
|
:* => :multiplication_operator,
|
|
|
|
:% => :modulo_operator,
|
|
|
|
:/ => :division_operator,
|
|
|
|
:| => :bitwise_or_operator,
|
|
|
|
:^ => :bitwise_xor_operator,
|
|
|
|
:& => :bitwise_and_operator,
|
|
|
|
:< => :less_than_operator,
|
|
|
|
:> => :greater_than_operator,
|
|
|
|
:+ => :addition_operator,
|
2013-06-24 16:10:40 -04:00
|
|
|
:- => :substraction_operator,
|
2013-01-03 18:18:48 -05:00
|
|
|
:~@ => :unary_match_operator,
|
|
|
|
:+@ => :unary_addition_operator,
|
|
|
|
:-@ => :unary_substraction_operator,
|
|
|
|
:'!' => :negation_operator
|
|
|
|
}.freeze
|
|
|
|
|
2013-06-24 16:10:40 -04:00
|
|
|
INDEX_OPERATORS = [ :[], :[]= ].freeze
|
|
|
|
|
|
|
|
UNARY_METHOD_OPERATORS = [
|
|
|
|
:~@, :+@, :-@, :'!'
|
|
|
|
].freeze
|
2013-01-03 18:18:48 -05:00
|
|
|
|
2013-06-24 16:10:40 -04:00
|
|
|
BINARY_METHOD_OPERATORS = (OPERATOR_EXPANSIONS.keys - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS)).to_set.freeze
|
2013-06-21 12:00:17 -04:00
|
|
|
|
2013-06-27 17:20:06 -04:00
|
|
|
OPERATOR_METHODS = OPERATOR_EXPANSIONS.keys + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
|
|
|
|
|
2013-06-21 12:00:17 -04:00
|
|
|
# Hopefully all types parser does generate
|
|
|
|
NODE_TYPES = [
|
|
|
|
:lvasgn, :ivasgn, :cvasgn, :gvasgn,
|
|
|
|
:casgn, :masgn, :mlhs, :break, :rescue,
|
|
|
|
:ensure, :resbody, :begin, :retry, :arg_expr,
|
|
|
|
:args, :blockarg, :optarg, :kwrestarg, :kwoptarg,
|
|
|
|
:kwarg, :restarg, :arg, :block_pass, :or, :and,
|
|
|
|
:next, :undef, :if, :module, :cbase, :block, :send,
|
|
|
|
:zsuper, :super, :empty, :alias, :for, :redo,
|
|
|
|
:return, :splat, :not, :defined?, :op_asgn, :self,
|
|
|
|
:true, :false, :nil, :dstr, :dsym, :regexp,
|
|
|
|
:regopt, :int, :str, :float, :sym, :pair, :hash, :array,
|
2013-06-21 12:10:06 -04:00
|
|
|
:xstr, :def, :defs, :case, :when, :ivar, :lvar, :cvar, :gvar,
|
2013-06-21 12:00:17 -04:00
|
|
|
:back_ref, :const, :nth_ref, :class, :sclass, :yield,
|
2013-06-21 21:10:53 -04:00
|
|
|
:match_with_lvasgn, :match_current_line, :irange, :erange,
|
2013-06-28 18:32:20 -04:00
|
|
|
:or_asgn, :kwbegin
|
2013-06-21 12:00:17 -04:00
|
|
|
].to_set.freeze
|
|
|
|
end # Mutant,
|