summaryrefslogtreecommitdiffstats
path: root/regex.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2009-11-02 13:58:30 -0800
committerKaz Kylheku <kaz@kylheku.com>2009-11-02 13:58:30 -0800
commit6191fbb2ca7a9ac339dd3994bdea8273ceb0a24d (patch)
tree3ddb47f26c66c5e4d09dd87f4518468f489f84a3 /regex.h
parent4b493073a6deafa6b4ac6386a0eab034e0e20082 (diff)
downloadtxr-6191fbb2ca7a9ac339dd3994bdea8273ceb0a24d.tar.gz
txr-6191fbb2ca7a9ac339dd3994bdea8273ceb0a24d.tar.bz2
txr-6191fbb2ca7a9ac339dd3994bdea8273ceb0a24d.zip
Start of implementation for freestyle matching.
Lazy strings implemented, incompletely. Changed string function to implicitly strdup; non-strdup version changed to string_own. Fixed wrong uses of strdup rather than chk_strdup. Functions added to regex module to provide regex matching as a state machine to which characters are fed.
Diffstat (limited to 'regex.h')
-rw-r--r--regex.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/regex.h b/regex.h
index 5f2d5021..973ab501 100644
--- a/regex.h
+++ b/regex.h
@@ -90,16 +90,29 @@ void nfa_state_free(nfa_state_t *st);
void nfa_state_shallow_free(nfa_state_t *st);
void nfa_state_merge(nfa_state_t *accept, nfa_state_t *);
-typedef struct nfa nfa_t;
-
-struct nfa {
+typedef struct nfa {
nfa_state_t *start;
nfa_state_t *accept;
-};
+} nfa_t;
+
+enum nfam_result { NFAM_INCOMPLETE, NFAM_FAIL, NFAM_MATCH };
+
+typedef struct nfa_machine {
+ long last_accept_pos;
+ unsigned visited;
+ nfa_state_t **move, **clos, **stack;
+ int nmove, nclos;
+ long count;
+ nfa_t nfa;
+} nfa_machine_t;
nfa_t nfa_compile_regex(obj_t *regex);
void nfa_free(nfa_t);
long nfa_run(nfa_t nfa, const char *str);
+void nfa_machine_init(nfa_machine_t *, nfa_t);
+void nfa_machine_cleanup(nfa_machine_t *);
+int nfa_machine_feed(nfa_machine_t *, int ch);
+long nfa_machine_match_span(nfa_machine_t *);
obj_t *regex_compile(obj_t *regex_sexp);
obj_t *regexp(obj_t *);
nfa_t *regex_nfa(obj_t *);