class Regexp::Parser
def escape(token)
def escape(token) case token.token when :backspace; node << EscapeSequence::Backspace.new(token, active_opts) when :escape; node << EscapeSequence::AsciiEscape.new(token, active_opts) when :bell; node << EscapeSequence::Bell.new(token, active_opts) when :form_feed; node << EscapeSequence::FormFeed.new(token, active_opts) when :newline; node << EscapeSequence::Newline.new(token, active_opts) when :carriage; node << EscapeSequence::Return.new(token, active_opts) when :tab; node << EscapeSequence::Tab.new(token, active_opts) when :vertical_tab; node << EscapeSequence::VerticalTab.new(token, active_opts) when :codepoint; node << EscapeSequence::Codepoint.new(token, active_opts) when :codepoint_list; node << EscapeSequence::CodepointList.new(token, active_opts) when :hex; node << EscapeSequence::Hex.new(token, active_opts) when :octal; node << EscapeSequence::Octal.new(token, active_opts) when :control if token.text =~ /\A(?:\\C-\\M|\\c\\M)/ # TODO: emit :meta_control_sequence token in v3.0.0 node << EscapeSequence::MetaControl.new(token, active_opts) else node << EscapeSequence::Control.new(token, active_opts) end when :meta_sequence if token.text =~ /\A\\M-\\[Cc]/ # TODO: emit :meta_control_sequence token in v3.0.0: node << EscapeSequence::MetaControl.new(token, active_opts) else node << EscapeSequence::Meta.new(token, active_opts) end else # treating everything else as a literal # TODO: maybe split this up a bit more in v3.0.0? # E.g. escaped quantifiers or set meta chars are not the same # as stuff that would be a literal even without the backslash. # Right now, they all end up here. node << EscapeSequence::Literal.new(token, active_opts) end end