1
0
mirror of https://github.com/janet-lang/janet synced 2025-05-06 17:34:16 +00:00

Add support for buffer peg literals - address #1549

This commit is contained in:
Calvin Rose 2025-01-26 09:48:48 -06:00
parent 1f34ec9902
commit fa75a395cb
2 changed files with 11 additions and 0 deletions

View File

@ -1419,6 +1419,11 @@ static uint32_t peg_compile1(Builder *b, Janet peg) {
emit_bytes(b, RULE_LITERAL, len, str);
break;
}
case JANET_BUFFER: {
const JanetBuffer *buf = janet_unwrap_buffer(peg);
emit_bytes(b, RULE_LITERAL, buf->count, buf->data);
break;
}
case JANET_TABLE: {
/* Build grammar table */
JanetTable *new_grammar = janet_table_clone(janet_unwrap_table(peg));

View File

@ -783,5 +783,11 @@
"abc123,,,,"
@["" "" "" "" ""])
# Issue #1549 - allow buffers as peg literals
(test "issue 1549"
''@"abc123"
"abc123"
@["abc123"])
(end-suite)