diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-01-10 00:12:09 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-01-10 00:12:09 -0800 |
| commit | 9d1f51c483578c66d401a59f59ad18add0e1a52f (patch) | |
| tree | 569d53f5a3adb2e7de56bba7f38ad0267476aec2 /types.h | |
| parent | aa91728a082cde784e01078944dc39e6df0877fa (diff) | |
Simplified grammars using intrusive linked lists instead of dynamic
arrays
Diffstat (limited to 'types.h')
| -rw-r--r-- | types.h | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -88,24 +88,33 @@ typedef struct match_s { vm_op_t *op; } match_t; - -typedef struct { +/* + * Pattern matching rule definition + */ +typedef struct def_s { const char *name; const char *source; file_t *file; vm_op_t *op; + struct def_s *next; } def_t; -typedef struct { - size_t defcount, defcapacity; - def_t *definitions; +/* + * Backreference (look up previous capture by name) + */ +typedef struct backref_s { + const char *name; + match_t *capture; + vm_op_t *op; + struct backref_s *next; +} backref_t; - size_t backrefcount, backrefcapacity; - struct { - const char *name; - match_t *capture; - vm_op_t *op; - } *backrefs; +/* + * Grammar (a collection of definitions) + */ +typedef struct { + def_t *firstdef; + backref_t *firstbackref; } grammar_t; #endif |
