106 const DFAI*
d = static_cast<DFAI*>(
object());
107 return (
d == NULL) ? 1 :
d->n_states;
112 const DFAI*
d = static_cast<DFAI*>(
object());
113 return (
d == NULL) ? 0 :
d->n_symbols;
118 const DFAI*
d = static_cast<DFAI*>(
object());
119 return (
d == NULL) ? 0 :
d->n_trans;
124 const DFAI*
d = static_cast<DFAI*>(
object());
125 return (
d == NULL) ? 0 :
d->max_degree;
130 const DFAI*
d = static_cast<DFAI*>(
object());
131 return (
d == NULL) ? 0 :
d->final_fst;
136 const DFAI*
d = static_cast<DFAI*>(
object());
137 return (
d == NULL) ? 0 :
d->final_lst;
142 const DFAI*
d = static_cast<DFAI*>(
object());
143 return ((
d != NULL) && (
d->n_trans > 0)) ?
149 const DFAI*
d = static_cast<DFAI*>(
object());
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>&
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++) {
270 if (
t.i_state() == s) {
272 st << std::endl <<
"\t";
273 st <<
"[" <<
t.i_state() <<
"]" 274 <<
"- " <<
t.symbol() <<
" >" 275 <<
"[" <<
t.o_state() <<
"] ";
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 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.
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.
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.
int n
Number of negative literals for node type.
int final_lst
Last final state.
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.
virtual SharedHandle::Object * copy(void) const
Create a copy.
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.
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.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const DFA &d)
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.