1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 01:37:19 +00:00

fixup! peg: add support for "true" and "false" primitives to always/never match

This commit is contained in:
Chloe Kudryavtsev 2023-06-11 12:38:40 +02:00
parent f9ab91511d
commit e54ea7a1d8

View File

@ -736,9 +736,9 @@ static const uint8_t *peg_getrange(Builder *b, Janet x) {
} }
static int32_t peg_getboolean(Builder *b, Janet x) { static int32_t peg_getboolean(Builder *b, Janet x) {
if (!janet_checktype(x, JANET_BOOLEAN)) if (!janet_checktype(x, JANET_BOOLEAN))
peg_panicf(b, "expected boolean, got %v", x); peg_panicf(b, "expected boolean, got %v", x);
return janet_unwrap_boolean(x); return janet_unwrap_boolean(x);
} }
static int32_t peg_getinteger(Builder *b, Janet x) { static int32_t peg_getinteger(Builder *b, Janet x) {
@ -1268,12 +1268,12 @@ static uint32_t peg_compile1(Builder *b, Janet peg) {
peg_panic(b, "unexpected peg source"); peg_panic(b, "unexpected peg source");
return 0; return 0;
case JANET_BOOLEAN: { case JANET_BOOLEAN: {
int n = peg_getboolean(b, peg); int n = peg_getboolean(b, peg);
Reserve r = reserve(b, 2); Reserve r = reserve(b, 2);
emit_1(r, n ? RULE_NCHAR : RULE_NOTNCHAR, 0); emit_1(r, n ? RULE_NCHAR : RULE_NOTNCHAR, 0);
break; break;
} }
case JANET_NUMBER: { case JANET_NUMBER: {
int32_t n = peg_getinteger(b, peg); int32_t n = peg_getinteger(b, peg);
Reserve r = reserve(b, 2); Reserve r = reserve(b, 2);