bp/compiler.c

608 lines
22 KiB
C
Raw Normal View History

//
// compiler.c - Compile strings into BP virtual machine code.
//
2020-09-11 01:28:06 -07:00
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
2020-09-11 01:28:06 -07:00
#include "compiler.h"
#include "utils.h"
2020-09-28 21:30:43 -07:00
#define file_err(f, ...) do { fprint_line(stderr, f, __VA_ARGS__); _exit(1); } while(0)
__attribute__((nonnull))
static vm_op_t *expand_chain(file_t *f, vm_op_t *first);
__attribute__((nonnull))
static vm_op_t *expand_choices(file_t *f, vm_op_t *first);
__attribute__((nonnull))
static vm_op_t *_bp_simplepattern(file_t *f, const char *str);
__attribute__((nonnull(1)))
static vm_op_t *chain_together(file_t *f,vm_op_t *first, vm_op_t *second);
__attribute__((nonnull(1,2,3,6)))
static vm_op_t *new_range(file_t *f, const char *start, const char *end, ssize_t min, ssize_t max, vm_op_t *pat, vm_op_t *sep);
//
// Allocate a new opcode for this file (ensuring it will be automatically freed
// when the file is freed)
//
vm_op_t *new_op(file_t *f, const char *start, enum VMOpcode type)
{
allocated_op_t *tracker = new(allocated_op_t);
tracker->next = f->ops;
f->ops = tracker;
tracker->op.type = type;
tracker->op.start = start;
tracker->op.len = -1;
return &tracker->op;
}
2020-09-11 01:28:06 -07:00
//
// Helper function to initialize a range object.
//
static vm_op_t *new_range(file_t *f, const char *start, const char *end, ssize_t min, ssize_t max, vm_op_t *pat, vm_op_t *sep)
2020-09-11 01:28:06 -07:00
{
vm_op_t *op = new_op(f, start, VM_REPEAT);
2020-09-11 01:28:06 -07:00
if (pat->len >= 0 && (sep == NULL || sep->len >= 0) && min == max && min >= 0)
op->len = pat->len * min + (sep == NULL || min == 0 ? 0 : sep->len * (min-1));
else
op->len = -1;
op->args.repetitions.min = min;
op->args.repetitions.max = max;
op->args.repetitions.repeat_pat = pat;
op->args.repetitions.sep = sep;
2020-09-28 17:42:38 -07:00
if (!op->start) op->start = pat->start;
if (!op->end) op->end = pat->end;
if (sep) {
if (sep->start < op->start) op->start = sep->start;
if (sep->end > op->end) op->end = sep->end;
}
op->end = end;
return op;
2020-09-11 01:28:06 -07:00
}
//
// Take an opcode and expand it into a chain of patterns if it's followed by
// any patterns (e.g. "`x `y"), otherwise return the original input.
//
2020-09-16 19:35:43 -07:00
static vm_op_t *expand_chain(file_t *f, vm_op_t *first)
2020-09-11 01:28:06 -07:00
{
2020-12-30 19:42:47 -08:00
vm_op_t *second = bp_simplepattern(f, first->end);
2020-09-11 01:28:06 -07:00
if (second == NULL) return first;
2020-09-16 19:35:43 -07:00
second = expand_chain(f, second);
2020-09-28 21:30:43 -07:00
if (second->end <= first->end)
file_err(f, second->end, second->end,
"This chain is not parsing properly");
return chain_together(f, first, second);
2020-09-11 01:28:06 -07:00
}
//
// Take an opcode 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.
//
2020-09-16 19:35:43 -07:00
static vm_op_t *expand_choices(file_t *f, vm_op_t *first)
2020-09-11 01:28:06 -07:00
{
2020-09-16 19:35:43 -07:00
first = expand_chain(f, first);
2020-09-11 01:28:06 -07:00
const char *str = first->end;
2021-01-05 19:31:50 -08:00
while (str+2 < f->end && matchstr(&str, "=>")) { // Replacement <pat> => <pat>
str = after_spaces(str);
char quote = *str;
if (!(matchchar(&str, '"') || matchchar(&str, '\'')))
file_err(f, str, str, "There should be a string literal as a replacement here.");
const char *repstr = str;
for (; *str && *str != quote; str++) {
if (*str == '\\') {
if (!str[1] || str[1] == '\n')
file_err(f, str, str+1,
"There should be an escape sequence after this backslash.");
++str;
}
}
if (!matchchar(&str, quote))
file_err(f, &repstr[-1], str, "This string doesn't have a closing quote.");
size_t replace_len = (size_t)(str-repstr-1);
const char *replacement = xcalloc(sizeof(char), replace_len+1);
memcpy((void*)replacement, repstr, replace_len);
vm_op_t *pat = first;
first = new_op(f, pat->start, VM_REPLACE);
2021-01-05 19:31:50 -08:00
first->args.replace.pat = pat;
first->args.replace.text = replacement;
first->args.replace.len = replace_len;
first->len = pat->len;
first->end = str;
}
2020-09-11 01:28:06 -07:00
if (!matchchar(&str, '/')) return first;
2020-12-30 19:42:47 -08:00
vm_op_t *second = bp_simplepattern(f, str);
2020-09-28 21:30:43 -07:00
if (!second)
file_err(f, str, str, "There should be a pattern here after a '/'");
2020-09-16 19:35:43 -07:00
second = expand_choices(f, second);
vm_op_t *choice = new_op(f, first->start, VM_OTHERWISE);
2020-09-11 01:28:06 -07:00
if (first->len == second->len)
choice->len = first->len;
else choice->len = -1;
choice->end = second->end;
choice->args.multiple.first = first;
choice->args.multiple.second = second;
return choice;
}
//
// Given two patterns, return a new opcode for the first pattern followed by
// the second. If either pattern is NULL, return the other.
//
static vm_op_t *chain_together(file_t *f, vm_op_t *first, vm_op_t *second)
2020-09-11 01:28:06 -07:00
{
if (first == NULL) return second;
if (second == NULL) return first;
2021-01-13 18:56:22 -08:00
check(first->type != VM_CHAIN, "A chain should not be the first item in a chain.");
vm_op_t *chain = new_op(f, first->start, VM_CHAIN);
2020-09-11 01:28:06 -07:00
chain->start = first->start;
if (first->len >= 0 && second->len >= 0)
chain->len = first->len + second->len;
else chain->len = -1;
chain->end = second->end;
chain->args.multiple.first = first;
chain->args.multiple.second = second;
return chain;
}
//
// Wrapper for _bp_simplepattern() that expands any postfix operators
//
2020-12-30 19:42:47 -08:00
vm_op_t *bp_simplepattern(file_t *f, const char *str)
{
vm_op_t *op = _bp_simplepattern(f, str);
if (op == NULL) return op;
2021-01-13 18:56:22 -08:00
check(op->end != NULL, "op->end is uninitialized!");
// Expand postfix operators (if any)
str = after_spaces(op->end);
while (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 = bp_simplepattern(f, str);
if (!second)
file_err(f, str, str, "The '%c=' operator expects a pattern before and after.", equal?'=':'!');
if (equal) {
if (!(first->len == -1 || second->len == -1 || first->len == second->len))
file_err(f, op->start, second->end,
"These two patterns cannot possibly give the same result (different lengths: %ld != %ld)",
first->len, second->len);
}
op = new_op(f, str, equal ? VM_EQUAL : VM_NOT_EQUAL);
op->end = second->end;
op->len = first->len != -1 ? first->len : second->len;
op->args.multiple.first = first;
op->args.multiple.second = second;
str = op->end;
str = after_spaces(str);
}
return op;
}
//
// Compile a string of BP code into virtual machine opcodes
//
static vm_op_t *_bp_simplepattern(file_t *f, const char *str)
2020-09-11 01:28:06 -07:00
{
str = after_spaces(str);
if (!*str) return NULL;
const char *start = str;
2020-09-11 01:28:06 -07:00
char c = *str;
++str;
switch (c) {
// Any char (dot)
2020-09-11 01:28:06 -07:00
case '.': {
if (*str == '.') { // ".."
vm_op_t *op = new_op(f, start, VM_UPTO_AND);
++str;
2020-12-30 19:42:47 -08:00
vm_op_t *till = bp_simplepattern(f, str);
2020-12-14 18:11:33 -08:00
op->args.multiple.first = till;
if (till)
str = till->end;
2020-12-14 18:11:33 -08:00
if (matchchar(&str, '%')) {
2020-12-30 19:42:47 -08:00
vm_op_t *skip = bp_simplepattern(f, str);
2020-12-14 18:11:33 -08:00
if (!skip)
file_err(f, str, str, "There should be a pattern to skip here after the '%%'");
op->args.multiple.second = skip;
str = skip->end;
}
op->end = str;
return op;
} else {
vm_op_t *op = new_op(f, start, VM_ANYCHAR);
op->len = 1;
op->end = str;
return op;
}
2020-09-11 01:28:06 -07:00
}
// Char literals
case '`': {
2020-12-19 18:53:51 -08:00
vm_op_t *all = NULL;
do {
char c = *str;
if (!c || c == '\n')
file_err(f, str, str, "There should be a character here after the '`'");
const char *opstart = str-1;
2020-12-19 18:53:51 -08:00
vm_op_t *op;
2020-09-11 01:28:06 -07:00
++str;
2020-12-19 18:53:51 -08:00
if (matchchar(&str, '-')) { // Range
char c2 = *str;
if (!c2 || c2 == '\n')
file_err(f, str, str, "There should be a character here to complete the character range.");
op = new_op(f, opstart, VM_RANGE);
2020-12-19 18:53:51 -08:00
if (c < c2) {
op->args.range.low = (unsigned char)c;
op->args.range.high = (unsigned char)c2;
} else {
op->args.range.low = (unsigned char)c2;
op->args.range.high = (unsigned char)c;
}
++str;
} else {
op = new_op(f, opstart, VM_STRING);
2020-12-19 18:53:51 -08:00
char *s = xcalloc(sizeof(char), 2);
s[0] = c;
op->args.s = s;
}
op->len = 1;
2020-12-19 18:53:51 -08:00
op->end = str;
if (all == NULL) {
all = op;
} else {
vm_op_t *either = new_op(f, all->start, VM_OTHERWISE);
2020-12-19 18:53:51 -08:00
either->end = op->end;
either->args.multiple.first = all;
either->args.multiple.second = op;
either->len = 1;
all = either;
}
op = NULL;
} while (matchchar(&str, ','));
return all;
2020-09-11 01:28:06 -07:00
}
// Escapes
case '\\': {
2020-09-28 21:30:43 -07:00
if (!*str || *str == '\n')
file_err(f, str, str, "There should be an escape sequence here after this backslash.");
if (matchchar(&str, 'N')) { // \N (nodent)
vm_op_t *op = new_op(f, start, VM_NODENT);
op->end = str;
return op;
}
vm_op_t *op;
const char *opstart = str;
2020-09-28 21:30:43 -07:00
unsigned char e = unescapechar(str, &str);
2020-09-11 01:28:06 -07:00
if (*str == '-') { // Escape range (e.g. \x00-\xFF)
++str;
2020-09-28 21:30:43 -07:00
const char *seqstart = str;
unsigned char e2 = unescapechar(str, &str);
if (str == seqstart)
file_err(f, seqstart, str+1, "This value isn't a valid escape sequence");
if (e2 < e)
file_err(f, start, str, "Escape ranges should be low-to-high, but this is high-to-low.");
op = new_op(f, opstart, VM_RANGE);
2020-09-11 01:28:06 -07:00
op->args.range.low = e;
op->args.range.high = e2;
} else {
op = new_op(f, opstart, VM_STRING);
char *s = xcalloc(sizeof(char), 2);
s[0] = (char)e;
op->args.s = s;
2020-09-11 01:28:06 -07:00
}
op->len = 1;
op->end = str;
return op;
2020-09-11 01:28:06 -07:00
}
// String literal
case '"': case '\'': case '\002': {
char endquote = c == '\002' ? '\003' : c;
char *litstart = (char*)str;
2020-09-11 01:28:06 -07:00
for (; *str && *str != endquote; str++) {
if (*str == '\\') {
2020-09-28 22:02:00 -07:00
if (!str[1] || str[1] == '\n')
file_err(f, str, str+1,
"There should be an escape sequence after this backslash.");
2020-09-11 01:28:06 -07:00
++str;
}
}
size_t len = (size_t)(str - litstart);
char *literal = xcalloc(sizeof(char), len+1);
memcpy(literal, litstart, len);
2021-01-12 18:41:31 -08:00
// Note: an unescaped string is guaranteed to be no longer than the
// escaped string, so this is safe to do inplace.
2020-09-11 01:28:06 -07:00
len = unescape_string(literal, literal, len);
vm_op_t *op = new_op(f, start, VM_STRING);
op->len = (ssize_t)len;
2020-09-11 01:28:06 -07:00
op->args.s = literal;
2020-09-28 22:02:00 -07:00
if (!matchchar(&str, endquote))
file_err(f, start, str, "This string doesn't have a closing quote.");
op->end = str;
return op;
2020-09-11 01:28:06 -07:00
}
// Not <pat>
case '!': {
2020-12-30 19:42:47 -08:00
vm_op_t *p = bp_simplepattern(f, str);
2020-09-28 22:02:00 -07:00
if (!p) file_err(f, str, str, "There should be a pattern after this '!'");
vm_op_t *op = new_op(f, start, VM_NOT);
2020-09-11 01:28:06 -07:00
op->len = 0;
op->args.pat = p;
op->end = p->end;
return op;
2020-09-11 01:28:06 -07:00
}
// Number of repetitions: <N>(-<N> / - / + / "")
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9': {
ssize_t min = -1, max = -1;
--str;
long n1 = strtol(str, (char**)&str, 10);
if (matchchar(&str, '-')) {
str = after_spaces(str);
const char *numstart = str;
2020-09-11 01:28:06 -07:00
long n2 = strtol(str, (char**)&str, 10);
if (str == numstart) min = 0, max = n1;
2020-09-11 01:28:06 -07:00
else min = n1, max = n2;
} else if (matchchar(&str, '+')) {
min = n1, max = -1;
} else {
min = n1, max = n1;
}
2020-12-30 19:42:47 -08:00
vm_op_t *pat = bp_simplepattern(f, str);
2020-09-28 22:02:00 -07:00
if (!pat)
file_err(f, str, str, "There should be a pattern after this repetition count.");
2020-09-11 01:28:06 -07:00
str = pat->end;
vm_op_t *sep = NULL;
2020-09-11 01:28:06 -07:00
if (matchchar(&str, '%')) {
2020-12-30 19:42:47 -08:00
sep = bp_simplepattern(f, str);
2020-09-28 22:02:00 -07:00
if (!sep)
file_err(f, str, str, "There should be a separator pattern after this '%%'");
2020-09-11 01:28:06 -07:00
str = sep->end;
} else {
2020-09-14 01:21:49 -07:00
str = pat->end;
2020-09-11 01:28:06 -07:00
}
return new_range(f, start, str, min, max, pat, sep);
2020-09-11 01:28:06 -07:00
}
// Lookbehind
case '<': {
2020-12-30 19:42:47 -08:00
vm_op_t *pat = bp_simplepattern(f, str);
2020-09-28 21:30:43 -07:00
if (!pat)
file_err(f, str, str, "There should be a pattern after this '<'");
2020-09-11 01:28:06 -07:00
str = pat->end;
2020-09-28 21:30:43 -07:00
if (pat->len == -1)
file_err(f, start, pat->end,
2020-09-28 21:30:43 -07:00
"Sorry, variable-length lookbehind patterns like this are not supported.\n"
"Please use a fixed-length lookbehind pattern instead.");
2020-09-11 01:28:06 -07:00
str = pat->end;
vm_op_t *op = new_op(f, start, VM_AFTER);
2020-09-11 01:28:06 -07:00
op->len = 0;
op->args.pat = pat;
op->end = str;
return op;
2020-09-11 01:28:06 -07:00
}
// Lookahead
case '>': {
2020-12-30 19:42:47 -08:00
vm_op_t *pat = bp_simplepattern(f, str);
2020-09-28 21:30:43 -07:00
if (!pat)
file_err(f, str, str, "There should be a pattern after this '>'");
2020-09-11 01:28:06 -07:00
str = pat->end;
vm_op_t *op = new_op(f, start, VM_BEFORE);
2020-09-11 01:28:06 -07:00
op->len = 0;
op->args.pat = pat;
op->end = str;
return op;
2020-09-11 01:28:06 -07:00
}
// Parentheses
case '(': case '{': {
char closing = c == '(' ? ')' : '}';
vm_op_t *op = bp_simplepattern(f, str);
2020-09-28 21:30:43 -07:00
if (!op)
2020-09-28 22:02:00 -07:00
file_err(f, str, str, "There should be a valid pattern after this parenthesis.");
2020-09-16 19:35:43 -07:00
op = expand_choices(f, op);
2020-09-11 01:28:06 -07:00
str = op->end;
if (!matchchar(&str, closing))
file_err(f, start, str, "This parenthesis group isn't properly closed.");
op->start = start;
op->end = str;
return op;
2020-09-11 01:28:06 -07:00
}
// Square brackets
case '[': {
2020-12-30 19:42:47 -08:00
vm_op_t *pat = bp_simplepattern(f, str);
2020-09-28 22:02:00 -07:00
if (!pat)
file_err(f, str, str, "There should be a valid pattern after this square bracket.");
pat = expand_choices(f, pat);
str = pat->end;
2020-09-28 22:02:00 -07:00
if (!matchchar(&str, ']'))
file_err(f, start, str, "This square bracket group isn't properly closed.");
return new_range(f, start, str, 0, 1, pat, NULL);
}
// Repeating
case '*': case '+': {
ssize_t min = c == '*' ? 0 : 1;
2020-12-30 19:42:47 -08:00
vm_op_t *pat = bp_simplepattern(f, str);
2020-09-28 22:02:00 -07:00
if (!pat)
file_err(f, str, str, "There should be a valid pattern here after the '%c'", c);
str = pat->end;
vm_op_t *sep = NULL;
if (matchchar(&str, '%')) {
2020-12-30 19:42:47 -08:00
sep = bp_simplepattern(f, str);
2020-09-28 21:30:43 -07:00
if (!sep)
2020-09-28 22:02:00 -07:00
file_err(f, str, str, "There should be a separator pattern after the '%%' here.");
str = sep->end;
}
return new_range(f, start, str, min, -1, pat, sep);
}
2020-09-11 01:28:06 -07:00
// Capture
case '@': {
vm_op_t *op = new_op(f, start, VM_CAPTURE);
const char *a = *str == '!' ? &str[1] : after_name(str);
if (a > str && after_spaces(a)[0] == '=' && after_spaces(a)[1] != '>') {
op->args.capture.name = strndup(str, (size_t)(a-str));
str = after_spaces(a) + 1;
2020-09-11 01:28:06 -07:00
}
2020-12-30 19:42:47 -08:00
vm_op_t *pat = bp_simplepattern(f, str);
2020-09-28 22:02:00 -07:00
if (!pat)
file_err(f, str, str, "There should be a valid pattern here to capture after the '@'");
2020-09-11 01:28:06 -07:00
op->args.capture.capture_pat = pat;
op->len = pat->len;
op->end = pat->end;
return op;
2020-09-11 01:28:06 -07:00
}
// Hide
case '~': {
2020-12-30 19:42:47 -08:00
vm_op_t *pat = bp_simplepattern(f, str);
if (!pat)
file_err(f, str, str, "There should be a pattern after this '~'");
vm_op_t *op = new_op(f, start, VM_HIDE);
op->len = 0;
op->args.pat = pat;
op->end = pat->end;
return op;
}
2020-09-11 01:28:06 -07:00
// Special rules:
case '_': case '^': case '$': case '|': {
const char *name = NULL;
2020-09-11 01:28:06 -07:00
if (matchchar(&str, c)) { // double __, ^^, $$
if (matchchar(&str, ':')) return NULL; // Don't match definitions
2020-09-11 01:28:06 -07:00
char tmp[3] = {c, c, '\0'};
name = strdup(tmp);
2020-09-11 01:28:06 -07:00
} else {
if (matchchar(&str, ':')) return NULL; // Don't match definitions
name = strndup(&c, 1);
}
vm_op_t *op = new_op(f, start, VM_REF);
op->args.s = name;
op->end = str;
return op;
2020-09-11 01:28:06 -07:00
}
default: {
// Reference
if (!isalpha(c)) return NULL;
--str;
const char *refname = str;
str = after_name(str);
if (matchchar(&str, ':')) // Don't match definitions
2020-09-11 01:28:06 -07:00
return NULL;
vm_op_t *op = new_op(f, start, VM_REF);
op->args.s = strndup(refname, (size_t)(str - refname));
op->end = str;
return op;
2020-09-28 17:56:02 -07:00
}
2020-09-13 20:33:11 -07:00
}
return NULL;
2020-09-11 01:28:06 -07:00
}
//
// Similar to bp_simplepattern, except that the pattern begins with an implicit, unclosable quote.
//
2020-12-30 19:42:47 -08:00
vm_op_t *bp_stringpattern(file_t *f, const char *str)
2020-09-11 01:28:06 -07:00
{
vm_op_t *ret = NULL;
while (*str) {
char *start = (char*)str;
2020-09-11 01:28:06 -07:00
vm_op_t *interp = NULL;
for (; *str; str++) {
if (*str == '\\') {
2020-09-28 22:02:00 -07:00
if (!str[1] || str[1] == '\n')
file_err(f, str, str, "There should be an escape sequence or pattern here after this backslash.");
if (matchchar(&str, 'N')) { // \N (nodent)
interp = new_op(f, str-2, VM_NODENT);
break;
}
const char *after_escape;
2020-09-28 21:30:43 -07:00
unsigned char e = unescapechar(&str[1], &after_escape);
if (e != str[1]) {
str = after_escape - 1;
continue;
}
if (str[1] == '\\') {
++str;
continue;
}
2020-12-30 19:42:47 -08:00
interp = bp_simplepattern(f, str + 1);
2020-09-28 22:02:00 -07:00
if (interp == NULL)
file_err(f, str, str+1, "This isn't a valid escape sequence or pattern.");
2020-09-11 01:28:06 -07:00
break;
}
}
// End of string
size_t len = (size_t)(str - start);
char *literal = xcalloc(sizeof(char), len+1);
memcpy(literal, start, len);
2021-01-12 18:41:31 -08:00
// Note: an unescaped string is guaranteed to be no longer than the
// escaped string, so this is safe to do inplace.
2020-09-11 01:28:06 -07:00
len = unescape_string(literal, literal, len);
2021-01-13 18:56:22 -08:00
if (len > 0) {
vm_op_t *strop = new_op(f, str, VM_STRING);
strop->len = (ssize_t)len;
strop->args.s = literal;
strop->end = str;
ret = chain_together(f, ret, strop);
2020-09-11 01:28:06 -07:00
}
if (interp) {
ret = chain_together(f, ret, interp);
2020-09-11 01:28:06 -07:00
str = interp->end;
// allow terminating seq
matchchar(&str, ';');
}
}
return ret;
}
//
// Given a pattern and a replacement string, compile the two into a replacement
// VM opcode.
//
2020-12-30 19:42:47 -08:00
vm_op_t *bp_replacement(file_t *f, vm_op_t *pat, const char *replacement)
2020-09-11 01:28:06 -07:00
{
vm_op_t *op = new_op(f, pat->start, VM_REPLACE);
2021-01-08 00:58:00 -08:00
op->end = pat->end;
2020-09-11 01:28:06 -07:00
op->len = pat->len;
op->args.replace.pat = pat;
2020-09-11 01:28:06 -07:00
const char *p = replacement;
for (; *p; p++) {
if (*p == '\\') {
2020-09-28 22:02:00 -07:00
if (!p[1] || p[1] == '\n')
file_err(f, p, p, "There should be an escape sequence or pattern here after this backslash.");
2020-09-11 01:28:06 -07:00
++p;
}
}
size_t rlen = (size_t)(p-replacement);
char *rcpy = xcalloc(sizeof(char), rlen + 1);
memcpy(rcpy, replacement, rlen);
op->args.replace.text = rcpy;
op->args.replace.len = rlen;
2020-09-11 01:28:06 -07:00
return op;
}
2021-01-12 21:28:44 -08:00
//
// Compile a string representing a BP pattern into an opcode object.
//
2020-12-30 19:42:47 -08:00
vm_op_t *bp_pattern(file_t *f, const char *str)
2020-09-11 01:28:06 -07:00
{
2020-12-30 19:42:47 -08:00
vm_op_t *op = bp_simplepattern(f, str);
2020-09-16 19:35:43 -07:00
if (op != NULL) op = expand_choices(f, op);
2020-09-11 01:28:06 -07:00
return op;
}
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1