From: Akim Demaille Date: Thu, 16 Mar 2000 16:00:07 +0000 (+0000) Subject: * src/bison.s1 (yyparse): Reorganize the definitions of the stacks X-Git-Tag: BISON-1_28b~171 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/bb10be5408f05ce81863bd115a5639cfc303edcb * src/bison.s1 (yyparse): Reorganize the definitions of the stacks and related variables so that the similarities are highlighted. --- diff --git a/ChangeLog b/ChangeLog index 928c0d3d..75c820c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-03-16 Akim Demaille + + * src/bison.s1 (yyparse): Reorganize the definitions of the stacks + and related variables so that the similarities are highlighted. + 2000-03-16 Akim Demaille * src/bison.s1: Properly indent CPP directives. diff --git a/src/bison.s1 b/src/bison.s1 index 76f87692..ea58ffcc 100644 --- a/src/bison.s1 +++ b/src/bison.s1 @@ -251,29 +251,37 @@ yyparse(YYPARSE_PARAM_ARG) { register int yystate; register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ int yychar1 = 0; + /* Three stacks and their tools: + `yyss': related to states, + `yysv': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; - - /* Refer to the stacks thru separate pointers. */ - short *yyss = yyssa; - /* To allow yyoverflow to reallocate them elsewhere. */ YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; #ifdef YYLSP_NEEDED /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; +#endif +#ifdef YYLSP_NEEDED # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else # define YYPOPSTACK (yyvsp--, yyssp--) @@ -291,9 +299,10 @@ yyparse(YYPARSE_PARAM_ARG) # endif #endif - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ + + /* The variable used to return semantic values from the action + routines. */ + YYSTYPE yyval; int yylen; @@ -344,16 +353,16 @@ yynewstate: # ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); + yyoverflow ("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); # else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); + yyoverflow ("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); # endif yyss = yyss1; yyvs = yyvs1; diff --git a/src/bison.simple b/src/bison.simple index 76f87692..ea58ffcc 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -251,29 +251,37 @@ yyparse(YYPARSE_PARAM_ARG) { register int yystate; register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ int yychar1 = 0; + /* Three stacks and their tools: + `yyss': related to states, + `yysv': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; - - /* Refer to the stacks thru separate pointers. */ - short *yyss = yyssa; - /* To allow yyoverflow to reallocate them elsewhere. */ YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; #ifdef YYLSP_NEEDED /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; +#endif +#ifdef YYLSP_NEEDED # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else # define YYPOPSTACK (yyvsp--, yyssp--) @@ -291,9 +299,10 @@ yyparse(YYPARSE_PARAM_ARG) # endif #endif - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ + + /* The variable used to return semantic values from the action + routines. */ + YYSTYPE yyval; int yylen; @@ -344,16 +353,16 @@ yynewstate: # ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); + yyoverflow ("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); # else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); + yyoverflow ("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); # endif yyss = yyss1; yyvs = yyvs1;