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/alternative.rb,
lib/mutant/ast/regexp/transformer/character_set.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
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
-
.parse(regexp) ⇒ Regexp::Expression
private
Parse regex string into expression.
-
.supported?(expression) ⇒ Boolean
private
Check if expression is supported by mapper.
-
.to_ast(expression) ⇒ Parser::AST::Node
private
Convert expression into ast node.
-
.to_expression(node) ⇒ Regexp::Expression
private
Convert node into expression.
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
16 17 18 |
# File 'lib/mutant/ast/regexp.rb', line 16 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
25 26 27 28 29 |
# File 'lib/mutant/ast/regexp.rb', line 25 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
36 37 38 39 40 |
# File 'lib/mutant/ast/regexp.rb', line 36 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
47 48 49 |
# File 'lib/mutant/ast/regexp.rb', line 47 def self.to_expression(node) Transformer.lookup(node.type).to_expression(node) end |