diff options
| -rw-r--r-- | bpeg.1 | 3 | ||||
| -rw-r--r-- | bpeg.c | 4 | ||||
| -rw-r--r-- | compiler.c | 11 | ||||
| -rw-r--r-- | grammars/bpeg.bpeg | 2 | ||||
| -rw-r--r-- | grammars/builtins.bpeg | 10 | ||||
| -rw-r--r-- | grammars/html.bpeg | 5 | ||||
| -rw-r--r-- | types.h | 1 | ||||
| -rw-r--r-- | vm.c | 9 |
8 files changed, 10 insertions, 35 deletions
@@ -147,9 +147,6 @@ same length. Pronounced \fI<pat1>\fB-assuming-it-equals-\fI<pat2>\fR This pattern matches the indentation at the beginning of a line that has the same indentation as the line before (or zero indentation on the first line). -.B (/) -The empty string (a pattern that always matches). - .B # \fI<comment>\fR A comment @@ -156,9 +156,9 @@ int main(int argc, char *argv[]) } if (isatty(STDOUT_FILENO)) { - vm_op_t *p = bpeg_pattern(NULL, "(/)"); + vm_op_t *p = bpeg_pattern(NULL, "''"); check(p, "Failed to compile is-tty"); - add_def(g, NULL, "(/)", "is-tty", p); + add_def(g, NULL, "''", "is-tty", p); } vm_op_t *pattern = lookup(g, rule); @@ -323,17 +323,6 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str) op->op = VM_REF; break; } - // Empty choice (/) or {/} - case '/': { - const char *next = after_spaces(str); - if (*next == ')' || *next == '}') { - op->op = VM_EMPTY; - } else { - free(op); - return NULL; - } - break; - } case '|': { op->op = VM_NODENT; break; diff --git a/grammars/bpeg.bpeg b/grammars/bpeg.bpeg index dd3a3b4..b1381bc 100644 --- a/grammars/bpeg.bpeg +++ b/grammars/bpeg.bpeg @@ -33,7 +33,7 @@ Nodent = `|; Upto-and = 2-3`. 0-1(_@pat); Repeat = ( @[min]int _ `- _ @[max]int - / @[min]int _ `+ @[max](/) + / @[min]int _ `+ @[max]'' / @[min]@[max]int ) _ @[repeat-pat]pat 0-1( __ `% __ @[sep]pat); After = `< _ pat; diff --git a/grammars/builtins.bpeg b/grammars/builtins.bpeg index 8abb550..7446212 100644 --- a/grammars/builtins.bpeg +++ b/grammars/builtins.bpeg @@ -1,5 +1,5 @@ -yes = (/); -no = !(/); +yes = ''; +no = !''; # Configurable options: is-tty = no; # Defined as either always-match or always-fail, depending on stdout @@ -8,8 +8,8 @@ print-filenames = is-tty; highlight = is-tty; # Meta-rules for acting on everything: -pattern = !(/); # Not defined by default -replacement = !(/); # Not defined by default +pattern = !''; # Not defined by default +replacement = !''; # Not defined by default replace-all = define-highlights add-filename 1+(...@hl-replacement) ...; find-all = define-highlights add-filename 1+find-next%\n 0-1{!<\n => "\n"}; find-next = matching-line / {..\n =>} find-next; @@ -50,7 +50,7 @@ c-block-comment = '/*' ... '*/'; c-line-comment = '//' ..$; c-comment = c-line-comment / c-block-comment; hash-comment = `# ..$; -comment = !(/); # No default definition, can be overridden +comment = !''; # No default definition, can be overridden WS = ` /\t/\n/\r/comment; ws = ` /\t; $$ = !$.; diff --git a/grammars/html.bpeg b/grammars/html.bpeg index 451e61c..3a2d9f2 100644 --- a/grammars/html.bpeg +++ b/grammars/html.bpeg @@ -19,9 +19,8 @@ normal-element = `< @[tag](id==match-tag) __attributes__ `> >match-body @[body]0 comment = "<!--" ..."-->"; -attributes = 0+(!(attribute==match-attribute))%__ __(attribute==match-attribute)__ 0+attribute%__; +attributes = 0+attribute%__; attribute = (1+id%`:)__`=__ (id / `" ..`" / `' ..`'); attribute = (1+id%`:)__`=__ (id / `" ..`" / `' ..`'); -match-attribute = attribute; match-tag = id; -match-body = (/); +match-body = ''; @@ -17,7 +17,6 @@ enum BPEGFlag { * BPEG virtual machine opcodes (these must be kept in sync with the names in vm.c) */ enum VMOpcode { - VM_EMPTY = 0, VM_ANYCHAR = 1, VM_STRING, VM_RANGE, @@ -17,7 +17,6 @@ static match_t *get_capture_named(match_t *m, const char *name); * The names of the opcodes (keep in sync with the enum definition above) */ static const char *opcode_names[] = { - [VM_EMPTY] = "EMPTY", [VM_ANYCHAR] = "ANYCHAR", [VM_STRING] = "STRING", [VM_RANGE] = "RANGE", @@ -83,13 +82,6 @@ typedef struct recursive_ref_s { static match_t *_match(grammar_t *g, file_t *f, const char *str, vm_op_t *op, unsigned int flags, recursive_ref_t *rec) { switch (op->op) { - case VM_EMPTY: { - match_t *m = calloc(sizeof(match_t), 1); - m->op = op; - m->start = str; - m->end = str; - return m; - } case VM_ANYCHAR: { if (!*str || (!op->multiline && *str == '\n')) return NULL; @@ -382,7 +374,6 @@ void print_pattern(vm_op_t *op) { switch (op->op) { case VM_REF: fprintf(stderr, "a $%s", op->args.s); break; - case VM_EMPTY: fprintf(stderr, "the empty string"); break; case VM_ANYCHAR: fprintf(stderr, "any char"); break; case VM_STRING: fprintf(stderr, "string \"%s\"", op->args.s); break; case VM_RANGE: { |
