From: Paul Eggert Date: Thu, 22 Dec 2005 00:24:40 +0000 (+0000) Subject: * NEWS: Reword %destructor vs YYABORT etc. X-Git-Tag: v2.3b~541 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/9d9b8b70061b84abff1222350bc94f033cee6d62?hp=2c3b392a9ad550ca87f6e5172072cd0b70b15f1d * NEWS: Reword %destructor vs YYABORT etc. * data/glr.c: Use American spacing, for consistency. * data/glr.cc: Likewise. * data/lalr1.cc: Likewise. * data/yacc.c: Likewise. * data/yacc.c: Reformat comments slightly. * doc/bison.texinfo: Replace "non-" with "non" when that makes sense, for consistency. Fix some spelling errors and reword recently-included text slightly. * tests/cxx-type.at: Cast results of malloc, for C++. --- diff --git a/ChangeLog b/ChangeLog index 4bcf0a31..9cd31938 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-12-21 Paul Eggert + + * NEWS: Reword %destructor vs YYABORT etc. + * data/glr.c: Use American spacing, for consistency. + * data/glr.cc: Likewise. + * data/lalr1.cc: Likewise. + * data/yacc.c: Likewise. + * data/yacc.c: Reformat comments slightly. + * doc/bison.texinfo: Replace "non-" with "non" when that makes sense, + for consistency. Fix some spelling errors and reword recently-included + text slightly. + * tests/cxx-type.at: Cast results of malloc, for C++. + 2005-12-21 Joel E. Denny * tests/cxx-type.at: Construct a tree, count the parents of shared diff --git a/NEWS b/NEWS index 29310169..ae7c5c94 100644 --- a/NEWS +++ b/NEWS @@ -3,10 +3,10 @@ Bison News Changes in version 2.1a: -* %destructor vs. YYACCEPT, YYERROR, and YYABORT. - When the parsing/action is cut by the user using one of these - special actions, the stack is freed except the right-hand side - symbols of the current rule. +* %destructor vs. YYABORT, YYACCEPT, and YYERROR. + Destructors are now called when user code invokes YYABORT, YYACCEPT, + and YYERROR, for all objects on the stack, other than objects + corresponding to the right-hand side of the current rule. * GLR, C++ LALR(1) parsers. These parser skeletons are now distributed with the same special diff --git a/data/glr.c b/data/glr.c index 99c7bb70..e1671325 100644 --- a/data/glr.c +++ b/data/glr.c @@ -151,7 +151,7 @@ m4_divert(0)dnl b4_copyright([Skeleton parser for GLR parsing with Bison], [2002, 2003, 2004, 2005]) [ -/* This is the parser code for GLR (Generalized LR) parser. */ +/* This is the parser code for GLR (Generalized LR) parser. */ ]b4_identification @@ -230,7 +230,7 @@ m4_if(b4_defines_flag, 0, right-hand sides. Unlike the standard yacc.c template, here we set the default value of $$ to a zeroed-out value. Since the default value is undefined, this behavior is - technically correct. */ + technically correct. */ static YYSTYPE yyval_default; /* Copy the second part of user declarations. */ @@ -323,23 +323,23 @@ b4_syncline([@oline@], [@ofile@]) # define YYASSERT(condition) ((void) ((condition) || (abort (), 0))) #endif -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL ]b4_final_state_number[ /* YYLAST -- Last index in YYTABLE. */ #define YYLAST ]b4_last[ -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS ]b4_tokens_number[ -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS ]b4_nterms_number[ -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES ]b4_rules_number[ -/* YYNRULES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES ]b4_states_number[ -/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */ +/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */ #define YYMAXRHS ]b4_r2_max[ /* YYMAXLEFT -- Maximum number of symbols to the left of a handle - accessed by $0, $-1, etc., in any rule. */ + accessed by $0, $-1, etc., in any rule. */ #define YYMAXLEFT ]b4_max_left_semantic_context[ /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */ @@ -364,7 +364,7 @@ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = ]b4_prhs[ }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = { ]b4_rhs[ @@ -379,7 +379,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { ]b4_tname[ @@ -398,13 +398,13 @@ static const ]b4_int_type_for([b4_r2])[ yyr2[] = ]b4_r2[ }; -/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */ +/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */ static const ]b4_int_type_for([b4_dprec])[ yydprec[] = { ]b4_dprec[ }; -/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */ +/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */ static const ]b4_int_type_for([b4_merger])[ yymerger[] = { ]b4_merger[ @@ -418,7 +418,7 @@ static const ]b4_int_type_for([b4_defact])[ yydefact[] = ]b4_defact[ }; -/* YYPDEFGOTO[NTERM-NUM]. */ +/* YYPDEFGOTO[NTERM-NUM]. */ static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] = { ]b4_defgoto[ @@ -621,7 +621,7 @@ int yydebug; allocation. This is to allow allocation and initialization to be completed by functions that call yyexpandGLRStack before the stack is expanded, thus insuring that all necessary pointers get - properly redirected to new data. */ + properly redirected to new data. */ #define YYHEADROOM 2 #ifndef YYSTACKEXPANDABLE @@ -740,12 +740,12 @@ typedef union yyGLRStackItem yyGLRStackItem; typedef struct yyGLRStack yyGLRStack; struct yyGLRState { - /** Type tag: always true. */ + /** Type tag: always true. */ yybool yyisState; - /** Type tag for yysemantics. If true, yysval applies, otherwise - * yyfirstVal applies. */ + /** Type tag for yysemantics. If true, yysval applies, otherwise + * yyfirstVal applies. */ yybool yyresolved; - /** Number of corresponding LALR(1) machine state. */ + /** Number of corresponding LALR(1) machine state. */ yyStateNum yylrState; /** Preceding state in this stack */ yyGLRState* yypred; @@ -754,12 +754,12 @@ struct yyGLRState { union { /** First in a chain of alternative reductions producing the * non-terminal corresponding to this state, threaded through - * yynext. */ + * yynext. */ yySemanticOption* yyfirstVal; - /** Semantic value for this state. */ + /** Semantic value for this state. */ YYSTYPE yysval; } yysemantics; - /** Source location for this state. */ + /** Source location for this state. */ YYLTYPE yyloc; }; @@ -769,19 +769,19 @@ struct yyGLRStateSet { }; struct yySemanticOption { - /** Type tag: always false. */ + /** Type tag: always false. */ yybool yyisState; /** Rule number for this reduction */ yyRuleNum yyrule; - /** The last RHS state in the list of states to be reduced. */ + /** The last RHS state in the list of states to be reduced. */ yyGLRState* yystate; - /** Next sibling in chain of options. To facilitate merging, - * options are chained in decreasing order by address. */ + /** Next sibling in chain of options. To facilitate merging, + * options are chained in decreasing order by address. */ yySemanticOption* yynext; }; -/** Type of the items in the GLR stack. The yyisState field - * indicates which item of the union is valid. */ +/** Type of the items in the GLR stack. The yyisState field + * indicates which item of the union is valid. */ union yyGLRStackItem { yyGLRState yystate; yySemanticOption yyoption; @@ -844,7 +844,7 @@ yytokenName (yySymbol yytoken) /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred - * containing the pointer to the next state in the chain. */ + * containing the pointer to the next state in the chain. */ static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__)); static void yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1) @@ -881,8 +881,8 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal) /** Perform user action for rule number YYN, with RHS length YYRHSLEN, * and top stack item YYVSP. YYLVALP points to place to put semantic * value ($$), and yylocp points to place for location information - * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT, - * yyerr for YYERROR, yyabort for YYABORT. */ + * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT, + * yyerr for YYERROR, yyabort for YYABORT. */ /*ARGSUSED*/ static YYRESULTTAG yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, YYSTYPE* yyvalp, @@ -995,7 +995,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[) } } -/** Left-hand-side symbol for rule #RULE. */ +/** Left-hand-side symbol for rule #RULE. */ static inline yySymbol yylhsNonterm (yyRuleNum yyrule) { @@ -1008,14 +1008,14 @@ yylhsNonterm (yyRuleNum yyrule) [((yystate) == YYPACT_NINF)])[ /** True iff LR state STATE has only a default reduction (regardless - * of token). */ + * of token). */ static inline yybool yyisDefaultedState (yyStateNum yystate) { return yyis_pact_ninf (yypact[yystate]); } -/** The default reduction for STATE, assuming it has one. */ +/** The default reduction for STATE, assuming it has one. */ static inline yyRuleNum yydefaultAction (yyStateNum yystate) { @@ -1112,7 +1112,7 @@ yyaddDeferredAction (yyGLRStack* yystackp, yyGLRState* yystate, /* GLRStacks */ -/** Initialize SET to a singleton set containing an empty stack. */ +/** Initialize SET to a singleton set containing an empty stack. */ static yybool yyinitStateSet (yyGLRStateSet* yyset) { @@ -1131,7 +1131,7 @@ static void yyfreeStateSet (yyGLRStateSet* yyset) } /** Initialize STACK to a single empty stack, with total maximum - * capacity for all stacks of SIZE. */ + * capacity for all stacks of SIZE. */ static yybool yyinitGLRStack (yyGLRStack* yystackp, size_t yysize) { @@ -1157,7 +1157,7 @@ yyinitGLRStack (yyGLRStack* yystackp, size_t yysize) stack from outside should be considered invalid after this call. We always expand when there are 1 or fewer items left AFTER an allocation, so that we can avoid having external pointers exist - across an allocation. */ + across an allocation. */ static void yyexpandGLRStack (yyGLRStack* yystackp) { @@ -1225,7 +1225,7 @@ yyfreeGLRStack (yyGLRStack* yystackp) /** Assuming that S is a GLRState somewhere on STACK, update the * splitpoint of STACK, if needed, so that it is at least as deep as - * S. */ + * S. */ static inline void yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys) { @@ -1233,7 +1233,7 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys) yystackp->yysplitPoint = yys; } -/** Invalidate stack #K in STACK. */ +/** Invalidate stack #K in STACK. */ static inline void yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk) { @@ -1244,7 +1244,7 @@ yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk) /** Undelete the last stack that was marked as deleted. Can only be done once after a deletion, and only when all other stacks have - been deleted. */ + been deleted. */ static void yyundeleteLastStack (yyGLRStack* yystackp) { @@ -1286,7 +1286,7 @@ yyremoveDeletes (yyGLRStack* yystackp) } /** Shift to a new state on stack #K of STACK, corresponding to LR state - * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */ + * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */ static inline void yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, size_t yyposn, @@ -1307,7 +1307,7 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, /** Shift stack #K of YYSTACK, to a new state corresponding to LR * state YYLRSTATE, at input position YYPOSN, with the (unresolved) - * semantic value of YYRHS under the action for YYRULE. */ + * semantic value of YYRHS under the action for YYRULE. */ static inline void yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule) @@ -1321,16 +1321,16 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, yynewState->yysemantics.yyfirstVal = NULL; yystackp->yytops.yystates[yyk] = yynewState; - /* Invokes YY_RESERVE_GLRSTACK. */ + /* Invokes YY_RESERVE_GLRSTACK. */ yyaddDeferredAction (yystackp, yynewState, rhs, yyrule); } /** Pop the symbols consumed by reduction #RULE from the top of stack * #K of STACK, and perform the appropriate semantic action on their * semantic values. Assumes that all ambiguities in semantic values - * have been previously resolved. Set *VALP to the resulting value, + * have been previously resolved. Set *VALP to the resulting value, * and *LOCP to the computed location (if any). Return value is as - * for userAction. */ + * for userAction. */ static inline YYRESULTTAG yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) @@ -1339,7 +1339,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, if (yystackp->yysplitPoint == NULL) { - /* Standard special case: single stack. */ + /* Standard special case: single stack. */ yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; YYASSERT (yyk == 0); yystackp->yynextFree -= yynrhs; @@ -1353,14 +1353,14 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, /* At present, doAction is never called in nondeterministic * mode, so this branch is never taken. It is here in * anticipation of a future feature that will allow immediate - * evaluation of selected actions in nondeterministic mode. */ + * evaluation of selected actions in nondeterministic mode. */ int yyi; yyGLRState* yys; yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1]; yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yystackp->yytops.yystates[yyk];]b4_location_if([[ if (yynrhs == 0) - /* Set default location. */ + /* Set default location. */ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[ for (yyi = 0; yyi < yynrhs; yyi += 1) { @@ -1424,7 +1424,7 @@ yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, * the new state. If the new state would have an identical input * position, LR state, and predecessor to an existing state on the stack, * it is identified with that existing state, eliminating stack #K from - * the STACK. In this case, the (necessarily deferred) semantic value is + * the STACK. In this case, the (necessarily deferred) semantic value is * added to the options for the existing state's semantic value. */ static inline YYRESULTTAG @@ -1463,7 +1463,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, yyupdateSplit (yystackp, yys); yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule)); YYDPRINTF ((stderr, - "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n", + "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n", (unsigned long int) yyk, yyrule - 1, yynewLRState)); for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) if (yyi != yyk && yystackp->yytops.yystates[yyi] != NULL) @@ -1518,7 +1518,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk) /** True iff Y0 and Y1 represent identical options at the top level. * That is, they represent the same rule applied to RHS symbols - * that produce the same terminal symbols. */ + * that produce the same terminal symbols. */ static yybool yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1) { @@ -1539,7 +1539,7 @@ yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1) } /** Assuming identicalOptions (Y0,Y1), destructively merge the - * alternative semantic values for the RHS-symbols of Y1 and Y0. */ + * alternative semantic values for the RHS-symbols of Y1 and Y0. */ static void yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) { @@ -1593,7 +1593,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) /** Y0 and Y1 represent two possible actions to take in a given * parsing state; return 0 if no combination is possible, - * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */ + * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */ static int yypreference (yySemanticOption* y0, yySemanticOption* y1) { @@ -1655,7 +1655,7 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp, YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[)); yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_location_if([[ if (yynrhs == 0) - /* Set default location. */ + /* Set default location. */ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[ return yyuserAction (yyopt->yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, @@ -1733,7 +1733,7 @@ yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated - * actions, and return the result. */ + * actions, and return the result. */ static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystackp, YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) @@ -2040,7 +2040,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) if (*yytokenp != YYEMPTY) {]b4_location_if([[ /* We throw away the lookahead, but the error range - of the shifted error token must take it into account. */ + of the shifted error token must take it into account. */ yyGLRState *yys = yystackp->yytops.yystates[0]; yyGLRStackItem yyerror_range[3]; yyerror_range[1].yystate.yyloc = yys->yyloc; @@ -2077,7 +2077,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) yyremoveDeletes (yystackp); yycompressStack (yystackp); - /* Now pop stack until we find a state that shifts the error token. */ + /* Now pop stack until we find a state that shifts the error token. */ yystackp->yyerrState = 3; while (yystackp->yytops.yystates[0] != NULL) { @@ -2153,7 +2153,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) m4_ifdef([b4_initial_action], [ m4_pushdef([b4_at_dollar], [yylloc])dnl m4_pushdef([b4_dollar_dollar], [yylval])dnl - /* User initialization code. */ + /* User initialization code. */ b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl diff --git a/data/glr.cc b/data/glr.cc index 52551f03..23148c9a 100644 --- a/data/glr.cc +++ b/data/glr.cc @@ -112,7 +112,7 @@ m4_popdef([b4_parse_param])dnl /* Pacify ``unused variable'' warnings. */ YYUSE (yyvaluep); YYUSE (yylocationp); - /* Backward compatibility, but should be removed eventually. */ + /* Backward compatibility, but should be removed eventually. */ std::ostream& cdebug_ = *yycdebug_; YYUSE (cdebug_); diff --git a/data/lalr1.cc b/data/lalr1.cc index d9d9af9d..ef451070 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -285,7 +285,7 @@ b4_error_verbose_if([, int tok])[); [b4_token_defines(b4_tokens) #ifndef YYSTYPE - /* Redirection for backward compatibility. */ + /* Redirection for backward compatibility. */ # define YYSTYPE yy::b4_parser_class_name::semantic_type #endif ])[ @@ -323,7 +323,7 @@ b4_syncline([@oline@], [@ofile@])[ /* Suppress unused-variable warnings by "using" E. */ #define YYUSE(e) ((void) (e)) -/* A pseudo ostream that takes yydebug_ into account. */ +/* A pseudo ostream that takes yydebug_ into account. */ # define YYCDEBUG \ for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \ (*yycdebug_) @@ -428,7 +428,7 @@ namespace yy ]b4_parser_class_name[::yysymprint_ (int yytype, const semantic_type* yyvaluep, const location_type* yylocationp) { - /* Backward compatibility, but should be removed eventually. */ + /* Backward compatibility, but should be removed eventually. */ std::ostream& cdebug_ = *yycdebug_; YYUSE (!&cdebug_); @@ -512,7 +512,7 @@ namespace yy int yylen = 0; int yystate = 0; - /* Error handling. */ + /* Error handling. */ int yynerrs_ = 0; int yyerrstatus_ = 0; @@ -535,7 +535,7 @@ namespace yy ]m4_ifdef([b4_initial_action], [ m4_pushdef([b4_at_dollar], [yylloc])dnl m4_pushdef([b4_dollar_dollar], [yylval])dnl - /* User initialization code. */ + /* User initialization code. */ b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl @@ -732,7 +732,7 @@ b4_error_verbose_if([, yytoken])[)); yyerror_range[0] = yylocation_stack_[yylen - 1]; /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ + this YYERROR. */ yypop_ (yylen); yylen = 0; yystate = yystate_stack_[0]; @@ -781,7 +781,7 @@ b4_error_verbose_if([, yytoken])[)); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); - /* Shift the error token. */ + /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], &yysemantic_stack_[0], &yylocation_stack_[0]); @@ -803,7 +803,7 @@ b4_error_verbose_if([, yytoken])[)); yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ + this YYABORT or YYACCEPT. */ yypop_ (yylen); while (yystate_stack_.height () != 1) { @@ -950,7 +950,7 @@ b4_error_verbose_if([, int tok])[) #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at \a yyntokens_, nonterminals. */ + First, the terminals, then, starting at \a yyntokens_, nonterminals. */ const char* const ]b4_parser_class_name[::yytname_[] = { @@ -959,7 +959,7 @@ b4_error_verbose_if([, int tok])[) #endif #if YYDEBUG - /* YYRHS -- A `-1'-separated list of the rules' RHS. */ + /* YYRHS -- A `-1'-separated list of the rules' RHS. */ const ]b4_parser_class_name[::rhs_number_type ]b4_parser_class_name[::yyrhs_[] = { diff --git a/data/yacc.c b/data/yacc.c index db978f0d..c23b5dc1 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -305,7 +305,7 @@ b4_syncline([@oline@], [@ofile@])[ # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ + /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, @@ -411,18 +411,18 @@ union yyalloc typedef short int yysigned_char; #endif -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL ]b4_final_state_number[ /* YYLAST -- Last index in YYTABLE. */ #define YYLAST ]b4_last[ -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS ]b4_tokens_number[ -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS ]b4_nterms_number[ -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES ]b4_rules_number[ -/* YYNRULES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES ]b4_states_number[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ @@ -446,7 +446,7 @@ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = ]b4_prhs[ }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = { ]b4_rhs[ @@ -461,7 +461,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { ]b4_tname[ @@ -497,7 +497,7 @@ static const ]b4_int_type_for([b4_defact])[ yydefact[] = ]b4_defact[ }; -/* YYDEFGOTO[NTERM-NUM]. */ +/* YYDEFGOTO[NTERM-NUM]. */ static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] = { ]b4_defgoto[ @@ -666,7 +666,7 @@ do { \ [[short int *top], [top]])[ { YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) + for (; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } @@ -1039,7 +1039,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param) YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; - /* The locations where the error started and ended. */ + /* The locations where the error started and ended. */ YYLTYPE yyerror_range[2];]])[ #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_location_if([, yylsp -= (N)])[) @@ -1052,7 +1052,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param) ]b4_location_if([ YYLTYPE yyloc;])[ /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped off. */ + Keep to zero when no symbol should be popped. */ int yylen = 0; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1079,7 +1079,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param) m4_ifdef([b4_initial_action], [ m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl - /* User initialization code. */ + /* User initialization code. */ b4_initial_action m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_at_dollar])dnl @@ -1097,8 +1097,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ + have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: @@ -1111,7 +1110,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of + /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; @@ -1269,7 +1268,7 @@ yyreduce: yyval = yyvsp[1-yylen]; ]b4_location_if( -[[ /* Default location. */ +[[ /* Default location. */ YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);]])[ YY_REDUCE_PRINT (yyn); switch (yyn) @@ -1387,7 +1386,7 @@ yyerrorlab: ]b4_location_if([[ yyerror_range[0] = yylsp[1-yylen]; ]])[ /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ + this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); @@ -1434,11 +1433,11 @@ yyerrlab1: ]b4_location_if([[ yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the look-ahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2); *++yylsp = yyloc;]])[ - /* Shift the error token. */ + /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; @@ -1474,7 +1473,7 @@ yyreturn: yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[); /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ + this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) diff --git a/doc/bison.texinfo b/doc/bison.texinfo index acc3be5d..74e53812 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -461,7 +461,7 @@ more information on this. @cindex @acronym{GLR} parsing @cindex generalized @acronym{LR} (@acronym{GLR}) parsing @cindex ambiguous grammars -@cindex non-deterministic parsing +@cindex nondeterministic parsing Parsers for @acronym{LALR}(1) grammars are @dfn{deterministic}, meaning roughly that the next grammar rule to apply at any point in the input is @@ -469,7 +469,7 @@ uniquely determined by the preceding input and a fixed, finite portion (called a @dfn{look-ahead}) of the remaining input. A context-free grammar can be @dfn{ambiguous}, meaning that there are multiple ways to apply the grammar rules to get the same inputs. Even unambiguous -grammars can be @dfn{non-deterministic}, meaning that no fixed +grammars can be @dfn{nondeterministic}, meaning that no fixed look-ahead always suffices to determine the next grammar rule to apply. With the proper declarations, Bison is also able to parse these more general context-free grammars, using a technique known as @acronym{GLR} @@ -2126,7 +2126,7 @@ as @code{sin}, @code{cos}, etc. It is easy to add new operators to the infix calculator as long as they are only single-character literals. The lexical analyzer @code{yylex} passes -back all nonnumber characters as tokens, so new grammar rules suffice for +back all nonnumeric characters as tokens, so new grammar rules suffice for adding a new operator. But we want something more flexible: built-in functions whose syntax has this form: @@ -2411,7 +2411,7 @@ getsym (char const *sym_name) The function @code{yylex} must now recognize variables, numeric values, and the single-character arithmetic operators. Strings of alphanumeric -characters with a leading non-digit are recognized as either variables or +characters with a leading letter are recognized as either variables or functions depending on what the symbol table says about them. The string is passed to @code{getsym} for look up in the symbol table. If @@ -2782,7 +2782,7 @@ into a separate header file @file{@var{name}.tab.h} which you can include in the other source files that need it. @xref{Invocation, ,Invoking Bison}. If you want to write a grammar that is portable to any Standard C -host, you must use only non-null character tokens taken from the basic +host, you must use only nonnull character tokens taken from the basic execution character set of Standard C@. This set consists of the ten digits, the 52 lower- and upper-case English letters, and the characters in the following C-language string: @@ -3813,7 +3813,7 @@ For instance, if your locations use a file name, you may use During error recovery (@pxref{Error Recovery}), symbols already pushed on the stack and tokens coming from the rest of the file are discarded until the parser falls on its feet. If the parser runs out of memory, -or if the parsing is cut by @code{YYACCEPT} or @code{YYABORT}, all the +or if it returns via @code{YYABORT} or @code{YYACCEPT}, all the symbols on the stack must be discarded. Even if the parser succeeds, it must discard the start symbol. @@ -3862,16 +3862,18 @@ stacked symbols popped during the first phase of error recovery, incoming terminals during the second phase of error recovery, @item the current look-ahead and the entire stack (except the current -right-hand side symbols) when the parser aborts (either via an explicit -call to @code{YYABORT} or @code{YYACCEPT}, or as a consequence of a -failed error recovery or of memory exhaustion), and +right-hand side symbols) when the parser returns immediately, and @item the start symbol, when the parser succeeds. @end itemize -Note that right-hand size symbols of a rule that explicitly triggers a -syntax error via @code{YYERROR} are not reclaimed. As a thumb rule, -destructors are invoked only when you do not have other means to manage +The parser can @dfn{return immediately} because of an explicit call to +@code{YYABORT} or @code{YYACCEPT}, or failed error recovery, or memory +exhaustion. + +Right-hand size symbols of a rule that explicitly triggers a syntax +error via @code{YYERROR} are not discarded automatically. As a rule +of thumb, destructors are invoked only when user actions cannot manage the memory. @node Expect Decl @@ -3959,8 +3961,8 @@ may override this restriction with the @code{%start} declaration as follows: A @dfn{reentrant} program is one which does not alter in the course of execution; in other words, it consists entirely of @dfn{pure} (read-only) code. Reentrancy is important whenever asynchronous execution is possible; -for example, a non-reentrant program may not be safe to call from a signal -handler. In systems with multiple threads of control, a non-reentrant +for example, a nonreentrant program may not be safe to call from a signal +handler. In systems with multiple threads of control, a nonreentrant program must be called only within interlocks. Normally, Bison generates a parser which is not reentrant. This is @@ -4450,7 +4452,7 @@ The @code{yytname} table is generated only if you use the @subsection Semantic Values of Tokens @vindex yylval -In an ordinary (non-reentrant) parser, the semantic value of the token must +In an ordinary (nonreentrant) parser, the semantic value of the token must be stored into the global variable @code{yylval}. When you are using just one data type for semantic values, @code{yylval} has that type. Thus, if the type is @code{int} (the default), you might write this in @@ -5610,7 +5612,7 @@ pp.@: 615--649 @uref{http://doi.acm.org/10.1145/69622.357187}. @cindex @acronym{GLR} parsing @cindex generalized @acronym{LR} (@acronym{GLR}) parsing @cindex ambiguous grammars -@cindex non-deterministic parsing +@cindex nondeterministic parsing Bison produces @emph{deterministic} parsers that choose uniquely when to reduce and which reduction to apply @@ -5675,10 +5677,10 @@ quadratic worst-case time, and any general (possibly ambiguous) context-free grammar in cubic worst-case time. However, Bison currently uses a simpler data structure that requires time proportional to the length of the input times the maximum number of stacks required for any -prefix of the input. Thus, really ambiguous or non-deterministic +prefix of the input. Thus, really ambiguous or nondeterministic grammars can require exponential time and space to process. Such badly behaving examples, however, are not generally of practical interest. -Usually, non-determinism in a grammar is local---the parser is ``in +Usually, nondeterminism in a grammar is local---the parser is ``in doubt'' only for a few tokens at a time. Therefore, the current data structure should generally be adequate. On @acronym{LALR}(1) portions of a grammar, in particular, it is only slightly slower than with the default @@ -7037,7 +7039,7 @@ The output files @file{@var{output}.hh} and @file{@var{output}.cc} declare and define the parser class in the namespace @code{yy}. The class name defaults to @code{parser}, but may be changed using @samp{%define "parser_class_name" "@var{name}"}. The interface of -this class is detailled below. It can be extended using the +this class is detailed below. It can be extended using the @code{%parse-param} feature: its semantics is slightly changed since it describes an additional member of the parser class, and an additional argument for its constructor. @@ -7065,7 +7067,7 @@ Get or set the stream used for tracing the parsing. It defaults to @deftypemethod {parser} {debug_level_type} debug_level () @deftypemethodx {parser} {void} set_debug_level (debug_level @var{l}) Get or set the tracing level. Currently its value is either 0, no trace, -or non-zero, full tracing. +or nonzero, full tracing. @end deftypemethod @deftypemethod {parser} {void} error (const location_type& @var{l}, const std::string& @var{m}) @@ -7116,7 +7118,7 @@ actually easier to interface with. @subsection Calc++ --- C++ Calculator Of course the grammar is dedicated to arithmetics, a single -expression, possibily preceded by variable assignments. An +expression, possibly preceded by variable assignments. An environment containing possibly predefined variables such as @code{one} and @code{two}, is exchanged with the parser. An example of valid input follows. @@ -7411,7 +7413,7 @@ The grammar itself is straightforward. unit: assignments exp @{ driver.result = $2; @}; assignments: assignments assignment @{@} - | /* Nothing. */ @{@}; + | /* Nothing. */ @{@}; assignment: "identifier" ":=" exp @{ driver.variables[*$1] = $3; @}; @@ -7480,7 +7482,7 @@ blank [ \t] @end example @noindent -The following paragraph suffices to track locations acurately. Each +The following paragraph suffices to track locations accurately. Each time @code{yylex} is invoked, the begin position is moved onto the end position. Then when a pattern is matched, the end position is advanced of its width. In case it matched ends of lines, the end @@ -7505,7 +7507,7 @@ preceding tokens. Comments would be treated equally. The rules are simple, just note the use of the driver to report errors. It is convenient to use a typedef to shorten @code{yy::calcxx_parser::token::identifier} into -@code{token::identifier} for isntance. +@code{token::identifier} for instance. @comment file: calc++-scanner.ll @example @@ -7949,7 +7951,7 @@ parser file. @xref{Decl Summary}. @end deffn @deffn {Directive} %nonassoc -Bison declaration to assign non-associativity to token(s). +Bison declaration to assign nonassociativity to token(s). @xref{Precedence Decl, ,Operator Precedence}. @end deffn diff --git a/tests/cxx-type.at b/tests/cxx-type.at index dcc0810c..78a4f68f 100644 --- a/tests/cxx-type.at +++ b/tests/cxx-type.at @@ -231,7 +231,7 @@ yyerror (ERROR_PARAMETERS) static Node * new_nterm (char const *form, Node *child0, Node *child1, Node *child2) { - Node *node = malloc (sizeof (Node)); + Node *node = (Node *) malloc (sizeof (Node)); node->nterm.type = 1; node->nterm.parents = 0; node->nterm.form = form; @@ -250,7 +250,7 @@ new_nterm (char const *form, Node *child0, Node *child1, Node *child2) static Node * new_term (char *text) { - Node *node = malloc (sizeof (Node)); + Node *node = (Node *) malloc (sizeof (Node)); node->term.type = 0; node->term.parents = 0; node->term.text = text; @@ -286,7 +286,7 @@ node_to_string (Node *node) char *buffer; if (!node) { - buffer = malloc (1); + buffer = (char *) malloc (1); buffer[0] = 0; } else if (node->node_info.type == 1) @@ -294,8 +294,8 @@ node_to_string (Node *node) child0 = node_to_string (node->nterm.children[0]); child1 = node_to_string (node->nterm.children[1]); child2 = node_to_string (node->nterm.children[2]); - buffer = malloc (strlen (node->nterm.form) + strlen (child0) - + strlen (child1) + strlen (child2) + 1); + buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0) + + strlen (child1) + strlen (child2) + 1); sprintf (buffer, node->nterm.form, child0, child1, child2); free (child0); free (child1);