diff options
author | ben <ben@rana> | 2016-04-26 22:23:44 -0500 |
---|---|---|
committer | ben <ben@rana> | 2016-04-26 22:23:44 -0500 |
commit | 0a460e1722c50e31653359f8a86fe0b606d2b513 (patch) | |
tree | b5a00bbfc883aa98709db012e0a7bacc67e234af /sys/include | |
parent | 651d6c2bc68e7e5224c3ba41b094e37b1c1890ed (diff) |
New libregexp and APE ported to native
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/regexp.h | 92 |
1 files changed, 41 insertions, 51 deletions
diff --git a/sys/include/regexp.h b/sys/include/regexp.h index a574674ac..45ae64b2c 100644 --- a/sys/include/regexp.h +++ b/sys/include/regexp.h @@ -1,15 +1,29 @@ -#pragma src "/sys/src/libregexp" -#pragma lib "libregexp.a" +#pragma src "/sys/src/libregexp" +#pragma lib "libregexp.a" +enum +{ + OANY = 0, + OBOL, + OCLASS, + OEOL, + OJMP, + ONOTNL, + ORUNE, + OSAVE, + OSPLIT, + OUNSAVE, +}; + +typedef struct Resub Resub; +typedef struct Reinst Reinst; +typedef struct Reprog Reprog; +typedef struct Rethread Rethread; -typedef struct Resub Resub; -typedef struct Reclass Reclass; -typedef struct Reinst Reinst; -typedef struct Reprog Reprog; +#pragma incomplete Reinst +#pragma incomplete Rethread -/* - * Sub expression matches - */ -struct Resub{ +struct Resub +{ union { char *sp; @@ -21,46 +35,22 @@ struct Resub{ Rune *rep; }; }; - -/* - * character class, each pair of rune's defines a range - */ -struct Reclass{ - Rune *end; - Rune spans[64]; -}; - -/* - * Machine instructions - */ -struct Reinst{ - int type; - union { - Reclass *cp; /* class pointer */ - Rune r; /* character */ - int subid; /* sub-expression id for RBRA and LBRA */ - Reinst *right; /* right child of OR */ - }; - union { /* regexp relies on these two being in the same union */ - Reinst *left; /* left child of OR */ - Reinst *next; /* next instruction for CAT & LBRA */ - }; -}; - -/* - * Reprogram definition - */ -struct Reprog{ - Reinst *startinst; /* start pc */ - Reclass class[16]; /* .data */ - Reinst firstinst[5]; /* .text */ +struct Reprog +{ + Reinst *startinst; + Rethread *threads; + Rethread **thrpool; + char *regstr; + int len; + int nthr; }; -extern Reprog *regcomp(char*); -extern Reprog *regcomplit(char*); -extern Reprog *regcompnl(char*); -extern void regerror(char*); -extern int regexec(Reprog*, char*, Resub*, int); -extern void regsub(char*, char*, int, Resub*, int); -extern int rregexec(Reprog*, Rune*, Resub*, int); -extern void rregsub(Rune*, Rune*, int, Resub*, int); +Reprog* regcomp(char*); +Reprog* regcomplit(char*); +Reprog* regcompnl(char*); +void regerror(char*); +int regexec(Reprog*, char*, Resub*, int); +void regsub(char*, char*, int, Resub*, int); +int rregexec(Reprog*, Rune*, Resub*, int); +void rregsub(Rune*, Rune*, int, Resub*, int); +int reprogfmt(Fmt *); |