From c18eb4c9968289c4808d70f7124c0b6bed5eb022 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 12 Sep 2020 18:20:13 -0700 Subject: Added backrefs --- types.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'types.h') diff --git a/types.h b/types.h index f8899b3..82c282c 100644 --- a/types.h +++ b/types.h @@ -7,7 +7,7 @@ #include /* - * BPEG virtual machine opcodes + * BPEG virtual machine opcodes (these must be kept in sync with the names in vm.c) */ enum VMOpcode { VM_EMPTY = 0, @@ -25,6 +25,7 @@ enum VMOpcode { VM_CHAIN, VM_REPLACE, VM_REF, + VM_BACKREF, }; /* @@ -57,6 +58,7 @@ typedef struct vm_op_s { struct vm_op_s *capture_pat; char *name; } capture; + void *backref; struct vm_op_s *pat; } args; } vm_op_t; @@ -81,8 +83,15 @@ typedef struct { } def_t; typedef struct { + size_t defcount, defcapacity; def_t *definitions; - size_t size, capacity; + + size_t backrefcount, backrefcapacity; + struct { + const char *name; + match_t *capture; + vm_op_t *op; + } *backrefs; } grammar_t; #endif -- cgit v1.2.3