|
#define | INCOMPATIBLE 1 /* destroys arc */ |
|
#define | SATISFIED 2 /* constraint satisfied */ |
|
#define | COMPATIBLE 3 /* compatible but not satisfied yet */ |
|
#define | REPLACEARC 4 /* replace arc's color with constraint color */ |
|
#define | NEXT() (next(v)) /* advance by one token */ |
|
#define | SEE(t) (v->nexttype == (t)) /* is next token this? */ |
|
#define | EAT(t) (SEE(t) && next(v)) /* if next is this, swallow it */ |
|
#define | VISERR(vv) ((vv)->err != 0) /* have we seen an error yet? */ |
|
#define | ISERR() VISERR(v) |
|
#define | VERR(vv, e) |
|
#define | ERR(e) VERR(v, e) /* record an error */ |
|
#define | NOERR() {if (ISERR()) return;} /* if error seen, return */ |
|
#define | NOERRN() {if (ISERR()) return NULL;} /* NOERR with retval */ |
|
#define | NOERRZ() {if (ISERR()) return 0;} /* NOERR with retval */ |
|
#define | INSIST(c, e) do { if (!(c)) ERR(e); } while (0) /* error if c false */ |
|
#define | NOTE(b) (v->re->re_info |= (b)) /* note visible condition */ |
|
#define | EMPTYARC(x, y) newarc(v->nfa, EMPTY, 0, x, y) |
|
#define | EMPTY 'n' /* no token present */ |
|
#define | EOS 'e' /* end of string */ |
|
#define | PLAIN 'p' /* ordinary character */ |
|
#define | DIGIT 'd' /* digit (in bound) */ |
|
#define | BACKREF 'b' /* back reference */ |
|
#define | COLLEL 'I' /* start of [. */ |
|
#define | ECLASS 'E' /* start of [= */ |
|
#define | CCLASS 'C' /* start of [: */ |
|
#define | END 'X' /* end of [. [= [: */ |
|
#define | CCLASSS 's' /* char class shorthand escape */ |
|
#define | CCLASSC 'c' /* complement char class shorthand escape */ |
|
#define | RANGE 'R' /* - within [] which might be range delim. */ |
|
#define | LACON 'L' /* lookaround constraint subRE */ |
|
#define | AHEAD 'a' /* color-lookahead arc */ |
|
#define | BEHIND 'r' /* color-lookbehind arc */ |
|
#define | WBDRY 'w' /* word boundary constraint */ |
|
#define | NWBDRY 'W' /* non-word-boundary constraint */ |
|
#define | CANTMATCH 'x' /* arc that cannot match anything */ |
|
#define | SBEGIN 'A' /* beginning of string (even if not BOL) */ |
|
#define | SEND 'Z' /* end of string (even if not EOL) */ |
|
#define | COLORED(a) |
|
#define | CNOERR() { if (ISERR()) return freev(v, v->err); } |
|
#define | ARCV(t, val) newarc(v->nfa, t, val, lp, rp) |
|
#define | SOME 2 |
|
#define | INF 3 |
|
#define | PAIR(x, y) ((x)*4 + (y)) |
|
#define | REDUCE(x) ( ((x) == DUPINF) ? INF : (((x) > 1) ? SOME : (x)) ) |
|
|
static void | moresubs (struct vars *v, int wanted) |
|
static int | freev (struct vars *v, int err) |
|
static void | makesearch (struct vars *v, struct nfa *nfa) |
|
static struct subre * | parse (struct vars *v, int stopper, int type, struct state *init, struct state *final) |
|
static struct subre * | parsebranch (struct vars *v, int stopper, int type, struct state *left, struct state *right, int partial) |
|
static struct subre * | parseqatom (struct vars *v, int stopper, int type, struct state *lp, struct state *rp, struct subre *top) |
|
static void | nonword (struct vars *v, int dir, struct state *lp, struct state *rp) |
|
static void | word (struct vars *v, int dir, struct state *lp, struct state *rp) |
|
static void | charclass (struct vars *v, enum char_classes cls, struct state *lp, struct state *rp) |
|
static void | charclasscomplement (struct vars *v, enum char_classes cls, struct state *lp, struct state *rp) |
|
static int | scannum (struct vars *v) |
|
static void | repeat (struct vars *v, struct state *lp, struct state *rp, int m, int n) |
|
static void | bracket (struct vars *v, struct state *lp, struct state *rp) |
|
static void | cbracket (struct vars *v, struct state *lp, struct state *rp) |
|
static void | brackpart (struct vars *v, struct state *lp, struct state *rp, bool *have_cclassc) |
|
static const chr * | scanplain (struct vars *v) |
|
static void | onechr (struct vars *v, chr c, struct state *lp, struct state *rp) |
|
static void | optimizebracket (struct vars *v, struct state *lp, struct state *rp) |
|
static void | wordchrs (struct vars *v) |
|
static void | processlacon (struct vars *v, struct state *begin, struct state *end, int latype, struct state *lp, struct state *rp) |
|
static struct subre * | subre (struct vars *v, int op, int flags, struct state *begin, struct state *end) |
|
static void | freesubre (struct vars *v, struct subre *sr) |
|
static void | freesubreandsiblings (struct vars *v, struct subre *sr) |
|
static void | freesrnode (struct vars *v, struct subre *sr) |
|
static void | removecaptures (struct vars *v, struct subre *t) |
|
static int | numst (struct subre *t, int start) |
|
static void | markst (struct subre *t) |
|
static void | cleanst (struct vars *v) |
|
static long | nfatree (struct vars *v, struct subre *t, FILE *f) |
|
static long | nfanode (struct vars *v, struct subre *t, int converttosearch, FILE *f) |
|
static int | newlacon (struct vars *v, struct state *begin, struct state *end, int latype) |
|
static void | freelacons (struct subre *subs, int n) |
|
static void | rfree (regex_t *re) |
|
static int | rstacktoodeep (void) |
|
static void | lexstart (struct vars *v) |
|
static void | prefixes (struct vars *v) |
|
static int | next (struct vars *v) |
|
static int | lexescape (struct vars *v) |
|
static chr | lexdigits (struct vars *v, int base, int minlen, int maxlen) |
|
static int | brenext (struct vars *v, chr c) |
|
static void | skip (struct vars *v) |
|
static chr | newline (void) |
|
static chr | chrnamed (struct vars *v, const chr *startp, const chr *endp, chr lastresort) |
|
static void | initcm (struct vars *v, struct colormap *cm) |
|
static void | freecm (struct colormap *cm) |
|
static color | maxcolor (struct colormap *cm) |
|
static color | newcolor (struct colormap *cm) |
|
static void | freecolor (struct colormap *cm, color co) |
|
static color | pseudocolor (struct colormap *cm) |
|
static color | subcolor (struct colormap *cm, chr c) |
|
static color | subcolorhi (struct colormap *cm, color *pco) |
|
static color | newsub (struct colormap *cm, color co) |
|
static int | newhicolorrow (struct colormap *cm, int oldrow) |
|
static void | newhicolorcols (struct colormap *cm) |
|
static void | subcolorcvec (struct vars *v, struct cvec *cv, struct state *lp, struct state *rp) |
|
static void | subcoloronechr (struct vars *v, chr ch, struct state *lp, struct state *rp, color *lastsubcolor) |
|
static void | subcoloronerange (struct vars *v, chr from, chr to, struct state *lp, struct state *rp, color *lastsubcolor) |
|
static void | subcoloronerow (struct vars *v, int rownum, struct state *lp, struct state *rp, color *lastsubcolor) |
|
static void | okcolors (struct nfa *nfa, struct colormap *cm) |
|
static void | colorchain (struct colormap *cm, struct arc *a) |
|
static void | uncolorchain (struct colormap *cm, struct arc *a) |
|
static void | rainbow (struct nfa *nfa, struct colormap *cm, int type, color but, struct state *from, struct state *to) |
|
static void | colorcomplement (struct nfa *nfa, struct colormap *cm, int type, struct state *of, struct state *from, struct state *to) |
|
static struct nfa * | newnfa (struct vars *v, struct colormap *cm, struct nfa *parent) |
|
static void | freenfa (struct nfa *nfa) |
|
static struct state * | newstate (struct nfa *nfa) |
|
static struct state * | newfstate (struct nfa *nfa, int flag) |
|
static void | dropstate (struct nfa *nfa, struct state *s) |
|
static void | freestate (struct nfa *nfa, struct state *s) |
|
static void | newarc (struct nfa *nfa, int t, color co, struct state *from, struct state *to) |
|
static void | createarc (struct nfa *nfa, int t, color co, struct state *from, struct state *to) |
|
static struct arc * | allocarc (struct nfa *nfa) |
|
static void | freearc (struct nfa *nfa, struct arc *victim) |
|
static void | changearcsource (struct arc *a, struct state *newfrom) |
|
static void | changearctarget (struct arc *a, struct state *newto) |
|
static int | hasnonemptyout (struct state *s) |
|
static struct arc * | findarc (struct state *s, int type, color co) |
|
static void | cparc (struct nfa *nfa, struct arc *oa, struct state *from, struct state *to) |
|
static void | sortins (struct nfa *nfa, struct state *s) |
|
static int | sortins_cmp (const void *a, const void *b) |
|
static void | sortouts (struct nfa *nfa, struct state *s) |
|
static int | sortouts_cmp (const void *a, const void *b) |
|
static void | moveins (struct nfa *nfa, struct state *oldState, struct state *newState) |
|
static void | copyins (struct nfa *nfa, struct state *oldState, struct state *newState) |
|
static void | mergeins (struct nfa *nfa, struct state *s, struct arc **arcarray, int arccount) |
|
static void | moveouts (struct nfa *nfa, struct state *oldState, struct state *newState) |
|
static void | copyouts (struct nfa *nfa, struct state *oldState, struct state *newState) |
|
static void | cloneouts (struct nfa *nfa, struct state *old, struct state *from, struct state *to, int type) |
|
static void | delsub (struct nfa *nfa, struct state *lp, struct state *rp) |
|
static void | deltraverse (struct nfa *nfa, struct state *leftend, struct state *s) |
|
static void | dupnfa (struct nfa *nfa, struct state *start, struct state *stop, struct state *from, struct state *to) |
|
static void | duptraverse (struct nfa *nfa, struct state *s, struct state *stmp) |
|
static void | removeconstraints (struct nfa *nfa, struct state *start, struct state *stop) |
|
static void | removetraverse (struct nfa *nfa, struct state *s) |
|
static void | cleartraverse (struct nfa *nfa, struct state *s) |
|
static struct state * | single_color_transition (struct state *s1, struct state *s2) |
|
static void | specialcolors (struct nfa *nfa) |
|
static long | optimize (struct nfa *nfa, FILE *f) |
|
static void | pullback (struct nfa *nfa, FILE *f) |
|
static int | pull (struct nfa *nfa, struct arc *con, struct state **intermediates) |
|
static void | pushfwd (struct nfa *nfa, FILE *f) |
|
static int | push (struct nfa *nfa, struct arc *con, struct state **intermediates) |
|
static int | combine (struct nfa *nfa, struct arc *con, struct arc *a) |
|
static void | fixempties (struct nfa *nfa, FILE *f) |
|
static struct state * | emptyreachable (struct nfa *nfa, struct state *s, struct state *lastfound, struct arc **inarcsorig) |
|
static int | isconstraintarc (struct arc *a) |
|
static int | hasconstraintout (struct state *s) |
|
static void | fixconstraintloops (struct nfa *nfa, FILE *f) |
|
static int | findconstraintloop (struct nfa *nfa, struct state *s) |
|
static void | breakconstraintloop (struct nfa *nfa, struct state *sinitial) |
|
static void | clonesuccessorstates (struct nfa *nfa, struct state *ssource, struct state *sclone, struct state *spredecessor, struct arc *refarc, char *curdonemap, char *outerdonemap, int nstates) |
|
static void | removecantmatch (struct nfa *nfa) |
|
static void | cleanup (struct nfa *nfa) |
|
static void | markreachable (struct nfa *nfa, struct state *s, struct state *okay, struct state *mark) |
|
static void | markcanreach (struct nfa *nfa, struct state *s, struct state *okay, struct state *mark) |
|
static long | analyze (struct nfa *nfa) |
|
static void | checkmatchall (struct nfa *nfa) |
|
static bool | checkmatchall_recurse (struct nfa *nfa, struct state *s, bool **haspaths) |
|
static bool | check_out_colors_match (struct state *s, color co1, color co2) |
|
static bool | check_in_colors_match (struct state *s, color co1, color co2) |
|
static void | compact (struct nfa *nfa, struct cnfa *cnfa) |
|
static void | carcsort (struct carc *first, size_t n) |
|
static int | carc_cmp (const void *a, const void *b) |
|
static void | freecnfa (struct cnfa *cnfa) |
|
static void | dumpnfa (struct nfa *nfa, FILE *f) |
|
static struct cvec * | newcvec (int nchrs, int nranges) |
|
static struct cvec * | clearcvec (struct cvec *cv) |
|
static void | addchr (struct cvec *cv, chr c) |
|
static void | addrange (struct cvec *cv, chr from, chr to) |
|
static struct cvec * | getcvec (struct vars *v, int nchrs, int nranges) |
|
static void | freecvec (struct cvec *cv) |
|
static int | pg_wc_isdigit (pg_wchar c) |
|
static int | pg_wc_isalpha (pg_wchar c) |
|
static int | pg_wc_isalnum (pg_wchar c) |
|
static int | pg_wc_isword (pg_wchar c) |
|
static int | pg_wc_isupper (pg_wchar c) |
|
static int | pg_wc_islower (pg_wchar c) |
|
static int | pg_wc_isgraph (pg_wchar c) |
|
static int | pg_wc_isprint (pg_wchar c) |
|
static int | pg_wc_ispunct (pg_wchar c) |
|
static int | pg_wc_isspace (pg_wchar c) |
|
static pg_wchar | pg_wc_toupper (pg_wchar c) |
|
static pg_wchar | pg_wc_tolower (pg_wchar c) |
|
static chr | element (struct vars *v, const chr *startp, const chr *endp) |
|
static struct cvec * | range (struct vars *v, chr a, chr b, int cases) |
|
static int | before (chr x, chr y) |
|
static struct cvec * | eclass (struct vars *v, chr c, int cases) |
|
static enum char_classes | lookupcclass (struct vars *v, const chr *startp, const chr *endp) |
|
static struct cvec * | cclasscvec (struct vars *v, enum char_classes cclasscode, int cases) |
|
static int | cclass_column_index (struct colormap *cm, chr c) |
|
static struct cvec * | allcases (struct vars *v, chr c) |
|
static int | cmp (const chr *x, const chr *y, size_t len) |
|
static int | casecmp (const chr *x, const chr *y, size_t len) |
|
int | pg_regcomp (regex_t *re, const chr *string, size_t len, int flags, Oid collation) |
|
static struct subre * parseqatom |
( |
struct vars * |
v, |
|
|
int |
stopper, |
|
|
int |
type, |
|
|
struct state * |
lp, |
|
|
struct state * |
rp, |
|
|
struct subre * |
top |
|
) |
| |
|
static |
Definition at line 838 of file regcomp.c.
844{
847
848#define ARCV(t, val) newarc(v->nfa, t, val, lp, rp)
849 int m,
850 n;
853 int cap;
855 int subno;
856 int atomtype;
857 int qprefer;
858 int f;
859 struct subre **atomp;
860
861
862 atom = NULL;
865 subno = 0;
866
867
869 switch (atomtype)
870 {
871
872 case '^':
877 return top;
878 break;
879 case '$':
884 return top;
885 break;
890 return top;
891 break;
896 return top;
897 break;
898 case '<':
905 return top;
906 break;
907 case '>':
914 return top;
915 break;
927 return top;
928 break;
940 return top;
941 break;
954 return top;
955 break;
956
957 case '*':
958 case '+':
959 case '?':
960 case '{':
962 return top;
963 break;
964 default:
966 return top;
967 break;
968
969 case ')':
971 {
973 return top;
974 }
975
977
978
984 break;
985 case '[':
988 else
992 break;
997 break;
1000
1002 break;
1003 case '.':
1006 lp, rp);
1008 break;
1009
1010 case '(':
1013 {
1016 if ((
size_t) subno >= v->
nsubs)
1018 }
1019 else
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1036
1044 if (cap)
1045 {
1046 if (atom->
capno == 0)
1047 {
1048
1050 atom->
capno = subno;
1051 }
1052 else
1053 {
1054
1059 atom = t;
1060 }
1062 v->
subs[subno] = atom;
1063 }
1064
1065 break;
1080 break;
1081 }
1082
1083
1085 {
1086 case '*':
1087 m = 0;
1091 break;
1092 case '+':
1093 m = 1;
1097 break;
1098 case '?':
1099 m = 0;
1100 n = 1;
1103 break;
1104 case '{':
1108 {
1111 else
1113 if (m > n)
1114 {
1116 return top;
1117 }
1118
1120 }
1121 else
1122 {
1123 n = m;
1124
1125 qprefer = 0;
1126 }
1128 {
1130 return top;
1131 }
1133 break;
1134 default:
1135 m = n = 1;
1136 qprefer = 0;
1137 break;
1138 }
1139
1140
1141 if (m == 0 && n == 0)
1142 {
1143
1144
1145
1146
1147
1148 if (atom != NULL && (atom->
flags &
CAP))
1149 {
1152 }
1153 else
1154 {
1155
1156 if (atom != NULL)
1159 }
1161 return top;
1162 }
1163
1164
1166 f = top->
flags | qprefer | ((atom != NULL) ? atom->
flags : 0);
1168 {
1169 if (!(m == 1 && n == 1))
1171 if (atom != NULL)
1174 return top;
1175 }
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185 if (atom == NULL)
1186 {
1187 atom =
subre(v,
'=', 0, lp, rp);
1189 }
1190
1191
1192
1193
1194
1195
1196
1197
1198 if (atom->
begin == lp || atom->
end == rp)
1199 {
1207 }
1208 else
1209 {
1210
1211
1214 }
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1237
1238
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1262
1263
1264
1266 {
1270
1271
1272
1273
1274
1275
1279
1280
1283 }
1284
1285
1286
1287
1288
1290 {
1291
1293
1295 atom->
min = (short) m;
1296 atom->
max = (short) n;
1298
1300 }
1301 else if (m == 1 && n == 1 &&
1302 (qprefer == 0 ||
1305 {
1306
1308
1310 }
1312 {
1313
1314
1315
1316
1317
1324 *atomp = t;
1325
1327 }
1329 {
1330
1331
1332
1333
1334
1335
1336
1337
1342 t =
subre(v,
'.', f, s, atom->
end);
1347 *atomp = t;
1348
1350 }
1351 else
1352 {
1353
1366 *atomp = t;
1367
1368 }
1369
1370
1373 {
1374
1378
1379
1382
1383
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1399 {
1404 }
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414 else if (t->
child->
op ==
'=' &&
1417 {
1422 }
1423 }
1424 else
1425 {
1426
1427
1428
1429
1434
1435
1436
1437
1438
1439
1442 {
1447 top = t;
1448 }
1449 }
1450
1451 return top;
1452}
if(TABLE==NULL||TABLE_index==NULL)
static void wordchrs(struct vars *v)
static void repeat(struct vars *v, struct state *lp, struct state *rp, int m, int n)
static void moresubs(struct vars *v, int wanted)
static void moveouts(struct nfa *nfa, struct state *oldState, struct state *newState)
static int scannum(struct vars *v)
static void cbracket(struct vars *v, struct state *lp, struct state *rp)
static void nonword(struct vars *v, int dir, struct state *lp, struct state *rp)
static void delsub(struct nfa *nfa, struct state *lp, struct state *rp)
static void removeconstraints(struct nfa *nfa, struct state *start, struct state *stop)
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
static void processlacon(struct vars *v, struct state *begin, struct state *end, int latype, struct state *lp, struct state *rp)
static void word(struct vars *v, int dir, struct state *lp, struct state *rp)
References AHEAD, ARCV, assert, subre::backno, BACKR, BACKREF, subre::begin, BEHIND, bracket(), BRUSE, CAP, subre::capno, cbracket(), CCLASSC, CCLASSS, vars::cflags, charclass(), charclasscomplement(), subre::child, vars::cm, COLORLESS, COMBINE, delsub(), DIGIT, DUPINF, dupnfa(), EAT, EMPTYARC, subre::end, EOS, ERR, subre::flags, freesrnode(), freesubre(), freesubreandsiblings(), if(), INSIST, ISERR, LACON, subre::latype, LONGER, subre::max, MESSY, subre::min, MIXED, moresubs(), moveins(), moveouts(), newstate(), NEXT, vars::nexttype, vars::nextvalue, vars::nfa, state::nins, vars::nlcolor, NOERRN, nonword(), NOTE, state::nouts, vars::nsubexp, vars::nsubs, NWBDRY, okcolors(), onechr(), subre::op, parse(), parsebranch(), PLAIN, PREF, processlacon(), rainbow(), REG_ADVANCED, REG_ASSERT, REG_BADBR, REG_BADRPT, REG_EPAREN, REG_ESUBREG, REG_EXTENDED, REG_NLANCH, REG_NLSTOP, REG_UPBOTCH, removeconstraints(), repeat(), s2, SBEGIN, scannum(), SEE, SEND, SHORTER, subre::sibling, subre(), vars::subs, type, UP, WBDRY, word(), and wordchrs().
Referenced by parsebranch().