16 void DFA::split(State *s)
18 State *move =
new State;
20 move->action.set_move ();
26 s->go.span = allocate<Span> (1);
28 s->go.span[0].to = move;
35 State *prev = NULL, *to;
42 to = f->to == b->to ? bg : f->to;
60 if (nf == 0 && nb == 0)
62 return static_cast<uint32_t
> (x - x0);
68 to = f->
to == b->to ? bg : f->to;
87 to = b->
to == f->to ? bg : f->to;
106 void DFA::findBaseState()
110 for (State *s =
head; s; s = s->
next)
114 for (uint32_t i = 0; i < s->go.nSpans; ++i)
116 State *to = s->go.span[i].
to;
121 uint32_t nSpans =
merge(span, s, to);
123 if (nSpans < s->go.nSpans)
125 operator delete (s->go.span);
126 s->go.nSpans = nSpans;
127 s->go.span = allocate<Span> (nSpans);
128 memcpy(s->go.span, span, nSpans*
sizeof(Span));
137 operator delete (span);
145 std::map<rule_rank_t, State *> rules;
150 if (rules.find (s->rule->rank) == rules.end ())
154 rules[s->rule->rank] = n;
157 for (uint32_t i = 0; i < s->go.nSpans; ++i)
159 if (!s->go.span[i].to)
161 s->go.span[i].to = rules[s->rule->rank];
168 State * default_state = NULL;
171 for (uint32_t i = 0; i < s->go.nSpans; ++i)
173 if (!s->go.span[i].to)
177 default_state =
new State;
178 addState(default_state, s);
180 s->go.span[i].to = default_state;
192 for (uint32_t i = 0; i < s->go.nSpans; ++i)
194 if (!s->go.span[i].to->rule && s->go.span[i].to->action.type !=
Action::RULE)
196 const uint32_t accept =
static_cast<uint32_t
> (accepts.
find_or_add (rules[s->rule->rank]));
212 for (uint32_t i = 0; i < s->go.nSpans; ++i)
214 if (s->go.span[i].to == s)
246 if (max_fill < s->fill)
void set_rule(const RuleOp *const rule)
void set_save(uint32_t save)
static uint32_t merge(Span *x0, State *fg, State *bg)
void set_accept(const accept_t *accepts)
static const BitMap * find(const Go *, const State *)
size_t find_or_add(const value_t &v)