parse.lac: implement exploratory stack reallocations.

* data/yacc.c: Rename %define variable parse.lac.es-capacity to
parse.lac.es-capacity-initial.  Accept parse.lac.memory-trace
with values of "failures" (default) or "full".
(b4_declare_parser_state_variables): Add yyesa, yyes, and
yyes_capacity variables.
(YYSTACK_USE_ALLOCA): Ignore it if LAC requested.
(YYSTACK_ALLOC, YYSTACK_FREE, YYSTACK_ALLOC_MAXIMUM): Define if
LAC requested.
(YYCOPY_NEEDED): New cpp macro.
(YYCOPY): Define if LAC requested.
(yy_lac_stack_realloc): New function implementing stack
reallocations.  Use YYMAXDEPTH for maximum stack size given that
the stack should never need to grow larger than the main state
stack needs to grow without LAC.
(YY_LAC_ESTABLISH): Update yy_lac invocation.
(yy_lac): Add arguments for exploratory stack memory data
recorded in the main parser.  Invoke yy_lac_stack_realloc when
reallocation is necessary.
(yysyntax_error): Add the same new arguments and pass them to
yy_lac.
(yypstate_delete): Free yyes if necessary.
(yyesa, yyes, yyes_capacity): #define these to yypstate members
in the case of push parsing.
(yyparse, yypush_parse): Initialize yyes and yyes_capacity.
Update yysyntax_error invocations.  At yyreturn, free yyes if
necessary.
* src/parse-gram.y: %define parse.lac full.
* tests/input.at (LAC: errors for %define): Extend for
parse.lac-memory-trace.
* tests/regression.at (LAC: Exploratory stack): Extend to check
that stack reallocs happen when expected.
(LAC: Memory exhaustion): Update to use YYMAXDEPTH and
parse.lac.es-capacity-initial.
This commit is contained in:
Joel E. Denny
2010-12-11 13:17:13 -05:00
parent bf35c71c58
commit 107844a3ee
7 changed files with 1017 additions and 622 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -31,8 +31,8 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* "%code requires" blocks. */
/* Line 1904 of yacc.c */
#line 202 "src/parse-gram.y"
/* Line 2002 of yacc.c */
#line 203 "src/parse-gram.y"
# ifndef PARAM_TYPE
# define PARAM_TYPE
@@ -46,7 +46,7 @@
# endif
/* Line 1904 of yacc.c */
/* Line 2002 of yacc.c */
#line 51 "src/parse-gram.h"
/* Tokens. */
@@ -175,8 +175,8 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 1904 of yacc.c */
#line 88 "src/parse-gram.y"
/* Line 2002 of yacc.c */
#line 89 "src/parse-gram.y"
assoc assoc;
char *code;
@@ -188,13 +188,13 @@ typedef union YYSTYPE
uniqstr uniqstr;
unsigned char character;
/* Line 1904 of yacc.c */
#line 226 "src/parse-gram.y"
/* Line 2002 of yacc.c */
#line 227 "src/parse-gram.y"
param_type param;
/* Line 1904 of yacc.c */
/* Line 2002 of yacc.c */
#line 199 "src/parse-gram.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1

View File

@@ -73,6 +73,7 @@ static char const *char_name (char);
%locations
%pure-parser
%define parse.error "verbose"
%define parse.lac full
%name-prefix="gram_"
%expect 0