class Mutant::Expression

Abstract base class for match expression

def self.from_match(match)

def self.from_match(match)
  names = anima.attribute_names
  new(names.zip(names.map(&match.public_method(:[]))).to_h)
end

def self.new(*)

def self.new(*)
  super.freeze
end

def self.try_parse(input)

Returns:
  • (nil) -
  • (Expression) -

Parameters:
  • input (String) --
def self.try_parse(input)
  match = self::REGEXP.match(input)
  from_match(match) if match
end

def match_length(other)

Returns:
  • (Integer) -

Parameters:
  • other (Expression) --
def match_length(other)
  if syntax.eql?(other.syntax)
    syntax.length
  else
    0
  end
end

def prefix?(other)

Returns:
  • (Boolean) -

Parameters:
  • other (Expression) --
def prefix?(other)
  !match_length(other).zero?
end