Tolerate spaces around = in @foo = baz

This commit is contained in:
Bruce Hill 2020-09-28 17:10:13 -07:00
parent c15b118bb4
commit 54b14a3557
2 changed files with 3 additions and 3 deletions

View File

@ -267,9 +267,9 @@ vm_op_t *bpeg_simplepattern(file_t *f, const char *str)
case '@': {
op->op = VM_CAPTURE;
const char *a = *str == '!' ? &str[1] : after_name(str);
if (a > str && a[0] == '=' && a[1] != '>') {
if (a > str && after_spaces(a)[0] == '=' && after_spaces(a)[1] != '>') {
op->args.capture.name = strndup(str, (size_t)(a-str));
str = a + 1;
str = after_spaces(a) + 1;
}
vm_op_t *pat = bpeg_simplepattern(f, str);
check(pat, "Expected pattern after @");

View File

@ -49,7 +49,7 @@ Repeat: (
Optional: `[ __ extended-pat (__`] / @!={=> "Expected closing square bracket here"})
After: `< _ pat
Before: `> _ pat
Capture: `@ [_ @capture-name=(id/`!) !"=>" `=] _ (@capture=pat / @!={=> "Expected pattern to capture"})
Capture: `@ [_ @capture-name=(id/`!) __ !"=>" `=] __ (@capture=pat / @!={=> "Expected pattern to capture"})
Replace: `{ __ (
[@replace-pat=extended-pat __] "=>" [__ @replacement=String]
) __ (`} / @!={=> "Expected closing brace here"})