From f7cdd6d4d2c492683f0b5f65fa2fe788772df7c8 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 7 Sep 2020 23:22:43 -0700 Subject: Cleanup, splitting into files --- bpeg.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 bpeg.h (limited to 'bpeg.h') diff --git a/bpeg.h b/bpeg.h new file mode 100644 index 0000000..8bc813a --- /dev/null +++ b/bpeg.h @@ -0,0 +1,40 @@ +/* + * bpeg.h - Header file for the bpeg parser + */ +#include +#include +#include +#include +#include + +#include "utils.h" +#include "vm.h" + +typedef struct match_s { + const char *start, *end; + union { + unsigned int is_capture:1; + const char *name; + } capture; + const char *replacement; + struct match_s *child, *nextsibling; +} match_t; + +static match_t *free_match(match_t *m); +static match_t *match(const char *str, vm_op_t *op); +static void set_range(vm_op_t *op, ssize_t min, ssize_t max, vm_op_t *pat, vm_op_t *sep); +static inline const char *after_spaces(const char *str); +static vm_op_t *expand_choices(vm_op_t *op); +static vm_op_t *expand_chain(vm_op_t *first); +static vm_op_t *compile_bpeg(const char *str); + + +typedef struct { + const char *name; + vm_op_t *op; +} def_t; + +static def_t defs[1024] = {{NULL, NULL}}; +size_t ndefs = 0; +static int verbose = 1; + -- cgit v1.2.3