diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-04-28 20:53:53 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-04-28 20:53:53 +0200 |
commit | 4c21da2ededfb5fc628dbee0d75b0aa5263ef97b (patch) | |
tree | 1d3e8ab7c177b55c74e03c5f4c26f31b523abfbc /sys/src/libregexp/regimpl.h | |
parent | ca5b491753ad363da8d9deb5978b56231ec27bf5 (diff) | |
parent | eb168924840977fe0941d4fc90e56db0d484a6e4 (diff) |
merge
Diffstat (limited to 'sys/src/libregexp/regimpl.h')
-rw-r--r-- | sys/src/libregexp/regimpl.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/sys/src/libregexp/regimpl.h b/sys/src/libregexp/regimpl.h new file mode 100644 index 000000000..f173a970c --- /dev/null +++ b/sys/src/libregexp/regimpl.h @@ -0,0 +1,104 @@ +enum +{ + LANY = 0, + LBOL, + LCLASS, + LEND, + LEOL, + LLPAR, + LOR, + LREP, + LRPAR, + LRUNE, + + TANY = 0, + TBOL, + TCAT, + TCLASS, + TEOL, + TNOTNL, + TOR, + TPLUS, + TQUES, + TRUNE, + TSTAR, + TSUB, + + NSUBEXPM = 32 +}; + +typedef struct Parselex Parselex; +typedef struct Renode Renode; + +struct Parselex +{ + /* Parse */ + Renode *next; + Renode *nodes; + int sub; + int instrs; + jmp_buf exitenv; + /* Lex */ + void (*getnextr)(Parselex*); + char *rawexp; + char *orig; + Rune rune; + Rune peek; + int peeklex; + int done; + int literal; + Rune cpairs[400+2]; + int nc; +}; +struct Renode +{ + int op; + Renode *left; + Rune r; + union + { + Rune r1; + int sub; + Renode *right; + }; + int nclass; +}; +struct Rethread +{ + Reinst *pc; + Resub sem[NSUBEXPM]; + int pri; + Rethread *next; +}; +struct Reinst +{ + char op; + int gen; + Reinst *a; + union + { + Rune r; + int sub; + }; + union + { + Rune r1; + Reinst *b; + }; +}; + +static int lex(Parselex*); +static void getnextr(Parselex*); +static void getnextrlit(Parselex*); +static void getclass(Parselex*); +static Renode *e0(Parselex*); +static Renode *e1(Parselex*); +static Renode *e2(Parselex*); +static Renode *e3(Parselex*); +static Renode *buildclass(Parselex*); +static Renode *buildclassn(Parselex*); +static int pcmp(void*, void*); +static Reprog *regcomp1(char*, int, int); +static Reinst *compile(Renode*, Reprog*, int); +static Reinst *compile1(Renode*, Reinst*, int*, int); +static void prtree(Renode*, int, int); |