Module: Mutant::AST::Regexp Private

Defined in:
lib/mutant/ast/regexp.rb,
lib/mutant/ast/regexp/transformer.rb,
lib/mutant/ast/regexp/transformer/root.rb,
lib/mutant/ast/regexp/transformer/text.rb,
lib/mutant/ast/regexp/transformer/direct.rb,
lib/mutant/ast/regexp/transformer/recursive.rb,
lib/mutant/ast/regexp/transformer/quantifier.rb,
lib/mutant/ast/regexp/transformer/named_group.rb,
lib/mutant/ast/regexp/transformer/options_group.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.

Regexp source mapper

Defined Under Namespace

Classes: Transformer

Class Method Summary collapse

Class Method Details

.parse(regexp) ⇒ Regexp::Expression

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.

Parse regex string into expression

Parameters:

  • regexp (String)

Returns:

  • (Regexp::Expression)


12
13
14
# File 'lib/mutant/ast/regexp.rb', line 12

def self.parse(regexp)
  ::Regexp::Parser.parse(regexp)
end

.to_ast(expression) ⇒ Parser::AST::Node

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.

Convert expression into ast node

Parameters:

  • expression (Regexp::Expression)

Returns:

  • (Parser::AST::Node)


21
22
23
24
25
# File 'lib/mutant/ast/regexp.rb', line 21

def self.to_ast(expression)
  ast_type = :"regexp_#{expression.token}_#{expression.type}"

  Transformer.lookup(ast_type).to_ast(expression)
end

.to_expression(node) ⇒ Regexp::Expression

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.

Convert node into expression

Parameters:

  • node (Parser::AST::Node)

Returns:

  • (Regexp::Expression)


32
33
34
# File 'lib/mutant/ast/regexp.rb', line 32

def self.to_expression(node)
  Transformer.lookup(node.type).to_expression(node)
end