diff --git a/src/core/peg.c b/src/core/peg.c index a814e65f..a087ddfa 100644 --- a/src/core/peg.c +++ b/src/core/peg.c @@ -735,6 +735,12 @@ static const uint8_t *peg_getrange(Builder *b, Janet x) { return str; } +static int32_t peg_getboolean(Builder *b, Janet x) { + if (!janet_checktype(x, JANET_BOOLEAN)) + peg_panicf(b, "expected boolean, got %v", x); + return janet_unwrap_boolean(x); +} + static int32_t peg_getinteger(Builder *b, Janet x) { if (!janet_checkint(x)) peg_panicf(b, "expected integer, got %v", x); @@ -1261,6 +1267,13 @@ static uint32_t peg_compile1(Builder *b, Janet peg) { default: peg_panic(b, "unexpected peg source"); return 0; + + case JANET_BOOLEAN: { + int n = peg_getboolean(b, peg); + Reserve r = reserve(b, 2); + emit_1(r, n ? RULE_NCHAR : RULE_NOTNCHAR, 0); + break; + } case JANET_NUMBER: { int32_t n = peg_getinteger(b, peg); Reserve r = reserve(b, 2);