diff --git a/pdf.c b/pdf.c index 2504e7863a4e7bf2c232b98cd7d93988bd581dac..2ceff3cd0cdf967f7967b41717655d5065c8a0f7 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));