Module: Mutest::AST::Regexp Private

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

Constant Summary collapse

UNSUPPORTED_EXPRESSION_TYPE =

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.

:conditional

Class Method Summary collapse

Class Method Details

.parse(regexp) ⇒ Regexp::Expression::Base

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::Base)


14
15
16
# File 'lib/mutest/ast/regexp.rb', line 14

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

.supported?(expression) ⇒ Boolean

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.

Check if expression is supported by mapper

Parameters:

  • expression (Regexp::Expression::Base)

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/mutest/ast/regexp.rb', line 23

def self.supported?(expression)
  expression.terminal? || expression.all? do |subexp|
    !subexp.type.equal?(UNSUPPORTED_EXPRESSION_TYPE) && supported?(subexp)
  end
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::Base)

Returns:

  • (Parser::AST::Node)


34
35
36
37
38
# File 'lib/mutest/ast/regexp.rb', line 34

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::Base

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::Base)


45
46
47
# File 'lib/mutest/ast/regexp.rb', line 45

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