1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-07 11:03:04 +00:00

Update peg docs and make bad backrefs not error the whole pattern, but just cause the current match attempt to fail.

This commit is contained in:
Calvin Rose
2019-01-14 21:46:36 -05:00
parent 90313afd40
commit 1304f9263b
3 changed files with 66 additions and 16 deletions

View File

@@ -269,8 +269,7 @@ tail:
case RULE_REPINDEX:
{
int32_t index = ((int32_t *)rule)[1];
if (index >= s->captures->count)
janet_panic("invalid capture index");
if (index >= s->captures->count) return NULL;
Janet capture = s->captures->data[index];
pushcap(s, capture, text, text);
return text;
@@ -278,8 +277,7 @@ tail:
case RULE_BACKINDEX:
{
int32_t index = ((int32_t *)rule)[1];
if (index >= s->captures->count)
janet_panic("invalid capture index");
if (index >= s->captures->count) return NULL;
Janet capture = s->captures->data[s->captures->count - 1 - index];
pushcap(s, capture, text, text);
return text;