class RegularExpression::AST::CharacterGroup

Attributes

invert[R]
items[R]

Public Class Methods

new(items, invert: false) click to toggle source
# File lib/regular_expression/ast.rb, line 121
def initialize(items, invert: false)
  @items = items
  @invert = invert
end

Public Instance Methods

to_dot(parent) click to toggle source
# File lib/regular_expression/ast.rb, line 126
def to_dot(parent)
  label = "CharacterGroup"
  label = "#{label} (invert)" if invert

  node = parent.add_node(object_id, label: label)
  items.each { |item| item.to_dot(node) }
end
to_nfa(start, finish) click to toggle source
# File lib/regular_expression/ast.rb, line 134
def to_nfa(start, finish)
  if invert
    transition = NFA::Transition::Invert.new(finish, items.flat_map(&:to_nfa_values).sort)
    start.add_transition(transition)
  else
    items.each do |item|
      item.to_nfa(start, finish)
    end
  end
end