Module: Fa
- Defined in:
- lib/fa.rb,
lib/fa/version.rb
Overview
Namespace for the libfa bindings
Defined Under Namespace
Modules: FFI Classes: Automaton, Error, OutOfMemoryError
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
-
.[](rx) ⇒ Fa::Automaton
Compiles
rx
into a finite automaton. -
.compile(rx) ⇒ Fa::Automaton
Compiles
rx
into a finite automaton. -
.make_basic(kind) ⇒ Fa::Automaton
Makes a basic finite automaton, either an empty, epsilon, or total finite automaton.
Class Method Details
.[](rx) ⇒ Fa::Automaton
Compiles rx
into a finite automaton
229 230 231 |
# File 'lib/fa.rb', line 229 def self.[](rx) compile(rx) end |
.compile(rx) ⇒ Fa::Automaton
Compiles rx
into a finite automaton
219 220 221 222 223 224 |
# File 'lib/fa.rb', line 219 def self.compile(rx) faptr = ::FFI::MemoryPointer.new :pointer r = FFI::compile(rx, rx.size, faptr) raise Error if r != 0 # REG_NOERROR is 0, at least for glibc Automaton.new(faptr.get_pointer(0)) end |
.make_basic(kind) ⇒ Fa::Automaton
Makes a basic finite automaton, either an empty, epsilon, or total finite automaton. Those match no words, only the empty word, or all words.
238 239 240 241 242 |
# File 'lib/fa.rb', line 238 def self.make_basic(kind) faptr = FFI::make_basic(kind) raise OutOfMemoryError if faptr.null? Automaton.new(faptr) end |