aboutsummaryrefslogtreecommitdiff
path: root/compiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'compiler.c')
-rw-r--r--compiler.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/compiler.c b/compiler.c
index 4e2b185..df34e44 100644
--- a/compiler.c
+++ b/compiler.c
@@ -97,10 +97,21 @@ vm_op_t *bpeg_simplepattern(const char *str)
switch (c) {
// Any char (dot) ($. is multiline anychar)
case '.': {
- anychar:
- op->op = VM_ANYCHAR;
- op->len = 1;
- break;
+ if (matchchar(&str, '.')) { // ".."
+ if (matchchar(&str, '.')) // "..."
+ op->multiline = 1;
+ vm_op_t *till = bpeg_simplepattern(str);
+ str = str; // Don't advance str, the following pattern will be re-matched.
+ op->op = VM_UPTO;
+ op->len = -1;
+ op->args.pat = till;
+ break;
+ } else {
+ anychar:
+ op->op = VM_ANYCHAR;
+ op->len = 1;
+ break;
+ }
}
// Char literals
case '`': {
@@ -184,17 +195,6 @@ vm_op_t *bpeg_simplepattern(const char *str)
op->args.pat = p;
break;
}
- // Upto and including <pat>
- case '&': {
- if (matchchar(&str, '&')) op->multiline = 1;
- vm_op_t *p = bpeg_simplepattern(str);
- check(p, "Expected pattern after '&'\n");
- str = p->end;
- op->op = VM_UPTO_AND;
- op->len = -1;
- op->args.pat = p;
- break;
- }
// 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': {