Class: Resyma::Core::Regexp
- Inherits:
-
Object
- Object
- Resyma::Core::Regexp
- Defined in:
- lib/resyma/core/automaton/regexp.rb
Direct Known Subclasses
RegexpConcat, RegexpNothing, RegexpRepeat, RegexpSelect, RegexpSomething
Instance Method Summary collapse
-
#inject(ab, start_state) ⇒ Resyma::Core::State
Converts self to automaton, which is implemented by subclasses.
-
#to_automaton(eliminate_epsilon = true) ⇒ Resyma::Core::Automaton
Convert the regexp to a DFA.
Instance Method Details
#inject(ab, start_state) ⇒ Resyma::Core::State
Converts self to automaton, which is implemented by subclasses. Note that only add states and transitions by the automaton builder, do not modify starting state and accept set
18 19 20 |
# File 'lib/resyma/core/automaton/regexp.rb', line 18 def inject(ab, start_state) raise NotImplementedError end |
#to_automaton(eliminate_epsilon = true) ⇒ Resyma::Core::Automaton
Convert the regexp to a DFA
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/resyma/core/automaton/regexp.rb', line 27 def to_automaton(eliminate_epsilon = true) ab = AutomatonBuilder.new start = ab.new_state! ab.start! start accept = inject ab, start ab.accept! accept result = ab.build if eliminate_epsilon result.to_DFA else result end end |