diff --git a/pdf.c b/pdf.c index c824eba7deba8b3bd32eb57073b7d76ca959795c..c55c2cdbe6266be2128046e7c5df5bf34f4ba22f 100644 --- a/pdf.c +++ b/pdf.c @@ -1174,11 +1174,11 @@ act_rldstring(const HParseResult *p, void *u) * * The counters are global across the document (but respect document structure, * e.g. parentheses in streams don't count, unless for some reason they're parsed with the lparen rule.) - * The lparen, dopen, and array_begin validations make the parse fail if this nesting depth is exceeded. + * The sopen, dopen, and array_begin validations make the parse fail if this nesting depth is exceeded. * Because currently there are no diagnostic messages, this can probably result in unexpected parses. * * validate_rparen, validate_array_end, and validate_dclose will make the parse fail if a respective closing token ( ')', ']', '>>' ) - * is encountered before an lparen, array_begin, or dopen (or there are more closing parentheses than opening ones.) This is not exactly + * is encountered before an sopen, array_begin, or dopen (or there are more closing parentheses than opening ones.) This is not exactly * the same as balanced parentheses: the order different types of parentheses appear in is not considered. Different brackets can be considered * independently because other H_RULEs already reject cases with interleaved opening/closing tokens such as "<< [ /Foo /Bar >> ]". */ @@ -1186,14 +1186,14 @@ act_rldstring(const HParseResult *p, void *u) #define PAREN_MAX_NEST_DEPTH 256 bool -validate_lparen(HParseResult *p, void *u) +validate_sopen(HParseResult *p, void *u) { struct Env *aux = (struct Env*) u; return aux->paren_nest_depth < PAREN_MAX_NEST_DEPTH; } HParsedToken * -act_lparen(const HParseResult *p, void *u) +act_sopen(const HParseResult *p, void *u) { struct Env *aux = (struct Env*) u; aux->paren_nest_depth += 1; @@ -1202,14 +1202,14 @@ act_lparen(const HParseResult *p, void *u) } bool -validate_rparen(HParseResult *p, void *u) +validate_sclose(HParseResult *p, void *u) { struct Env *aux = (struct Env*) u; return aux->paren_nest_depth > 0; } HParsedToken* -act_rparen(const HParseResult *p, void *u) +act_sclose(const HParseResult *p, void *u) { struct Env *aux = (struct Env*) u; if(aux->paren_nest_depth > 0) @@ -2491,8 +2491,8 @@ init_parser(struct Env *aux) H_RULE(slash, h_ch('/')); H_RULE(hash, h_ch('#')); H_RULE(bslash, h_ch('\\')); - H_AVDRULE(lparen, h_ch('('), aux); - H_ADRULE(rparen, h_ch(')'), aux); + H_RULE(lparen, h_ch('(')); + H_RULE(rparen, h_ch(')')); H_RULE(langle, h_ch('<')); H_RULE(rangle, h_ch('>')); H_RULE(lbrack, h_ch('[')); @@ -2565,8 +2565,10 @@ init_parser(struct Env *aux) H_RULE(sesc, h_right(bslash, CHX(escape, octal, wrap, epsilon))); /* NB: lone backslashes and escaped newlines are ignored */ H_ARULE(schars, h_many(CHX(schar, snest, sesc, eol))); - H_RULE(snest_, SEQ(lparen, schars, rparen)); - H_RULE(litstr, h_middle(lparen, schars, rparen)); + H_AVDRULE(sopen, lparen, aux); + H_AVDRULE(sclose, rparen, aux); + H_RULE(snest_, SEQ(sopen, schars, sclose)); + H_RULE(litstr, h_middle(sopen, schars, sclose)); H_RULE(hexstr, h_middle(langle, MANY_WS(hdigit), rangle)); H_ARULE(string, CHX(litstr, hexstr)); h_bind_indirect(snest, snest_);