From 7e628fb0f5c86455f22a6c843f83a88baec45f66 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Fri, 13 Jan 2023 09:58:32 +0000 Subject: [PATCH] change array rule back to use h_many This reverts the part of commit f7dbb2ac that reworked the definition of arrays into explicit grammar recursion in order to make 'obj' compile with LALR. That project never came to fruition and with packrat it causes a recursive function call for every array element, exhausting the stack with large arrays. Fixes #26. This does not yet remove the explicitly recursive rules elemd and elemr because the latter is still used by the object stream parser. --- pdf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdf.c b/pdf.c index c967945..71b606e 100644 --- a/pdf.c +++ b/pdf.c @@ -2419,7 +2419,7 @@ init_parser(struct Env *aux) H_AVDRULE(array_begin, lbrack, aux); /* semantic action and validation implementing a limit on how deeply arrays can be nested */ H_AVDRULE(array_end, rbrack, aux); /* nesting limit and counter underflow check */ - H_ARULE(array_, h_middle(array_begin, elemd, array_end)); + H_ARULE(array_, h_middle(array_begin, MANY_WS(obj), array_end)); H_RULE(elemd_, CHX(SEQ(ws, dobj, elemd), SEQ(ws, name, elemr), SEQ(ws, robj, elemr), -- GitLab