Class: Resyma::Core::RegexpRepeat

Inherits:
Regexp
  • Object
show all
Defined in:
lib/resyma/core/automaton/regexp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Regexp

#to_automaton

Constructor Details

#initialize(regexp) ⇒ RegexpRepeat

Repeat the regexp zero, one, or more times

Parameters:

  • regexp (Regexp)

    A instance of Regexp



101
102
103
# File 'lib/resyma/core/automaton/regexp.rb', line 101

def initialize(regexp)
  @regexp = regexp
end

Instance Attribute Details

#regexpObject (readonly)

Returns the value of attribute regexp.



105
106
107
# File 'lib/resyma/core/automaton/regexp.rb', line 105

def regexp
  @regexp
end

Instance Method Details

#==(other) ⇒ Object



107
108
109
# File 'lib/resyma/core/automaton/regexp.rb', line 107

def ==(other)
  other.is_a?(self.class) && other.regexp == @regexp
end

#inject(ab, start_state) ⇒ Object



111
112
113
114
115
116
# File 'lib/resyma/core/automaton/regexp.rb', line 111

def inject(ab, start_state)
  accept = @regexp.inject(ab, start_state)
  ab.add_transition!(start_state, Epsilon, accept)
  ab.add_transition!(accept, Epsilon, start_state)
  accept
end