From c2c46541357be81150e88477e5cfcb3ad0830951 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Sat, 8 Feb 2020 20:30:26 +0100 Subject: [PATCH] allow leading zeroes in 'pnat' --- pdf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pdf.c b/pdf.c index 208cd10..eb15af4 100644 --- a/pdf.c +++ b/pdf.c @@ -237,11 +237,12 @@ act_nat(const HParseResult *p, void *u) #define act_xroff act_nat #define act_xrgen act_nat +/* p = (zeroes, d, digits) -- where d>0 */ HParsedToken * act_pnat(const HParseResult *p, void *u) { - uint64_t x = H_FIELD_UINT(0); - HCountedArray *seq = H_FIELD_SEQ(1); + uint64_t x = H_FIELD_UINT(1); + HCountedArray *seq = H_FIELD_SEQ(2); // XXX check for overflow for (size_t i = 0; i < seq->used; i++) @@ -506,6 +507,7 @@ init_parser(struct Env *aux) H_RULE(rangle, h_ch('>')); H_RULE(lbrack, h_ch('[')); H_RULE(rbrack, h_ch(']')); + H_RULE(zero, h_ch('0')); /* whitespace */ H_RULE(comment, SEQ(percent, line)); @@ -524,7 +526,7 @@ init_parser(struct Env *aux) H_RULE(epsilon, h_epsilon_p()); H_RULE(empty, SEQ(epsilon)); H_ARULE(nat, TOK(h_many1(digit))); - H_ARULE(pnat, TOK(SEQ(pdigit, h_many(digit)))); + H_ARULE(pnat, TOK(SEQ(h_many(zero), pdigit, h_many(digit)))); //H_RULE(npair, SEQ(pnat, wel,ws, nat)); #define OPT(X) CHX(X, epsilon) -- GitLab