aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpeg.13
-rw-r--r--bpeg.c4
-rw-r--r--compiler.c11
-rw-r--r--grammars/bpeg.bpeg2
-rw-r--r--grammars/builtins.bpeg10
-rw-r--r--grammars/html.bpeg5
-rw-r--r--types.h1
-rw-r--r--vm.c9
8 files changed, 10 insertions, 35 deletions
diff --git a/bpeg.1 b/bpeg.1
index cfb1241..1b5fe59 100644
--- a/bpeg.1
+++ b/bpeg.1
@@ -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
diff --git a/bpeg.c b/bpeg.c
index c10be76..9c5a23e 100644
--- a/bpeg.c
+++ b/bpeg.c
@@ -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);
diff --git a/compiler.c b/compiler.c
index fe7ad3f..f5bcd90 100644
--- a/compiler.c
+++ b/compiler.c
@@ -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 = '';
diff --git a/types.h b/types.h
index 2bef298..1a19e86 100644
--- a/types.h
+++ b/types.h
@@ -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,
diff --git a/vm.c b/vm.c
index 9579aee..40efb30 100644
--- a/vm.c
+++ b/vm.c
@@ -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: {