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;
146 rclass(Rune p0, Rune p1)
153 return re2char(0xff, 0xff); // no match
156 * bust range into same length
157 * character sequences
159 for(i=0; i<nelem(tab1); i++) {
161 if(p0 <= m && p1 > m)
162 return re2or(rclass(p0, m), rclass(m+1, p1));
166 * bust range into part of a single page
169 for(i=0; i<nelem(tab2); i++) {
171 if((p0 & ~m) != (p1 & ~m)) {
173 return re2or(rclass(p0, p0|m), rclass((p0|m)+1, p1));
175 return re2or(rclass(p0, (p1&~m)-1), rclass(p1&~m, p1));
179 n = runetochar(xc0, &p0);
180 i = runetochar(xc1, &p1);
184 x = re2char(xc0[0], xc1[0]);
186 x = re2cat(x, re2char(xc0[i], xc1[i]));
191 pcmp(void *va, void *vb)
206 * convert character chass into
207 * run-pair ranges of matches.
208 * this is 10646/utf specific and
209 * needs to be changed for some
210 * other input character set.
211 * this is the key to a fast
212 * regular search of characters
213 * by looking at sequential bytes.
218 Rune pairs[200+2], *p, *q, ov;
229 s += chartorune(p, s);
232 s += chartorune(p, s);
237 if(p >= pairs + nelem(pairs) - 2)
238 error("class too big");
239 s += chartorune(p, s);
242 s += chartorune(p, s);
244 s += chartorune(p, s);
248 s += chartorune(p, s);
251 qsort(pairs, (p-pairs)/2, 2*sizeof(*pairs), pcmp);
254 for(p=pairs+2; *p; p+=2) {
257 if(p[0] > q[1] || p[1] < q[0]) {
272 x = rclass(0, p[0]-1);
274 for(p+=2; *p; p+=2) {
275 x = re2or(x, rclass(ov, p[0]-1));
278 x = re2or(x, rclass(ov, Runemask));
280 x = rclass(p[0], p[1]);
282 x = re2or(x, rclass(p[0], p[1]));