From df13534a362db9ee6def13689ce040e48c73a29a Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sat, 10 Dec 2016 20:07:32 +0000 Subject: yyparse(): extend parser stack before every shift. This reverts v5.25.7-60-gb2c9b6e and adds a test. In that previous commit of mine, for efficiency I changed it so that it checked and extended the parser stack only after every reduce rather than every shift, but when it did check, it extended it by at least 15 slots to allow for all the elements of the longest possible rule to be shifted. Turns out this was bad reasoning. The following type of code can shift indefinitely without ever reducing: [{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ --- parser.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'parser.h') diff --git a/parser.h b/parser.h index 3c7bb4e97d..ad148c26eb 100644 --- a/parser.h +++ b/parser.h @@ -44,9 +44,7 @@ typedef struct yy_parser { int yylen; /* length of active reduction */ yy_stack_frame *stack; /* base of stack */ - yy_stack_frame *stack_maxbase;/* (stack + alloced size - YY_MAXRULE) - * it's offset by -YY_MAXRULE to make - * overflow checks quicker */ + yy_stack_frame *stack_max1;/* (top-1)th element of allocated stack */ yy_stack_frame *ps; /* current stack frame */ /* lexer state */ -- cgit v1.2.1