107 return (d == NULL) ? 1 : d->
n_states;
119 return (d == NULL) ? 0 : d->
n_trans;
143 return ((d != NULL) && (d->
n_trans > 0)) ?
150 return ((d != NULL) && (d->
n_trans > 0)) ?
165 : i_state(i_state0), symbol(symbol0), o_state(o_state0) {}
176 c_trans = &o->
trans[0];
179 c_trans = e_trans = NULL;
187 int mask = (1<<o->
n_log)-1;
194 c_trans = e_trans = NULL;
200 return c_trans < e_trans;
210 return c_trans->i_state;
215 return c_trans->symbol;
220 return c_trans->o_state;
232 c_trans = &o->
trans[0];
235 c_trans = e_trans = NULL;
241 return c_trans < e_trans;
246 int s = c_trans->symbol;
249 }
while ((c_trans < e_trans) && (s == c_trans->symbol));
254 return c_trans->symbol;
258 template<
class Char,
class Traits>
259 std::basic_ostream<Char,Traits>&
260 operator <<(std::basic_ostream<Char,Traits>& os,
const DFA&
d) {
261 std::basic_ostringstream<Char,Traits> st;
262 st.copyfmt(os); st.
width(0);
263 st <<
"Start state: 0" << std::endl
264 <<
"States: 0..." <<
d.n_states()-1 << std::endl
266 for (
int s = 0; s < static_cast<int>(
d.n_states()); s++) {
272 st << std::endl <<
"\t";
273 st <<
"[" << t.
i_state() <<
"]"
274 <<
"- " << t.
symbol() <<
" >"
281 st << std::endl <<
"Final states: "
283 <<
"\t[" <<
d.final_fst() <<
"] ... ["
284 <<
d.final_lst()-1 <<
"]"
286 return os << st.str();
Transitions(const DFA &d)
Initialize to all transitions of DFA d.
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.
int o_state(void) const
Return out-state of current transition.
void rfree(void *p)
Free memory block starting at p.
int final_lst(void) const
Return the number of the last final state.
Symbols(const DFA &d)
Initialize to symbols of DFA d.
bool operator()(void) const
Test whether iterator still at a symbol.
void operator++(void)
Move iterator to next transition.
virtual SharedHandle::Object * copy(void) const
Create a copy.
const int max
Largest allowed integer value.
const int min
Smallest allowed integer value.
Heap heap
The single global heap.
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.
unsigned int n_symbols(void) const
Return the number of symbols.
int n
Number of negative literals for node type.
int final_lst
Last final state.
virtual ~DFAI(void)
Delete automaton implemenentation.
int i_state(void) const
Return in-state of current transition.
Specification of a DFA transition.
unsigned int max_degree(void) const
Return maximal degree (in-degree and out-degree) of any state.
unsigned int width(int i) const
Return width of range at position i.
unsigned int n_symbols
Number of symbols.
bool operator()(void) const
Test whether iterator still at a transition.
int n_transitions(void) const
Return the number of transitions.
DFAI(void)
Initialize automaton implementation as empty.
DFA(void)
Initialize for DFA accepting the empty word.
SharedHandle::Object * object(void) const
Access to the shared object.
int symbol(void) const
Return symbol of current transition.
int val(void) const
Return current symbol.
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)
int n_states(void) const
Return the number of states.
void operator++(void)
Move iterator to next symbol.
int n_states
Number of states.
Gecode toplevel namespace
int n_log
Size of table (as binary logarithm)
#define GECODE_INT_EXPORT
int symbol_min(void) const
Return smallest symbol in DFA.
int symbol_max(void) const
Return largest symbol in DFA.
unsigned int max_degree
Maximal degree (in-degree and out-degree of any state) and maximal number of transitions per symbol...