Sha256: b0c166e3bf95230cd145558e6ab57fd5161f92d33dbc5b401d02fa3d9d691ed0
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 KB
Contents
module Mutest module AST module Regexp class Transformer # Transformer for character sets # # The `Regexp::Expression` representation of a character set # is unique due to its usage of the `#members` attribute which # is why it gets its own transformer class CharacterSet < self register :regexp_character_set # Mapper from `Regexp::Expression` to `Parser::AST::Node` class ExpressionToAST < Transformer::ExpressionToAST # Transform character set expression into node # # @return [Parser::AST::Node] def call quantify(ast(*expression.members)) end end # ExpressionToAST # Mapper from `Parser::AST::Node` to `Regexp::Expression` class ASTToExpression < Transformer::ASTToExpression CHARACTER_SET = IceNine.deep_freeze( ::Regexp::Expression::CharacterSet.new( ::Regexp::Token.new(:set, :character, '[') ) ) private # Transform node into expression # # @return [Regexp::Expression::Base] def transform CHARACTER_SET.dup.tap do |expression| expression.members = node.children end end end # ASTToExpression end # CharacterSet end # Transformer end # Regexp end # AST end # Mutest
Version data entries
3 entries across 3 versions & 1 rubygems