aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-12-30 19:42:47 -0800
committerBruce Hill <bruce@bruce-hill.com>2020-12-30 19:42:47 -0800
commitff2ef9504159665c30b16b398f1e755665353bc3 (patch)
tree5957bff54c7f1b7619dd044cd55b22fe83f80d09
parentbc2ddc0408e47cbc12b0f7d0c0abae943fc74b83 (diff)
Fully purging "bpeg" from the source
-rw-r--r--.gitignore2
-rw-r--r--LICENSE2
-rw-r--r--Makefile2
-rw-r--r--README.md10
-rw-r--r--bp.c (renamed from bpeg.c)58
-rw-r--r--compiler.c50
-rw-r--r--compiler.h10
-rw-r--r--grammar.c4
-rw-r--r--grammars/bpeg.bp4
-rw-r--r--types.h20
-rw-r--r--utils.c2
-rw-r--r--vm.c10
-rw-r--r--vm.h2
13 files changed, 88 insertions, 88 deletions
diff --git a/.gitignore b/.gitignore
index 73725c9..679010a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
*.o
tags
-bpeg
+bp
.*
!.gitignore
diff --git a/LICENSE b/LICENSE
index e6a922d..6f01923 100644
--- a/LICENSE
+++ b/LICENSE
@@ -17,7 +17,7 @@ whose value derives, entirely or substantially, from the functionality of the
Software. Any license notice or attribution required by the License must also
include this Commons Clause License Condition notice.
-Software: BPEG
+Software: BP
License: MIT
Licensor: Bruce Hill
diff --git a/Makefile b/Makefile
index d419241..39d15de 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ all: $(NAME)
.c.o:
$(CC) -c $(CFLAGS) $(CWARN) $(G) $(O) -o $@ $<
-$(NAME): $(OBJFILES) bpeg.c
+$(NAME): $(OBJFILES) bp.c
$(CC) $(CFLAGS) $(CWARN) $(G) $(O) -o $@ $^
clean:
diff --git a/README.md b/README.md
index cd290e1..04bfba4 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-# BPEG
+# BP - Bruce's PEG Tool
-BPEG is a parsing expression grammar tool for the command line.
+BP is a parsing expression grammar (PEG) tool for the command line.
It's written in pure C with no dependencies.
## Usage
@@ -24,8 +24,8 @@ It's written in pure C with no dependencies.
See `man ./bp.1` for more details.
-## BPEG Patterns
-BPEG patterns are a mixture of Parsing Expression Grammar and Regular
+## BP Patterns
+BP patterns are a mixture of Parsing Expression Grammar and Regular
Expression syntax, with a preference for prefix operators instead of
suffix operators.
@@ -70,7 +70,7 @@ Pattern | Meaning
See `man ./bp.1` for more details.
## License
-BPEG is provided under the MIT license with the [Commons Clause](https://commonsclause.com/)
+BP is provided under the MIT license with the [Commons Clause](https://commonsclause.com/)
(you can't sell this software without the developer's permission, but you're
otherwise free to use, modify, and redistribute it free of charge).
See [LICENSE](LICENSE) for details.
diff --git a/bpeg.c b/bp.c
index 438c302..41acbcc 100644
--- a/bpeg.c
+++ b/bp.c
@@ -1,5 +1,5 @@
/*
- * bpeg.c - Source code for the bpeg parser
+ * bp.c - Source code for the bp parser
*
* See `man ./bp.1` for more details
*/
@@ -77,7 +77,7 @@ static int run_match(grammar_t *g, const char *filename, vm_op_t *pattern, unsig
static int printed_matches = 0;
file_t *f = load_file(filename);
check(f, "Could not open file: %s", filename);
- if (flags & BPEG_INPLACE) // Need to do this before matching
+ if (flags & BP_INPLACE) // Need to do this before matching
intern_file(f);
match_t *m = match(g, f, f->contents, pattern, flags);
if (m && print_errors(f, m) > 0)
@@ -85,21 +85,21 @@ static int run_match(grammar_t *g, const char *filename, vm_op_t *pattern, unsig
if (m != NULL && m->end > m->start + 1) {
++printed_matches;
- if (flags & BPEG_EXPLAIN) {
+ if (flags & BP_EXPLAIN) {
if (filename)
printf("\033[1;4m%s\033[0m\n", filename);
visualize_match(m);
- } else if (flags & BPEG_LISTFILES) {
+ } else if (flags & BP_LISTFILES) {
printf("%s\n", filename);
- } else if (flags & BPEG_JSON) {
+ } else if (flags & BP_JSON) {
if (printed_matches > 1)
printf(",\n");
printf("{\"filename\":\"%s\",", filename ? filename : "-");
printf("\"tree\":{\"rule\":\"text\",\"start\":%d,\"end\":%ld,\"children\":[",
0, f->end - f->contents);
- json_match(f->contents, m, (flags & BPEG_VERBOSE) ? 1 : 0);
+ json_match(f->contents, m, (flags & BP_VERBOSE) ? 1 : 0);
printf("]}}\n");
- } else if (flags & BPEG_INPLACE && filename) {
+ } else if (flags & BP_INPLACE && filename) {
FILE *out = fopen(filename, "w");
print_match(out, f, m, 0);
fclose(out);
@@ -153,22 +153,22 @@ int main(int argc, char *argv[])
printf("%s\n", usage);
return 0;
} else if (streq(argv[i], "--verbose")) {
- flags |= BPEG_VERBOSE;
+ flags |= BP_VERBOSE;
} else if (streq(argv[i], "--explain")) {
- flags |= BPEG_EXPLAIN;
+ flags |= BP_EXPLAIN;
} else if (streq(argv[i], "--json")) {
- flags |= BPEG_JSON;
+ flags |= BP_JSON;
} else if (streq(argv[i], "--inplace")) {
- flags |= BPEG_INPLACE;
+ flags |= BP_INPLACE;
} else if (streq(argv[i], "--ignore-case")) {
- flags |= BPEG_IGNORECASE;
+ flags |= BP_IGNORECASE;
} else if (streq(argv[i], "--list-files")) {
- flags |= BPEG_LISTFILES;
+ flags |= BP_LISTFILES;
} else if (FLAG("--replace") || FLAG("-r")) {
file_t *pat_file = spoof_file("<pattern>", "pattern");
- vm_op_t *patref = bpeg_pattern(pat_file, pat_file->contents);
+ vm_op_t *patref = bp_pattern(pat_file, pat_file->contents);
file_t *replace_file = spoof_file("<replace argument>", flag);
- vm_op_t *rep = bpeg_replacement(replace_file, patref, replace_file->contents);
+ vm_op_t *rep = bp_replacement(replace_file, patref, replace_file->contents);
check(rep, "Replacement failed to compile: %s", flag);
add_def(g, replace_file, replace_file->contents, "replacement", rep);
rule = "replace-all";
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
*eq = '\0';
char *src = ++eq;
file_t *def_file = spoof_file(def, src);
- vm_op_t *pat = bpeg_pattern(def_file, def_file->contents);
+ vm_op_t *pat = bp_pattern(def_file, def_file->contents);
check(pat, "Failed to compile pattern: %s", flag);
add_def(g, def_file, src, def, pat);
} else if (FLAG("--define-string") || FLAG("-D")) {
@@ -201,19 +201,19 @@ int main(int argc, char *argv[])
*eq = '\0';
char *src = ++eq;
file_t *def_file = spoof_file(def, flag);
- vm_op_t *pat = bpeg_stringpattern(def_file, def_file->contents);
+ vm_op_t *pat = bp_stringpattern(def_file, def_file->contents);
check(pat, "Failed to compile pattern: %s", flag);
add_def(g, def_file, src, def, pat);
} else if (FLAG("--pattern") || FLAG("-p")) {
check(npatterns == 0, "Cannot define multiple patterns");
file_t *arg_file = spoof_file("<pattern argument>", flag);
- vm_op_t *p = bpeg_pattern(arg_file, arg_file->contents);
+ vm_op_t *p = bp_pattern(arg_file, arg_file->contents);
check(p, "Pattern failed to compile: %s", flag);
add_def(g, arg_file, flag, "pattern", p);
++npatterns;
} else if (FLAG("--pattern-string") || FLAG("-P")) {
file_t *arg_file = spoof_file("<pattern argument>", flag);
- vm_op_t *p = bpeg_stringpattern(arg_file, arg_file->contents);
+ vm_op_t *p = bp_stringpattern(arg_file, arg_file->contents);
check(p, "Pattern failed to compile: %s", flag);
add_def(g, arg_file, flag, "pattern", p);
++npatterns;
@@ -223,12 +223,12 @@ int main(int argc, char *argv[])
for (char *c = &argv[i][1]; *c; ++c) {
switch (*c) {
case 'h': goto flag_help; // -h
- case 'v': flags |= BPEG_VERBOSE; break; // -v
- case 'e': flags |= BPEG_EXPLAIN; break; // -e
- case 'j': flags |= BPEG_JSON; break; // -j
- case 'I': flags |= BPEG_INPLACE; break; // -I
- case 'i': flags |= BPEG_IGNORECASE; break; // -i
- case 'l': flags |= BPEG_LISTFILES; break; // -l
+ case 'v': flags |= BP_VERBOSE; break; // -v
+ case 'e': flags |= BP_EXPLAIN; break; // -e
+ case 'j': flags |= BP_JSON; break; // -j
+ case 'I': flags |= BP_INPLACE; break; // -I
+ case 'i': flags |= BP_IGNORECASE; break; // -i
+ case 'l': flags |= BP_LISTFILES; break; // -l
default:
printf("Unrecognized flag: -%c\n\n%s\n", *c, usage);
return 1;
@@ -237,7 +237,7 @@ int main(int argc, char *argv[])
} else if (argv[i][0] != '-') {
if (npatterns > 0) break;
file_t *arg_file = spoof_file("<pattern argument>", argv[i]);
- vm_op_t *p = bpeg_stringpattern(arg_file, arg_file->contents);
+ vm_op_t *p = bp_stringpattern(arg_file, arg_file->contents);
check(p, "Pattern failed to compile: %s", argv[i]);
add_def(g, arg_file, argv[i], "pattern", p);
++npatterns;
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
}
}
- if (((flags & BPEG_JSON) != 0) + ((flags & BPEG_EXPLAIN) != 0) + ((flags & BPEG_LISTFILES) != 0) > 1) {
+ if (((flags & BP_JSON) != 0) + ((flags & BP_EXPLAIN) != 0) + ((flags & BP_LISTFILES) != 0) > 1) {
printf("Please choose no more than one of the flags: -j/--json, -e/--explain, and -l/--list-files.\n"
"They are mutually contradictory.\n");
return 1;
@@ -261,7 +261,7 @@ int main(int argc, char *argv[])
check(pattern != NULL, "No such rule: '%s'", rule);
int ret = 1;
- if (flags & BPEG_JSON) printf("[");
+ if (flags & BP_JSON) printf("[");
if (i < argc) {
// Files pass in as command line args:
for (int nfiles = 0; i < argc; nfiles++, i++) {
@@ -280,7 +280,7 @@ int main(int argc, char *argv[])
// Piped in input:
ret &= run_match(g, NULL, pattern, flags);
}
- if (flags & BPEG_JSON) printf("]\n");
+ if (flags & BP_JSON) printf("]\n");
return ret;
}
diff --git a/compiler.c b/compiler.c
index 2ad0e32..7ee5fbe 100644
--- a/compiler.c
+++ b/compiler.c
@@ -1,5 +1,5 @@
/*
- * compiler.c - Compile strings into BPEG virtual machine code.
+ * compiler.c - Compile strings into BP virtual machine code.
*/
#include <ctype.h>
@@ -46,7 +46,7 @@ static void set_range(vm_op_t *op, ssize_t min, ssize_t max, vm_op_t *pat, vm_op
*/
static vm_op_t *expand_chain(file_t *f, vm_op_t *first)
{
- vm_op_t *second = bpeg_simplepattern(f, first->end);
+ vm_op_t *second = bp_simplepattern(f, first->end);
if (second == NULL) return first;
second = expand_chain(f, second);
if (second->end <= first->end)
@@ -65,7 +65,7 @@ static vm_op_t *expand_choices(file_t *f, vm_op_t *first)
first = expand_chain(f, first);
const char *str = first->end;
if (!matchchar(&str, '/')) return first;
- vm_op_t *second = bpeg_simplepattern(f, str);
+ vm_op_t *second = bp_simplepattern(f, str);
if (!second)
file_err(f, str, str, "There should be a pattern here after a '/'");
second = expand_choices(f, second);
@@ -98,9 +98,9 @@ static vm_op_t *chain_together(vm_op_t *first, vm_op_t *second)
}
/*
- * Compile a string of BPEG code into virtual machine opcodes
+ * Compile a string of BP code into virtual machine opcodes
*/
-vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
+vm_op_t *bp_simplepattern(file_t *f, const char *str)
{
str = after_spaces(str);
if (!*str) return NULL;
@@ -119,14 +119,14 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
++str;
op->multiline = 1;
}
- vm_op_t *till = bpeg_simplepattern(f, str);
+ vm_op_t *till = bp_simplepattern(f, str);
op->op = VM_UPTO_AND;
op->len = -1;
op->args.multiple.first = till;
if (till)
str = till->end;
if (matchchar(&str, '%')) {
- vm_op_t *skip = bpeg_simplepattern(f, str);
+ vm_op_t *skip = bp_simplepattern(f, str);
if (!skip)
file_err(f, str, str, "There should be a pattern to skip here after the '%%'");
op->args.multiple.second = skip;
@@ -252,7 +252,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
}
// Not <pat>
case '!': {
- vm_op_t *p = bpeg_simplepattern(f, str);
+ vm_op_t *p = bp_simplepattern(f, str);
if (!p) file_err(f, str, str, "There should be a pattern after this '!'");
str = p->end;
op->op = VM_NOT;
@@ -277,14 +277,14 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
} else {
min = n1, max = n1;
}
- vm_op_t *pat = bpeg_simplepattern(f, str);
+ vm_op_t *pat = bp_simplepattern(f, str);
if (!pat)
file_err(f, str, str, "There should be a pattern after this repetition count.");
str = pat->end;
str = after_spaces(str);
vm_op_t *sep = NULL;
if (matchchar(&str, '%')) {
- sep = bpeg_simplepattern(f, str);
+ sep = bp_simplepattern(f, str);
if (!sep)
file_err(f, str, str, "There should be a separator pattern after this '%%'");
str = sep->end;
@@ -296,7 +296,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
}
// Lookbehind
case '<': {
- vm_op_t *pat = bpeg_simplepattern(f, str);
+ vm_op_t *pat = bp_simplepattern(f, str);
if (!pat)
file_err(f, str, str, "There should be a pattern after this '<'");
str = pat->end;
@@ -312,7 +312,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
}
// Lookahead
case '>': {
- vm_op_t *pat = bpeg_simplepattern(f, str);
+ vm_op_t *pat = bp_simplepattern(f, str);
if (!pat)
file_err(f, str, str, "There should be a pattern after this '>'");
str = pat->end;
@@ -325,7 +325,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
case '(': case '{': {
char closing = c == '(' ? ')' : '}';
free(op);
- op = bpeg_simplepattern(f, str);
+ op = bp_simplepattern(f, str);
if (!op)
file_err(f, str, str, "There should be a valid pattern after this parenthesis.");
op = expand_choices(f, op);
@@ -339,7 +339,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
}
// Square brackets
case '[': {
- vm_op_t *pat = bpeg_simplepattern(f, str);
+ vm_op_t *pat = bp_simplepattern(f, str);
if (!pat)
file_err(f, str, str, "There should be a valid pattern after this square bracket.");
pat = expand_choices(f, pat);
@@ -353,14 +353,14 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
// Repeating
case '*': case '+': {
ssize_t min = c == '*' ? 0 : 1;
- vm_op_t *pat = bpeg_simplepattern(f, str);
+ vm_op_t *pat = bp_simplepattern(f, str);
if (!pat)
file_err(f, str, str, "There should be a valid pattern here after the '%c'", c);
str = pat->end;
str = after_spaces(str);
vm_op_t *sep = NULL;
if (matchchar(&str, '%')) {
- sep = bpeg_simplepattern(f, str);
+ sep = bp_simplepattern(f, str);
if (!sep)
file_err(f, str, str, "There should be a separator pattern after the '%%' here.");
str = sep->end;
@@ -376,7 +376,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
op->args.capture.name = strndup(str, (size_t)(a-str));
str = after_spaces(a) + 1;
}
- vm_op_t *pat = bpeg_simplepattern(f, str);
+ vm_op_t *pat = bp_simplepattern(f, str);
if (!pat)
file_err(f, str, str, "There should be a valid pattern here to capture after the '@'");
str = pat->end;
@@ -386,7 +386,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
}
// Hide
case '~': {
- vm_op_t *pat = bpeg_simplepattern(f, str);
+ vm_op_t *pat = bp_simplepattern(f, str);
if (!pat)
file_err(f, str, str, "There should be a pattern after this '~'");
str = pat->end;
@@ -473,7 +473,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
} else if (str+2 < f->end && (matchstr(&str, "!=") || matchstr(&str, "=="))) { // Equality <pat1>==<pat2> and inequality <pat1>!=<pat2>
int equal = str[-2] == '=';
vm_op_t *first = op;
- vm_op_t *second = bpeg_simplepattern(f, str);
+ vm_op_t *second = bp_simplepattern(f, str);
if (!second)
file_err(f, str, str, "The '%c=' operator expects a pattern before and after.", equal?'=':'!');
if (equal) {
@@ -497,9 +497,9 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
}
/*
- * Similar to bpeg_simplepattern, except that the pattern begins with an implicit, unclosable quote.
+ * Similar to bp_simplepattern, except that the pattern begins with an implicit, unclosable quote.
*/
-vm_op_t *bpeg_stringpattern(file_t *f, const char *str)
+vm_op_t *bp_stringpattern(file_t *f, const char *str)
{
vm_op_t *ret = NULL;
while (*str) {
@@ -530,7 +530,7 @@ vm_op_t *bpeg_stringpattern(file_t *f, const char *str)
++str;
continue;
}
- interp = bpeg_simplepattern(f, str + 1);
+ interp = bp_simplepattern(f, str + 1);
if (interp == NULL)
file_err(f, str, str+1, "This isn't a valid escape sequence or pattern.");
break;
@@ -565,7 +565,7 @@ vm_op_t *bpeg_stringpattern(file_t *f, const char *str)
* Given a pattern and a replacement string, compile the two into a replacement
* VM opcode.
*/
-vm_op_t *bpeg_replacement(file_t *f, vm_op_t *pat, const char *replacement)
+vm_op_t *bp_replacement(file_t *f, vm_op_t *pat, const char *replacement)
{
vm_op_t *op = new(vm_op_t);
op->op = VM_REPLACE;
@@ -588,9 +588,9 @@ vm_op_t *bpeg_replacement(file_t *f, vm_op_t *pat, const char *replacement)
return op;
}
-vm_op_t *bpeg_pattern(file_t *f, const char *str)
+vm_op_t *bp_pattern(file_t *f, const char *str)
{
- vm_op_t *op = bpeg_simplepattern(f, str);
+ vm_op_t *op = bp_simplepattern(f, str);
if (op != NULL) op = expand_choices(f, op);
return op;
}
diff --git a/compiler.h b/compiler.h
index f7e8b43..bae222f 100644
--- a/compiler.h
+++ b/compiler.h
@@ -1,5 +1,5 @@
/*
- * compiler.h - Header file for BPEG compiler.
+ * compiler.h - Header file for BP compiler.
*/
#ifndef COMPILER__H
#define COMPILER__H
@@ -8,13 +8,13 @@
#include "types.h"
__attribute__((nonnull(1,2)))
-vm_op_t *bpeg_simplepattern(file_t *f, const char *str);
+vm_op_t *bp_simplepattern(file_t *f, const char *str);
__attribute__((nonnull(1,2)))
-vm_op_t *bpeg_stringpattern(file_t *f, const char *str);
+vm_op_t *bp_stringpattern(file_t *f, const char *str);
__attribute__((nonnull(1,2)))
-vm_op_t *bpeg_replacement(file_t *f, vm_op_t *pat, const char *replacement);
+vm_op_t *bp_replacement(file_t *f, vm_op_t *pat, const char *replacement);
__attribute__((nonnull(1,2)))
-vm_op_t *bpeg_pattern(file_t *f, const char *str);
+vm_op_t *bp_pattern(file_t *f, const char *str);
#endif
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/grammar.c b/grammar.c
index 08fe37b..229fb0e 100644
--- a/grammar.c
+++ b/grammar.c
@@ -46,7 +46,7 @@ vm_op_t *load_grammar(grammar_t *g, file_t *f)
name = strndup(name, (size_t)(name_end-name));
src = after_spaces(name_end);
check(matchchar(&src, ':'), "Expected ':' in definition");
- vm_op_t *op = bpeg_pattern(f, src);
+ vm_op_t *op = bp_pattern(f, src);
if (op == NULL) break;
//check(op, "Couldn't load definition");
add_def(g, f, src, name, op);
@@ -59,7 +59,7 @@ vm_op_t *load_grammar(grammar_t *g, file_t *f)
src = after_spaces(src);
}
if (src < f->end) {
- fprint_line(stderr, f, src, NULL, "Invalid BPEG pattern");
+ fprint_line(stderr, f, src, NULL, "Invalid BP pattern");
_exit(1);
}
return ret;
diff --git a/grammars/bpeg.bp b/grammars/bpeg.bp
index c7960dd..007c209 100644
--- a/grammars/bpeg.bp
+++ b/grammars/bpeg.bp
@@ -1,4 +1,4 @@
-# This is a file defining the BPEG grammar using BPEG syntax
+# This is a file defining the BP grammar using BP syntax
Grammar: __ *(Def [__`;])%__ __ ($$ / @!=(... => "Could not parse this code"))
Def: @name=id _ `: __ (
@@ -78,5 +78,5 @@ id: "^^" / "^" / "__" / "_" / "$$" / "$" / "|" / `a-z,A-Z *`a-z,A-Z,0-9,-
line-comment: `# .. $
block-comment: "#("..")#" % block-comment
-# Note: comments are undefined by default in regular BPEG
+# Note: comments are undefined by default in regular BP
comment: block-comment / line-comment
diff --git a/types.h b/types.h
index 0cbcc93..24b66a9 100644
--- a/types.h
+++ b/types.h
@@ -1,5 +1,5 @@
/*
- * types.h - Datatypes used by BPEG
+ * types.h - Datatypes used by BP
*/
#ifndef TYPES__H
#define TYPES__H
@@ -8,17 +8,17 @@
#include "file_loader.h"
-enum BPEGFlag {
- BPEG_VERBOSE = 1 << 0,
- BPEG_IGNORECASE = 1 << 1,
- BPEG_EXPLAIN = 1 << 2,
- BPEG_JSON = 1 << 3,
- BPEG_LISTFILES = 1 << 4,
- BPEG_INPLACE = 1 << 5,
+enum BPFlag {
+ BP_VERBOSE = 1 << 0,
+ BP_IGNORECASE = 1 << 1,
+ BP_EXPLAIN = 1 << 2,
+ BP_JSON = 1 << 3,
+ BP_LISTFILES = 1 << 4,
+ BP_INPLACE = 1 << 5,
};
/*
- * BPEG virtual machine opcodes (these must be kept in sync with the names in vm.c)
+ * BP virtual machine opcodes (these must be kept in sync with the names in vm.c)
*/
enum VMOpcode {
VM_ANYCHAR = 1,
@@ -42,7 +42,7 @@ enum VMOpcode {
};
/*
- * A struct reperesenting a BPEG virtual machine operation
+ * A struct reperesenting a BP virtual machine operation
*/
typedef struct vm_op_s {
enum VMOpcode op;
diff --git a/utils.c b/utils.c
index c2473d2..2572b33 100644
--- a/utils.c
+++ b/utils.c
@@ -43,7 +43,7 @@ const char *after_spaces(const char *str)
}
/*
- * Return the first character after a valid BPEG name, or NULL if none is
+ * Return the first character after a valid BP name, or NULL if none is
* found.
*/
const char *after_name(const char *str)
diff --git a/vm.c b/vm.c
index 40c783b..9412b0c 100644
--- a/vm.c
+++ b/vm.c
@@ -1,5 +1,5 @@
/*
- * vm.c - Code for the BPEG virtual machine that performs the matching.
+ * vm.c - Code for the BP virtual machine that performs the matching.
*/
#include <ctype.h>
@@ -116,7 +116,7 @@ static match_t *_match(grammar_t *g, file_t *f, const char *str, vm_op_t *op, un
}
case VM_STRING: {
if (&str[op->len] > f->end) return NULL;
- if ((flags & BPEG_IGNORECASE) ? memicmp(str, op->args.s, (size_t)op->len) != 0
+ if ((flags & BP_IGNORECASE) ? memicmp(str, op->args.s, (size_t)op->len) != 0
: memcmp(str, op->args.s, (size_t)op->len) != 0)
return NULL;
match_t *m = new(match_t);
@@ -215,7 +215,7 @@ static match_t *_match(grammar_t *g, file_t *f, const char *str, vm_op_t *op, un
}
if (p->end == start && reps > 0) {
// Since no forward progress was made on either `pat` or
- // `sep` and BPEG does not have mutable state, it's
+ // `sep` and BP does not have mutable state, it's
// guaranteed that no progress will be made on the next
// loop either. We know that this will continue to loop
// until reps==max, so let's just cut to the chase instead
@@ -662,7 +662,7 @@ static match_t *match_backref(const char *str, vm_op_t *op, match_t *cap, unsign
for (match_t *child = cap->child; child; child = child->nextsibling) {
if (child->start > prev) {
size_t len = (size_t)(child->start - prev);
- if ((flags & BPEG_IGNORECASE) ? memicmp(str, prev, len) != 0
+ if ((flags & BP_IGNORECASE) ? memicmp(str, prev, len) != 0
: memcmp(str, prev, len) != 0) {
destroy_match(&ret);
return NULL;
@@ -682,7 +682,7 @@ static match_t *match_backref(const char *str, vm_op_t *op, match_t *cap, unsign
}
if (cap->end > prev) {
size_t len = (size_t)(cap->end - prev);
- if ((flags & BPEG_IGNORECASE) ? memicmp(str, prev, len) != 0
+ if ((flags & BP_IGNORECASE) ? memicmp(str, prev, len) != 0
: memcmp(str, prev, len) != 0) {
destroy_match(&ret);
return NULL;
diff --git a/vm.h b/vm.h
index 842b782..758b9d5 100644
--- a/vm.h
+++ b/vm.h
@@ -1,5 +1,5 @@
/*
- * vm.h - Header file for BPEG virtual machine.
+ * vm.h - Header file for BP virtual machine.
*/
#ifndef VM__H
#define VM__H