mirror of
https://github.com/janet-lang/janet
synced 2025-07-27 06:12:59 +00:00
Add support for buffer peg literals - address #1549
This commit is contained in:
parent
1f34ec9902
commit
fa75a395cb
@ -1419,6 +1419,11 @@ static uint32_t peg_compile1(Builder *b, Janet peg) {
|
|||||||
emit_bytes(b, RULE_LITERAL, len, str);
|
emit_bytes(b, RULE_LITERAL, len, str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case JANET_BUFFER: {
|
||||||
|
const JanetBuffer *buf = janet_unwrap_buffer(peg);
|
||||||
|
emit_bytes(b, RULE_LITERAL, buf->count, buf->data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case JANET_TABLE: {
|
case JANET_TABLE: {
|
||||||
/* Build grammar table */
|
/* Build grammar table */
|
||||||
JanetTable *new_grammar = janet_table_clone(janet_unwrap_table(peg));
|
JanetTable *new_grammar = janet_table_clone(janet_unwrap_table(peg));
|
||||||
|
@ -783,5 +783,11 @@
|
|||||||
"abc123,,,,"
|
"abc123,,,,"
|
||||||
@["" "" "" "" ""])
|
@["" "" "" "" ""])
|
||||||
|
|
||||||
|
# Issue #1549 - allow buffers as peg literals
|
||||||
|
(test "issue 1549"
|
||||||
|
''@"abc123"
|
||||||
|
"abc123"
|
||||||
|
@["abc123"])
|
||||||
|
|
||||||
(end-suite)
|
(end-suite)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user