diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-01-15 12:12:56 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-01-15 12:12:56 -0800 |
| commit | cbe1d97b37963a7ab75900463570cb6a109be8b4 (patch) | |
| tree | 70f89a2ce638aa96cf617b3badef13bad2179871 /grammar.c | |
| parent | b29060f38b30e6e379769582a0cf7cc3e9ae5056 (diff) | |
Fixed bug with backrefs. The backref pushing was overly greedy and
has been updated to only push backrefs when a capture is directly
in the chain and not recursively contained within it.
Diffstat (limited to 'grammar.c')
| -rw-r--r-- | grammar.c | 19 |
1 files changed, 1 insertions, 18 deletions
@@ -10,9 +10,6 @@ #include "grammar.h" #include "utils.h" -__attribute__((nonnull(2,3,4), returns_nonnull)) -static def_t *with_backref(def_t *defs, file_t *f, const char *name, match_t *m); - // // Return a new list of definitions with one added to the front // @@ -71,7 +68,7 @@ def_t *lookup(def_t *defs, const char *name) // // Push a backreference onto the backreference stack // -static def_t *with_backref(def_t *defs, file_t *f, const char *name, match_t *m) +def_t *with_backref(def_t *defs, file_t *f, const char *name, match_t *m) { vm_op_t *op = new_op(f, m->start, VM_BACKREF); op->end = m->end; @@ -81,20 +78,6 @@ static def_t *with_backref(def_t *defs, file_t *f, const char *name, match_t *m) } // -// Push all the backreferences contained in a match onto the backreference stack -// -def_t *with_backrefs(def_t *defs, file_t *f, match_t *m) -{ - if (m->op->type != VM_REF) { - if (m->op->type == VM_CAPTURE && m->op->args.capture.name) - defs = with_backref(defs, f, m->op->args.capture.name, m->child); - if (m->child) defs = with_backrefs(defs, f, m->child); - if (m->nextsibling) defs = with_backrefs(defs, f, m->nextsibling); - } - return defs; -} - -// // Free all the given definitions up till (but not including) `stop` // void free_defs(def_t **defs, def_t *stop) |
