diff --git a/lib/mutant.rb b/lib/mutant.rb index 1aedbeea..a80c89b9 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -12,6 +12,7 @@ require 'digest/sha1' require 'inflecto' require 'parser' require 'parser/current' +require 'parser-node-list' require 'unparser' require 'ice_nine' require 'diff/lcs' @@ -21,31 +22,6 @@ require 'anima' require 'concord' require 'rspec' -# Monkeypatch on parser with a list of allowed nodes. -# Will be pushed upstream once turning out to be correct. -module Parser - module Meta - NODE_TYPES = - %w( - true false nil int float str dstr str - sym dsym xstr regopt regexp array splat - array pair kwsplat hash irange erange self - lvar ivar cvar gvar const defined? lvasgn - ivasgn cvasgn gvasgn casgn mlhs masgn op_asgn - op_asgn and_asgn ensure rescue arg_expr - or_asgn and_asgn or_asgn back_ref nth_ref - match_with_lvasgn match_current_line - module class sclass def defs undef alias args - cbase arg optarg restarg blockarg block_pass args def kwarg kwoptarg - kwrestarg send super zsuper yield block send - and not or if when case while until while_post - until_post for break next redo return resbody - kwbegin begin retry preexe postexe iflipflop eflipflop - shadowarg - ).map(&:to_sym).to_set.freeze - end # Meta -end # Parser - # Library namespace module Mutant # The empty string used within this namespace diff --git a/lib/parser-node-list.rb b/lib/parser-node-list.rb new file mode 100644 index 00000000..c69df653 --- /dev/null +++ b/lib/parser-node-list.rb @@ -0,0 +1,25 @@ +# Monkeypatch on parser with a list of allowed nodes. +# Will be pushed upstream once turning out to be correct. +module Parser + module Meta + NODE_TYPES = + %w( + true false nil int float str dstr str + sym dsym xstr regopt regexp array splat + array pair kwsplat hash irange erange self + lvar ivar cvar gvar const defined? lvasgn + ivasgn cvasgn gvasgn casgn mlhs masgn op_asgn + op_asgn and_asgn ensure rescue arg_expr + or_asgn and_asgn or_asgn back_ref nth_ref + match_with_lvasgn match_current_line + module class sclass def defs undef alias args + cbase arg optarg restarg blockarg block_pass args def kwarg kwoptarg + kwrestarg send super zsuper yield block send + and not or if when case while until while_post + until_post for break next redo return resbody + kwbegin begin retry preexe postexe iflipflop eflipflop + shadowarg + ).map(&:to_sym).to_set.freeze + end # Meta +end # Parser +