aboutsummaryrefslogtreecommitdiff
path: root/match.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-09-23 15:15:48 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-09-23 15:15:48 -0700
commit8e1e6572feabd291cbd5048459c0a58c6460ff91 (patch)
treeadf66d019c271dc58cd9d47abdb7b1b20ab2226f /match.h
parentd20afd10b693180b667ebdb0bfab7b9afabc0b42 (diff)
Moved type defs into their own files instead of types.h
Diffstat (limited to 'match.h')
-rw-r--r--match.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/match.h b/match.h
index b6e7392..db948b8 100644
--- a/match.h
+++ b/match.h
@@ -8,7 +8,31 @@
#include <stdio.h>
#include "files.h"
-#include "types.h"
+#include "pattern.h"
+#include "definitions.h"
+
+struct match_s; // forward declared to resolve circular struct defs
+
+typedef struct {
+ struct match_s **home, *next;
+} match_dll_t;
+
+// #define MATCH_FROM(node, name) ((match_t*)((char*)node + (size_t)(&((match_t*)0)->name)))
+
+//
+// Pattern matching result object
+//
+typedef struct match_s {
+ // Where the match starts and ends (end is after the last character)
+ const char *start, *end;
+ pat_t *pat;
+ // Intrusive linked list nodes for garbage collection and cache buckets:
+ match_dll_t gc, cache;
+ size_t defs_id;
+ int refcount;
+ struct match_s **children;
+ struct match_s *_children[3];
+} match_t;
__attribute__((returns_nonnull))
match_t *new_match(def_t *defs, pat_t *pat, const char *start, const char *end, match_t *children[]);