4 * incremental compiler.
5 * add the branch c to the
9 increment(State *s, int c)
18 for(i=0; i<s->count; i++)
20 qsort(follow, nfollow, sizeof(*follow), fcmp);
21 for(tt=&state0; t = *tt;) {
22 if(t->count > nfollow) {
26 if(t->count < nfollow) {
30 for(i=0; i<nfollow; i++) {
42 if(!!matched && !t->match) {
46 if(!matched && !!t->match) {
57 for(i=0; i<nfollow; i++) {
66 fcmp(void *va, void *vb)
90 if(nfollow >= maxfollow)
100 follow[nfollow++] = r1;
112 if(c == '\n' || c == Cbegin)
113 follow[nfollow++] = r->next;
128 if(c >= r->lo && c <= r->hi)
129 follow[nfollow++] = r->next;
148 rclass(Rune p0, Rune p1)
155 return re2char(0xff, 0xff); // no match
158 * bust range into same length
159 * character sequences
161 for(i=0; i<nelem(tab1); i++) {
163 if(p0 <= m && p1 > m)
164 return re2or(rclass(p0, m), rclass(m+1, p1));
168 * bust range into part of a single page
171 for(i=0; i<nelem(tab2); i++) {
173 if((p0 & ~m) != (p1 & ~m)) {
175 return re2or(rclass(p0, p0|m), rclass((p0|m)+1, p1));
177 return re2or(rclass(p0, (p1&~m)-1), rclass(p1&~m, p1));
181 n = runetochar(xc0, &p0);
182 i = runetochar(xc1, &p1);
186 x = re2char(xc0[0], xc1[0]);
188 x = re2cat(x, re2char(xc0[i], xc1[i]));
193 pcmp(void *va, void *vb)
208 * convert character chass into
209 * run-pair ranges of matches.
210 * this is 10646/utf specific and
211 * needs to be changed for some
212 * other input character set.
213 * this is the key to a fast
214 * regular search of characters
215 * by looking at sequential bytes.
220 Rune pairs[200+2], *p, *q, ov;
231 s += chartorune(p, s);
234 s += chartorune(p, s);
239 if(p >= pairs + nelem(pairs) - 2)
240 error("class too big");
241 s += chartorune(p, s);
244 s += chartorune(p, s);
246 s += chartorune(p, s);
250 s += chartorune(p, s);
253 qsort(pairs, (p-pairs)/2, 2*sizeof(*pairs), pcmp);
256 for(p=pairs+2; *p; p+=2) {
259 if(p[0] > q[1] || p[1] < q[0]) {
274 x = rclass(0, p[0]-1);
276 for(p+=2; *p; p+=2) {
277 x = re2or(x, rclass(ov, p[0]-1));
280 x = re2or(x, rclass(ov, Runemax));
282 x = rclass(p[0], p[1]);
284 x = re2or(x, rclass(p[0], p[1]));