class RegularExpression::AST::Quantifier::AtLeast

Attributes

value[R]

Public Class Methods

new(value) click to toggle source
# File lib/regular_expression/ast.rb, line 318
def initialize(value)
  @value = value
end

Public Instance Methods

quantify(start, finish) { |states, states| ... } click to toggle source
# File lib/regular_expression/ast.rb, line 326
def quantify(start, finish)
  states = [start, *(value - 1).times.map { NFA::State.new }, finish]

  value.times do |index|
    yield states[index], states[index + 1]
  end

  states[-1].add_transition(NFA::Transition::Epsilon.new(states[-2]))
end
to_dot(parent) click to toggle source
# File lib/regular_expression/ast.rb, line 322
def to_dot(parent)
  parent.add_node(object_id, label: "{#{value},}", shape: "box")
end