Lines Matching refs:rex

89 static const char* rexname(Rex_t* rex)  in rexname()  argument
91 if (!rex) in rexname()
93 if (rex->type >= elementsof(rexnames)) in rexname()
95 return rexnames[rex->type]; in rexname()
249 _matchpush(Env_t* env, Rex_t* rex) in _matchpush() argument
257 if (rex->re.group.number <= 0 || (num = rex->re.group.last - rex->re.group.number + 1) <= 0) in _matchpush()
265 f->match = m = env->match + rex->re.group.number; in _matchpush()
281 pospush(Env_t* env, Rex_t* rex, unsigned char* p, int be) in pospush() argument
290 pos->serial = rex->serial; in pospush()
403 parserep(Env_t* env, Rex_t* rex, Rex_t* cont, unsigned char* s, int n) in parserep() argument
409 …%d `%-.*s'\n", __LINE__, debug_flag, rexname(rex->re.group.expr.rex), rex->re.group.number, rex->l… in parserep()
410 if ((rex->flags & REG_MINIMAL) && n >= rex->lo && n < rex->hi) in parserep()
412 if (env->stack && pospush(env, rex, s, END_ANY)) in parserep()
414 i = follow(env, rex, cont, s); in parserep()
428 if (n < rex->hi) in parserep()
431 catcher.serial = rex->serial; in parserep()
432 catcher.re.rep_catch.ref = rex; in parserep()
436 catcher.next = rex->next; in parserep()
438 rex->re.rep_catch.beg = s; in parserep()
441 if (matchpush(env, rex)) in parserep()
443 if (pospush(env, rex, s, BEG_ONE)) in parserep()
445 …%d (%d,%d)(%d,%d)(%d,%d) (%d,%d)(%d,%d)(%d,%d)\n", __LINE__, debug_flag, rex->re.group.number, e… in parserep()
447 r = parse(env, rex->re.group.expr.rex, &catcher, s); in parserep()
448 …t, "AHA#%04d 0x%04x parserep parse %d %d `%-.*s'\n", __LINE__, debug_flag, rex->re.group.number, r… in parserep()
452 matchpop(env, rex); in parserep()
453 …d %d (%d,%d)(%d,%d)(%d,%d) (%d,%d)(%d,%d)(%d,%d)\n", __LINE__, debug_flag, rex->re.group.number, r… in parserep()
465 if (rex->flags & REG_MINIMAL) in parserep()
471 if (n < rex->lo) in parserep()
473 if (!(rex->flags & REG_MINIMAL) || n >= rex->hi) in parserep()
475 if (env->stack && pospush(env, rex, s, END_ANY)) in parserep()
477 i = follow(env, rex, cont, s); in parserep()
492 r = (rex->flags & REG_MINIMAL) ? BEST : GOOD; in parserep()
500 parsetrie(Env_t* env, Trie_node_t* x, Rex_t* rex, Rex_t* cont, unsigned char* s) in parsetrie() argument
505 if (p = rex->map) in parsetrie()
536 if (rex->flags & REG_MINIMAL) in parsetrie()
537 switch (follow(env, rex, cont, s)) in parsetrie()
548 switch (parsetrie(env, x->son, rex, cont, s)) in parsetrie()
557 if (rex->flags & REG_MINIMAL) in parsetrie()
567 if (!(rex->flags & REG_MINIMAL)) in parsetrie()
568 switch (follow(env, rex, cont, s)) in parsetrie()
651 collmatch(Rex_t* rex, unsigned char* s, unsigned char* e, unsigned char** p) in collmatch() argument
662 ic = (rex->flags & REG_ICASE); in collmatch()
708 …if (ic ? collic(rex->re.collate.elements, (char*)key, (char*)key, c, x) : collelt(rex->re.collate.… in collmatch()
719 return rex->re.collate.invert ? !r : r; in collmatch()
798 parse(Env_t* env, Rex_t* rex, Rex_t* cont, unsigned char* s) in parse() argument
820 …tdout, "AHA#%04d 0x%04x parse %s `%-.*s'\n", __LINE__, debug_flag, rexname(rex), env->end - s, s))… in parse()
821 switch (rex->type) in parse()
826 if (matchpush(env, rex)) in parse()
828 if (pospush(env, rex, s, BEG_ALT)) in parse()
831 catcher.serial = rex->serial; in parse()
833 catcher.next = rex->next; in parse()
834 r = parse(env, rex->re.group.expr.binary.left, &catcher, s); in parse()
835 if (r < BEST || (rex->flags & REG_MINIMAL)) in parse()
837 matchcopy(env, rex); in parse()
838 …((Pos_t*)env->pos->vec + env->pos->cur - 1)->serial = catcher.serial = rex->re.group.expr.binary.s… in parse()
839 n = parse(env, rex->re.group.expr.binary.right, &catcher, s); in parse()
844 matchpop(env, rex); in parse()
848 if ((r = parse(env, rex->re.group.expr.binary.left, cont, s)) == NONE) in parse()
849 r = parse(env, rex->re.group.expr.binary.right, cont, s); in parse()
855 if (pospush(env, rex, s, END_ANY)) in parse()
857 r = follow(env, rex, rex->re.alt_catch.cont, s); in parse()
861 o = &env->match[rex->lo]; in parse()
869 if (!(p = rex->map)) in parse()
893 …if ((!(rex->flags & REG_NEWLINE) || s <= env->beg || *(s - 1) != '\n') && ((env->flags & REG_NOTBO… in parse()
897 if (LEADING(env, rex, s)) in parse()
899 n = rex->hi; in parse()
902 m = rex->lo; in parse()
906 if (!(rex->flags & REG_MINIMAL)) in parse()
909 if (!settst(rex->re.charclass, s[i])) in parse()
915 switch (follow(env, rex, cont, s)) in parse()
931 if (!settst(rex->re.charclass, *s)) in parse()
936 switch (follow(env, rex, cont, s)) in parse()
946 if (s >= e || !settst(rex->re.charclass, *s)) in parse()
953 if (LEADING(env, rex, s)) in parse()
955 n = rex->hi; in parse()
958 m = rex->lo; in parse()
963 if (!(rex->flags & REG_MINIMAL)) in parse()
970 for (i = 0; s < e && i < n && collmatch(rex, s, e, &t); i++) in parse()
975 for (; i-- >= rex->lo; s -= b[i]) in parse()
976 switch (follow(env, rex, cont, s)) in parse()
996 if (!collmatch(rex, s, e, &t)) in parse()
1000 switch (follow(env, rex, cont, s)) in parse()
1010 if (s >= e || !collmatch(rex, s, e, &s)) in parse()
1018 next.next = rex->next; in parse()
1020 catcher.re.conj_left.right = rex->re.group.expr.binary.right; in parse()
1024 return parse(env, rex->re.group.expr.binary.left, &catcher, s); in parse()
1026 rex->re.conj_left.cont->re.conj_right.end = s; in parse()
1027 cont = rex->re.conj_left.cont; in parse()
1028 s = rex->re.conj_left.beg; in parse()
1029 rex = rex->re.conj_left.right; in parse()
1032 if (rex->re.conj_right.end != s) in parse()
1034 cont = rex->re.conj_right.cont; in parse()
1041 …,%d)(%d,%d)(%d,%d)(%d,%d) (%d,%d)(%d,%d)\n", __LINE__, debug_flag, rexname(rex), env->best[0].rm_s… in parse()
1044 if (rex->flags & REG_MINIMAL) in parse()
1072 …,%d)(%d,%d)(%d,%d)(%d,%d) (%d,%d)(%d,%d)\n", __LINE__, debug_flag, rexname(rex), env->best[0].rm_s… in parse()
1075 if (LEADING(env, rex, s)) in parse()
1077 n = rex->hi; in parse()
1080 m = rex->lo; in parse()
1083 if ((c = rex->explicit) >= 0 && !mbwide()) in parse()
1091 if (!(rex->flags & REG_MINIMAL)) in parse()
1096 switch (follow(env, rex, cont, s)) in parse()
1120 switch (follow(env, rex, cont, s)) in parse()
1144 switch (follow(env, rex, cont, s)) in parse()
1162 switch (follow(env, rex, cont, s)) in parse()
1176 if ((!(rex->flags & REG_NEWLINE) || *s != '\n') && ((env->flags & REG_NOTEOL) || s < env->end)) in parse()
1180 …stdout,"AHA#%04d 0x%04x parse %s `%-.*s'\n", __LINE__, debug_flag, rexname(rex), env->end - s, s))… in parse()
1183 if (rex->re.group.number) in parse()
1184 env->match[rex->re.group.number].rm_so = s - env->beg; in parse()
1185 if (pospush(env, rex, s, BEG_SUB)) in parse()
1187 …catcher.re.group_catch.eo = rex->re.group.number ? &env->match[rex->re.group.number].rm_eo : (rego… in parse()
1190 catcher.serial = rex->serial; in parse()
1192 catcher.next = rex->next; in parse()
1193 r = parse(env, rex->re.group.expr.rex, &catcher, s); in parse()
1197 if (rex->re.group.number) in parse()
1198 env->match[rex->re.group.number].rm_so = -1; in parse()
1202 …#%04d 0x%04x parse %s=>%s `%-.*s'\n", __LINE__, debug_flag, rexname(rex), rexname(rex->re.group_ca… in parse()
1205 if (rex->re.group_catch.eo) in parse()
1206 *rex->re.group_catch.eo = s - env->beg; in parse()
1207 if (pospush(env, rex, s, END_ANY)) in parse()
1210 r = follow(env, rex, rex->re.group_catch.cont, s); in parse()
1214 if (rex->re.group_catch.eo) in parse()
1215 *rex->re.group_catch.eo = -1; in parse()
1220 catcher.flags = rex->flags; in parse()
1221 catcher.serial = rex->serial; in parse()
1224 catcher.next = rex->next; in parse()
1225 return parse(env, rex->re.group.expr.rex, &catcher, s); in parse()
1227 return follow(env, rex, rex->re.rep_catch.cont, rex->re.rep_catch.beg); in parse()
1229 r = parse(env, rex->re.group.expr.rex, NiL, s); in parse()
1231 r = follow(env, rex, cont, s); in parse()
1236 if ((s - env->beg) < rex->re.group.size) in parse()
1239 catcher.flags = rex->flags; in parse()
1240 catcher.serial = rex->serial; in parse()
1244 catcher.next = rex->next; in parse()
1245 for (t = s - rex->re.group.size; t >= env->beg; t--) in parse()
1248 r = parse(env, rex->re.group.expr.rex, &catcher, t); in parse()
1255 if (s != rex->re.behind_catch.beg) in parse()
1257 env->end = rex->re.behind_catch.end; in parse()
1258 return follow(env, rex, rex->re.behind_catch.cont, rex->re.behind_catch.beg); in parse()
1260 if ((s - env->beg) < rex->re.group.size) in parse()
1269 for (t = s - rex->re.group.size; t >= env->beg; t--) in parse()
1271 r = parse(env, rex->re.group.expr.rex, &catcher, t); in parse()
1278 r = follow(env, rex, cont, s); in parse()
1283 return s == rex->re.neg_catch.beg ? GOOD : NONE; in parse()
1285 if (q = rex->re.group.expr.binary.right) in parse()
1292 if (q = rex->re.group.expr.binary.left) in parse()
1295 catcher.flags = rex->flags; in parse()
1296 catcher.serial = rex->serial; in parse()
1300 catcher.next = rex->next; in parse()
1305 …else if (!rex->re.group.size || rex->re.group.size > 0 && env->match[rex->re.group.size].rm_so >= … in parse()
1315 catcher.next = rex->next; in parse()
1318 return follow(env, rex, cont, s); in parse()
1320 rex->re.cond_catch.yes = 1; in parse()
1322 catcher.flags = rex->flags; in parse()
1323 catcher.serial = rex->serial; in parse()
1324 catcher.re.group_catch.cont = rex->re.cond_catch.cont; in parse()
1325 catcher.next = rex->next; in parse()
1326 return parse(env, rex->re.cond_catch.next[1], &catcher, rex->re.cond_catch.beg); in parse()
1328 return follow(env, rex, rex->re.group_catch.cont, s); in parse()
1331 catcher.flags = rex->flags; in parse()
1332 catcher.serial = rex->serial; in parse()
1334 catcher.next = rex->next; in parse()
1335 return parse(env, rex->re.group.expr.rex, &catcher, s); in parse()
1337 switch (r = follow(env, rex, rex->re.group_catch.cont, s)) in parse()
1348 f = rex->re.string.fail; in parse()
1349 b = rex->re.string.base; in parse()
1350 n = rex->re.string.size; in parse()
1353 if (p = rex->map) in parse()
1368 switch (follow(env, rex, cont, t)) in parse()
1399 switch (follow(env, rex, cont, t)) in parse()
1417 if (LEADING(env, rex, s)) in parse()
1426 catcher.next = rex->next; in parse()
1427 if (parse(env, rex->re.group.expr.rex, &catcher, s) == BAD) in parse()
1435 switch (follow(env, rex, cont, s + i)) in parse()
1458 bitset(rex->re.neg_catch.index, s - rex->re.neg_catch.beg); in parse()
1465 if ((c = *s++) == rex->re.nest.primary) in parse()
1467 if (s >= env->end || !(s = nestmatch(s, env->end, rex->re.nest.type, c))) in parse()
1471 if (rex->re.nest.primary >= 0) in parse()
1473 if (rex->re.nest.type[c] & (REX_NEST_delimiter|REX_NEST_separator|REX_NEST_terminator)) in parse()
1475 if (!(s = nestmatch(s, env->end, rex->re.nest.type, c))) in parse()
1477 …} while (s < env->end && !(rex->re.nest.type[*(s-1)] & (REX_NEST_delimiter|REX_NEST_separator|REX_… in parse()
1482 n = rex->hi; in parse()
1485 m = rex->lo; in parse()
1489 c = rex->re.onechar; in parse()
1490 if (!(rex->flags & REG_MINIMAL)) in parse()
1494 if (p = rex->map) in parse()
1507 switch (follow(env, rex, cont, s)) in parse()
1528 if (!(rex->flags & REG_ICASE)) in parse()
1549 switch (follow(env, rex, cont, s)) in parse()
1572 if (p = rex->map) in parse()
1580 switch (follow(env, rex, cont, s)) in parse()
1602 switch (follow(env, rex, cont, s)) in parse()
1619 if (!(rex->flags & REG_ICASE)) in parse()
1629 switch (follow(env, rex, cont, s)) in parse()
1653 switch (follow(env, rex, cont, s)) in parse()
1671 if (env->stack && pospush(env, rex, s, BEG_REP)) in parse()
1673 r = parserep(env, rex, cont, s, 0); in parse()
1678 …%s n %d len %d s `%-.*s'\n", __LINE__, debug_flag, rexname(rex), rex->re.rep_catch.n, s - rex->re.… in parse()
1679 if (env->stack && pospush(env, rex, s, END_ANY)) in parse()
1681 if (s == rex->re.rep_catch.beg && rex->re.rep_catch.n > rex->re.rep_catch.ref->lo) in parse()
1687 …_, rex->re.rep_catch.ref->re.group.expr.rex, rex->re.rep_catch.ref->re.group.expr.rex->re.group.ba… in parse()
1688 …if (!env->stack || s != rex->re.rep_catch.ref->re.rep_catch.beg && !rex->re.rep_catch.ref->re.grou… in parse()
1690 else if (pospush(env, rex, s, END_ANY)) in parse()
1694 r = follow(env, rex, rex->re.rep_catch.cont, s); in parse()
1699 r = parserep(env, rex->re.rep_catch.ref, rex->re.rep_catch.cont, s, rex->re.rep_catch.n); in parse()
1704 …parse %s \"%-.*s\" `%-.*s'\n", __LINE__, debug_flag, rexname(rex), rex->re.string.size, rex->re.st… in parse()
1705 if (rex->re.string.size > (env->end - s)) in parse()
1707 t = rex->re.string.base; in parse()
1708 e = t + rex->re.string.size; in parse()
1709 if (!(p = rex->map)) in parse()
1733 … if (((s + rex->re.trie.min) > env->end) || !(x = rex->re.trie.root[rex->map ? rex->map[*s] : *s])) in parse()
1735 return parsetrie(env, x, rex, cont, s); in parse()
1738 …r = (*env->disc->re_execf)(env->regex, rex->re.exec.data, rex->re.exec.text, rex->re.exec.size, (c… in parse()
1783 if (!(rex = rex->next)) in parse()
1785 if (!(rex = cont)) in parse()
1822 listnode(e->re.group.expr.rex, level + 1); in listnode()
1830 list(Env_t* env, Rex_t* rex) in list() argument
1833 if (rex) in list()
1834 listnode(rex, 1); in list()
1894 DEBUG_TEST(0x1000,(list(env,env->rex)),(0)); in regnexec()
1896 if ((e = env->rex)->type == REX_BM) in regnexec()
2036 drop(env->disc, env->rex); in regfree()