diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-09-07 23:22:43 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-09-07 23:22:43 -0700 |
| commit | f7cdd6d4d2c492683f0b5f65fa2fe788772df7c8 (patch) | |
| tree | 75e7ab9b26a38c3ca7ba4337ec4bc991e8a9d2fa /vm.h | |
| parent | cead7e5b2626e80f826236320e63f2e8570e7fb6 (diff) | |
Cleanup, splitting into files
Diffstat (limited to 'vm.h')
| -rw-r--r-- | vm.h | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,50 @@ +/* + * vm.h - Source code for the BPEG virtual machine datatypes + */ + +enum VMOpcode { + VM_EMPTY = 0, + VM_ANYCHAR = 1, + VM_STRING, + VM_RANGE, + VM_NOT, + VM_UPTO, + VM_UPTO_AND, + VM_REPEAT, + VM_BEFORE, + VM_AFTER, + VM_CAPTURE, + VM_OTHERWISE, + VM_CHAIN, + VM_REPLACE, + VM_REF, +}; + +typedef struct vm_op_s { + enum VMOpcode op; + const char *start, *end; + ssize_t len; + union { + const char *s; + struct { + char low, high; + } range; + struct { + ssize_t min, max; + struct vm_op_s *sep, *repeat_pat; + } repetitions; + struct { + struct vm_op_s *first, *second; + } multiple; + struct { + struct vm_op_s *replace_pat; + const char *replacement; + } replace; + struct { + struct vm_op_s *capture_pat; + char *name; + } capture; + struct vm_op_s *pat; + } args; +} vm_op_t; + |
