From 384fb6293a85502bbc9423b8b098337e77bb3738 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 10 Sep 2020 00:27:51 -0700 Subject: Added "~x" (anything but x) and dropped "^x" (up to x), added "^" (start of line), added "$" (end of line), and changed "`a,z" to "`a-z" --- bpeg.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'bpeg.h') diff --git a/bpeg.h b/bpeg.h index 3ca21c2..0109f8d 100644 --- a/bpeg.h +++ b/bpeg.h @@ -10,7 +10,16 @@ #include "utils.h" -const char *usage = "Usage: bpeg [-m|--multiline] [-v|--verbose] [-h|--help] [-s|--slow] []"; +const char *usage = ( + "Usage:\n" + " bpeg [flags] [...]\n\n" + "Flags:\n" + " -m --multiline\t dot and similar patterns include newlines\n" + " -v --verbose\t print verbose debugging info\n" + " -h --help\t print the usage and quit\n" + " -s --slow\t run in slow mode for debugging\n" + " -r --replace replace the input pattern with the given replacement\n" + " -g --grammar use the specified file as a grammar\n"); /* * Pattern matching result object */ @@ -28,10 +37,10 @@ typedef struct match_s { enum VMOpcode { VM_EMPTY = 0, VM_ANYCHAR = 1, + VM_ANYTHING_BUT, VM_STRING, VM_RANGE, VM_NOT, - VM_UPTO, VM_UPTO_AND, VM_REPEAT, VM_BEFORE, @@ -82,6 +91,8 @@ static match_t *free_match(match_t *m); static match_t *match(const char *str, vm_op_t *op); static vm_op_t *compile_bpeg(const char *source, const char *str); static vm_op_t *load_grammar(const char *grammar); +static vm_op_t *add_def(const char *name, const char *source, vm_op_t *op); +static vm_op_t *load_def(const char *name, const char *source); static vm_op_t *chain_together(vm_op_t *first, vm_op_t *second); static vm_op_t *compile_bpeg_string(const char *source, const char *str); static vm_op_t *expand_chain(const char *source, vm_op_t *first); -- cgit v1.2.3