aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-15 18:57:09 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-15 18:57:09 -0800
commit09e1d1a36556c5b80f58159f2441905b77418194 (patch)
tree3e69e6c59ccf21e4106ff620042f0492382c4cab
parent7c77f5d6f45a0e888b16995a9c396a8161a688bb (diff)
Removing opcode references
-rw-r--r--bp.c4
-rw-r--r--compiler.c20
-rw-r--r--compiler.h2
-rw-r--r--types.h8
4 files changed, 16 insertions, 18 deletions
diff --git a/bp.c b/bp.c
index c506b2a..124c18e 100644
--- a/bp.c
+++ b/bp.c
@@ -365,11 +365,11 @@ int main(int argc, char *argv[])
def_t *defs = NULL;
file_t *loaded_files = NULL;
- // Define an opcode that is just a reference to the rule `pattern`
+ // Define a pattern that is just a reference to the rule `pattern`
file_t *pat_file = spoof_file(&loaded_files, "<pattern>", "pattern");
pat_t *pattern = bp_pattern(loaded_files, pat_file->contents);
- // Define an opcode that is just a reference to the rule `replacement`
+ // Define a pattern that is just a reference to the rule `replacement`
file_t *rep_file = spoof_file(&loaded_files, "<replacement>", "replacement");
pat_t *replacement = bp_pattern(rep_file, rep_file->contents);
diff --git a/compiler.c b/compiler.c
index 6e22746..21705d6 100644
--- a/compiler.c
+++ b/compiler.c
@@ -24,10 +24,10 @@ __attribute__((nonnull(1,2,3,6)))
static pat_t *new_range(file_t *f, const char *start, const char *end, ssize_t min, ssize_t max, pat_t *pat, pat_t *sep);
//
-// Allocate a new opcode for this file (ensuring it will be automatically freed
-// when the file is freed)
+// Allocate a new pattern for this file (ensuring it will be automatically
+// freed when the file is freed)
//
-pat_t *new_pat(file_t *f, const char *start, enum VMOpcode type)
+pat_t *new_pat(file_t *f, const char *start, enum pattype_e type)
{
allocated_op_t *tracker = new(allocated_op_t);
tracker->next = f->ops;
@@ -63,7 +63,7 @@ static pat_t *new_range(file_t *f, const char *start, const char *end, ssize_t m
}
//
-// Take an opcode and expand it into a chain of patterns if it's followed by
+// Take a pattern and expand it into a chain of patterns if it's followed by
// any patterns (e.g. "`x `y"), otherwise return the original input.
//
static pat_t *expand_chain(file_t *f, pat_t *first)
@@ -78,7 +78,7 @@ static pat_t *expand_chain(file_t *f, pat_t *first)
}
//
-// Take an opcode and parse any "=>" replacements and then expand it into a
+// Take a pattern and parse any "=>" replacements and then expand it into a
// chain of choices if it's followed by any "/"-separated patterns (e.g.
// "`x/`y"), otherwise return the original input.
//
@@ -133,7 +133,7 @@ static pat_t *expand_choices(file_t *f, pat_t *first)
}
//
-// Given two patterns, return a new opcode for the first pattern followed by
+// Given two patterns, return a new pattern for the first pattern followed by
// the second. If either pattern is NULL, return the other.
//
static pat_t *chain_together(file_t *f, pat_t *first, pat_t *second)
@@ -188,7 +188,7 @@ pat_t *bp_simplepattern(file_t *f, const char *str)
}
//
-// Compile a string of BP code into virtual machine opcodes
+// Compile a string of BP code into a BP pattern object.
//
static pat_t *_bp_simplepattern(file_t *f, const char *str)
{
@@ -557,8 +557,8 @@ pat_t *bp_stringpattern(file_t *f, const char *str)
}
//
-// Given a pattern and a replacement string, compile the two into a replacement
-// VM opcode.
+// Given a pattern and a replacement string, compile the two into a BP
+// replace pattern.
//
pat_t *bp_replacement(file_t *f, pat_t *pat, const char *replacement)
{
@@ -583,7 +583,7 @@ pat_t *bp_replacement(file_t *f, pat_t *pat, const char *replacement)
}
//
-// Compile a string representing a BP pattern into an opcode object.
+// Compile a string representing a BP pattern into a pattern object.
//
pat_t *bp_pattern(file_t *f, const char *str)
{
diff --git a/compiler.h b/compiler.h
index 46411fe..fae02cc 100644
--- a/compiler.h
+++ b/compiler.h
@@ -8,7 +8,7 @@
#include "types.h"
__attribute__((nonnull))
-pat_t *new_pat(file_t *f, const char *start, enum VMOpcode type);
+pat_t *new_pat(file_t *f, const char *start, enum pattype_e type);
__attribute__((nonnull(1,2)))
pat_t *bp_simplepattern(file_t *f, const char *str);
__attribute__((nonnull(1,2)))
diff --git a/types.h b/types.h
index 227bbb3..071c688 100644
--- a/types.h
+++ b/types.h
@@ -8,10 +8,8 @@
#include "file_loader.h"
-//
-// BP virtual machine opcodes (these must be kept in sync with the names in vm.c)
-//
-enum VMOpcode {
+// BP virtual machine pattern types
+enum pattype_e {
VM_ANYCHAR = 1,
VM_STRING,
VM_RANGE,
@@ -38,7 +36,7 @@ struct match_s; // forward declared to resolve circular struct defs
// A struct reperesenting a BP virtual machine operation
//
typedef struct pat_s {
- enum VMOpcode type;
+ enum pattype_e type;
const char *start, *end;
// Length of the match, if constant, otherwise -1
ssize_t len;