108 int mask = (1 <<
n_log) - 1;
117 while ((
i<n_trans) && (
trans[
i].symbol == s))
122 while (
table[p].fst != NULL)
141 return (d == NULL) ? 1 : d->
n_states;
153 return (d == NULL) ? 0 : d->
n_trans;
177 return ((d != NULL) && (d->
n_trans > 0)) ?
184 return ((d != NULL) && (d->
n_trans > 0)) ?
191 return (d != NULL) ? d->
key : 0;
205 : i_state(i_state0), symbol(symbol0), o_state(o_state0) {}
216 c_trans = &o->
trans[0];
219 c_trans = e_trans = NULL;
227 int mask = (1<<o->
n_log)-1;
234 c_trans = e_trans = NULL;
240 return c_trans < e_trans;
250 return c_trans->i_state;
255 return c_trans->symbol;
260 return c_trans->o_state;
272 c_trans = &o->
trans[0];
275 c_trans = e_trans = NULL;
281 return c_trans < e_trans;
286 int s = c_trans->symbol;
289 }
while ((c_trans < e_trans) && (s == c_trans->symbol));
294 return c_trans->symbol;
298 template<
class Char,
class Traits>
299 std::basic_ostream<Char,Traits>&
300 operator <<(std::basic_ostream<Char,Traits>& os,
const DFA&
d) {
301 std::basic_ostringstream<Char,Traits> st;
302 st.copyfmt(os); st.
width(0);
303 st <<
"Start state: 0" << std::endl
304 <<
"States: 0..." <<
d.n_states()-1 << std::endl
306 for (
int s = 0; s < static_cast<int>(
d.n_states()); s++) {
312 st << std::endl <<
"\t";
313 st <<
"[" << t.
i_state() <<
"]" 314 <<
"- " << t.
symbol() <<
" >" 321 st << std::endl <<
"Final states: " 323 <<
"\t[" <<
d.final_fst() <<
"] ... [" 324 <<
d.final_lst()-1 <<
"]" 326 return os << st.str();
348 return !(*
this ==
d);
Transitions(const DFA &d)
Initialize to all transitions of DFA d.
int i_state(void) const
Return in-state of current transition.
int n_trans
Number of transitions.
int final_fst
First final state.
int final_fst(void) const
Return the number of the first final state.
void rfree(void *p)
Free memory block starting at p.
Symbols(const DFA &d)
Initialize to symbols of DFA d.
unsigned int width(int i) const
Return width of range at position i.
std::size_t hash(void) const
Return hash key.
void operator++(void)
Move iterator to next transition.
const int max
Largest allowed integer value.
bool operator()(void) const
Test whether iterator still at a transition.
const int min
Smallest allowed integer value.
Specification of transition range.
Transition * trans
The transitions.
const Transition * fst
First transition for the symbol.
Deterministic finite automaton (DFA)
int p
Number of positive literals for node type.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
int n
Number of negative literals for node type.
int final_lst
Last final state.
Gecode::IntArgs i({1, 2, 3, 4})
bool operator!=(const DFA &d) const
Test whether DFA is not equal to d.
SharedHandle::Object * object(void) const
Access to the shared object.
virtual ~DFAI(void)
Delete automaton implemenentation.
int n_transitions(void) const
Return the number of transitions.
Specification of a DFA transition.
int symbol_max(void) const
Return largest symbol in DFA.
unsigned int n_symbols
Number of symbols.
bool operator==(const DFA &d) const
Test whether DFA is equal to d.
DFAI(void)
Initialize automaton implementation as empty.
DFA(void)
Initialize for DFA accepting the empty word.
unsigned int max_degree(void) const
Return maximal degree (in-degree and out-degree) of any state.
Heap heap
The single global heap.
HashEntry * table
The transition hash table by symbol.
void fill(void)
Fill hash table.
const Transition * lst
Last transition for the symbol.
Iterator for DFA transitions (sorted by symbols)
void operator++(void)
Move iterator to next symbol.
bool operator()(void) const
Test whether iterator still at a symbol.
int n_states
Number of states.
int n_states(void) const
Return the number of states.
int val(void) const
Return current symbol.
Gecode toplevel namespace
int symbol_min(void) const
Return smallest symbol in DFA.
int n_log
Size of table (as binary logarithm)
int final_lst(void) const
Return the number of the last final state.
#define GECODE_INT_EXPORT
unsigned int n_symbols(void) const
Return the number of symbols.
void cmb_hash(std::size_t &seed, const T h)
Combine hash value h into seed.
int symbol(void) const
Return symbol of current transition.
int o_state(void) const
Return out-state of current transition.
unsigned int max_degree
Maximal degree (in-degree and out-degree of any state) and maximal number of transitions per symbol...