summaryrefslogtreecommitdiff
path: root/sys/src/cmd/upas/bayes/regexp.h
diff options
context:
space:
mode:
authorben <ben@rana>2016-04-26 22:26:03 -0500
committerben <ben@rana>2016-04-26 22:26:03 -0500
commit0f8168038af32828fcdc39575dea0e4de0c01122 (patch)
tree58c3e51227504adb0fce952dee899363747ade89 /sys/src/cmd/upas/bayes/regexp.h
parent0a460e1722c50e31653359f8a86fe0b606d2b513 (diff)
remove old libregexp files; add headers for upas/bayes
Diffstat (limited to 'sys/src/cmd/upas/bayes/regexp.h')
-rw-r--r--sys/src/cmd/upas/bayes/regexp.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/sys/src/cmd/upas/bayes/regexp.h b/sys/src/cmd/upas/bayes/regexp.h
new file mode 100644
index 000000000..780dc8001
--- /dev/null
+++ b/sys/src/cmd/upas/bayes/regexp.h
@@ -0,0 +1,66 @@
+#pragma src "/sys/src/oldlibregexp"
+#pragma lib "oldlibregexp.a"
+
+typedef struct Resub Resub;
+typedef struct Reclass Reclass;
+typedef struct Reinst Reinst;
+typedef struct Reprog Reprog;
+
+/*
+ * Sub expression matches
+ */
+struct Resub{
+ union
+ {
+ char *sp;
+ Rune *rsp;
+ };
+ union
+ {
+ char *ep;
+ 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 */
+};
+
+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);