aboutsummaryrefslogtreecommitdiff
path: root/compiler.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-09-17 20:10:09 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-09-17 20:10:09 -0700
commit53ef6fd628201aa32b16934efb23ee8039dbce2e (patch)
treee9be024d18e7d6b424f8b75141362177d9b0e052 /compiler.c
parent4cfcdae3a1d6ec4963af436318907483e87c0a5b (diff)
Some fixes, including to "\\" and ".."/"..."
Diffstat (limited to 'compiler.c')
-rw-r--r--compiler.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler.c b/compiler.c
index c3c6fba..3b0489c 100644
--- a/compiler.c
+++ b/compiler.c
@@ -96,9 +96,12 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
switch (c) {
// Any char (dot) ($. is multiline anychar)
case '.': {
- if (matchchar(&str, '.')) { // ".."
- if (matchchar(&str, '.')) // "..."
+ if (*str == '.') { // ".."
+ ++str;
+ if (*str == '.') { // "..."
+ ++str;
op->multiline = 1;
+ }
vm_op_t *till = bpeg_simplepattern(f, str);
op->op = VM_UPTO_AND;
op->len = -1;
@@ -135,7 +138,7 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
}
// Escapes
case '\\': {
- check(*str, "Expected escape after '\\'");
+ check(*str && *str != '\n', "Expected escape after '\\'");
op->len = 1;
char e = unescapechar(str, &str);
if (*str == '-') { // Escape range (e.g. \x00-\xFF)
@@ -392,6 +395,10 @@ vm_op_t *bpeg_stringpattern(file_t *f, const char *str)
for (; *str; str++) {
if (*str == '\\') {
check(str[1], "Expected more string contents after backslash");
+ if (str[1] == '\\') {
+ ++str;
+ continue;
+ }
interp = bpeg_simplepattern(f, str + 1);
check(interp != NULL, "No valid BPEG pattern detected after backslash");
break;