aboutsummaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-12-14 18:11:33 -0800
committerBruce Hill <bruce@bruce-hill.com>2020-12-14 18:11:33 -0800
commitc43e4781763ee3f3f148e821a88e99c6b80c58db (patch)
tree53efc5bdee0f16d6e39e5fcae9888c0b21f06ad2 /vm.c
parent41639915dedfb9e6ec15e2851538b34d0562660b (diff)
Added % operator to ..
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/vm.c b/vm.c
index 4f26d5c..ed151bf 100644
--- a/vm.c
+++ b/vm.c
@@ -144,15 +144,25 @@ static match_t *_match(grammar_t *g, file_t *f, const char *str, vm_op_t *op, un
match_t *m = calloc(sizeof(match_t), 1);
m->start = str;
m->op = op;
- if (op->args.pat) {
+ if (op->args.multiple.first) {
+ match_t **dest = &m->child;
for (const char *prev = NULL; prev < str; ) {
prev = str;
- match_t *p = _match(g, f, str, op->args.pat, flags, rec);
+ match_t *p = _match(g, f, str, op->args.multiple.first, flags, rec);
if (p) {
- m->child = p;
+ *dest = p;
m->end = p->end;
return m;
}
+ if (op->args.multiple.second) {
+ p = _match(g, f, str, op->args.multiple.second, flags, rec);
+ if (p) {
+ *dest = p;
+ dest = &p->nextsibling;
+ str = p->end;
+ continue;
+ }
+ }
// This isn't in the for() structure because there needs to
// be at least once chance to match the pattern, even if
// we're at the end of the string already (e.g. "..$").