Class: Mutant::AST::Regexp::Transformer Private

Inherits:
Object
  • Object
show all
Includes:
Unparser::AbstractType
Defined in:
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 class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Regexp bijective mapper

Transforms parsed regular expression representation from ‘Regexp::Expression` instances (provided by `regexp_parser`) into equivalent representations using `Parser::AST::Node`

Direct Known Subclasses

Direct, NamedGroup, OptionsGroup, Quantifier, Recursive, Root, Text

Defined Under Namespace

Modules: LookupTable Classes: ASTToExpression, Direct, ExpressionToAST, NamedGroup, OptionsGroup, Quantifier, Recursive, Root, Text

Constant Summary collapse

REGISTRY =

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.

Registry.new(
  ->(type) { fail "No regexp transformer registered for: #{type}" }
)

Class Method Summary collapse

Class Method Details

.lookup(type) ⇒ Class<Transformer>

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.

Lookup transformer class for regular expression node type

Parameters:

  • type (Symbol)

Returns:



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

def self.lookup(type)
  REGISTRY.lookup(type)
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.

Transform expression

Parameters:

  • expression (Regexp::Expression)

Returns:

  • (Parser::AST::Node)


37
38
39
# File 'lib/mutant/ast/regexp/transformer.rb', line 37

def self.to_ast(expression)
  self::ExpressionToAST.call(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.

Transform node

Parameters:

  • node (Parser::AST::Node)

Returns:

  • (Regexp::Expression)


46
47
48
# File 'lib/mutant/ast/regexp/transformer.rb', line 46

def self.to_expression(node)
  self::ASTToExpression.call(node)
end