From 8cc8af76659462284327d2951d1e6909c333024c Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Sat, 8 Feb 2020 18:50:21 +0100 Subject: [PATCH] don't turn booleans into NULL via h_ignore() --- pdf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pdf.c b/pdf.c index 2504e78..2ceff3c 100644 --- a/pdf.c +++ b/pdf.c @@ -12,7 +12,7 @@ #define CHX(...) h_choice(__VA_ARGS__, NULL) #define REP(P,N) h_repeat_n(P, N) #define IGN(P) h_ignore(P) -#define LIT(S) h_ignore(h_literal(S)) +#define LIT(S) h_literal(S) #define IN(STR) h_in((const uint8_t *)(STR), sizeof(STR) - 1) #define NOT_IN(STR) h_not_in((const uint8_t *)(STR), sizeof(STR) - 1) @@ -171,7 +171,6 @@ pp_parseresult(FILE *stream, const HParsedToken *tok, int indent, int delta) h_pprint(stream, res->ast, indent, delta); } -// XXX booleans get printed as (null), since LIT() parses them with h_ignore() void pp_dict(FILE *stream, const HParsedToken *tok, int indent, int delta) { @@ -514,7 +513,7 @@ init_parser(struct Env *aux) H_RULE(lws, IGN(h_many(lwchar))); #define TOK(X) h_middle(ws, X, h_not(rchar)) -#define KW(S) TOK(LIT(S)) +#define KW(S) IGN(TOK(LIT(S))) #define TOKD(X) h_right(ws, X) /* for tokens that end on delimiters */ // XXX this allows, for instance, "<<<<" to be parsed as "<< <<". ok? @@ -534,7 +533,7 @@ init_parser(struct Env *aux) H_ARULE(ref, SEQ(pnat, nat, KW("R"))); H_RULE(null, KW("null")); - H_RULE(boole, CHX(KW("true"), KW("false"))); + H_RULE(boole, CHX(TOK(LIT("true")), TOK(LIT("false")))); /* numbers */ H_RULE(digits, h_many1(digit)); -- GitLab