From 742e4900c8b05c8c1f56985288141c890f1e9c73 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Sat, 10 Jun 2006 03:02:23 +0000 Subject: [PATCH] For consistency, use `lookahead' instead of `look-ahead' or `look_ahead'. Discussed starting at and then at . * NEWS: For the next release, note the change to `--report'. * TODO, doc/bison.1: Update English. * doc/bison.texinfo: Update English. (Understanding Your Parser, Bison Options): Document as `--report=lookahead' rather than `--report=look-ahead'. * src/conflicts.c: Update English in comments. (lookahead_set): Rename from look_ahead_set. (flush_reduce): Rename argument look_ahead_tokens to lookahead_tokens. (resolve_sr_conflict): Rename local look_ahead_tokens to lookahead_tokens, and update other uses. (flush_shift, set_conflicts, conflicts_solve, count_sr_conflicts, count_rr_conflicts, conflicts_free): Update uses. * src/getargs.c (report_args): Move "lookahead" before alternate spellings. (report_types): Update uses. (usage): For `--report' usage description, state `lookahead' spelling rather than `look-ahead'. * src/getargs.h (report.report_lookahead_tokens): Rename from report_look_ahead_tokens. * src/lalr.c: Update English in comments. (compute_lookahead_tokens): Rename from compute_look_ahead_tokens. (state_lookahead_tokens_count): Rename from state_look_ahead_tokens_count. Rename local n_look_ahead_tokens to n_lookahead_tokens. (lookahead_tokens_print): Rename from look_ahead_tokens_print. Rename local n_look_ahead_tokens to n_lookahead_tokens. Update other uses. Update English in output. (add_lookback_edge, initialize_LA, lalr, lalr_free): Update uses. * src/print.c: Update English in comments. (lookahead_set): Rename from look_ahead_set. (print_reduction): Rename argument lookahead_token from look_ahead_token. (print_core, state_default_rule, print_reductions, print_results): Update uses. * src/print_graph.c: Update English in comments. (print_core): Update uses. * src/state.c: Update English in comments. (reductions_new): Update uses. (state_rule_lookahead_tokens_print): Rename from state_rule_look_ahead_tokens_print, and update other uses. * src/state.h: Update English in comments. (reductions.lookahead_tokens): Rename from look_ahead_tokens. (state_rule_lookahead_tokens_print): Rename from state_rule_look_ahead_tokens_print. * src/tables.c: Update English in comments. (conflict_row, action_row): Update uses. * tests/glr-regression.at (Incorrect lookahead during deterministic GLR, Incorrect lookahead during nondeterministic GLR): Rename print_look_ahead to print_lookahead. * tests/torture.at: Update English in comments. (AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR): Rename from AT_DATA_LOOK_AHEAD_TOKENS_GRAMMAR. (Many lookahead tokens): Update uses. * data/glr.c: Update English in comments. * lalr1.cc: Likewise. * yacc.c: Likewise. * src/conflicts.h: Likewise. * src/lalr.h: Likewise. * src/main.c: Likewise. * src/output.c: Likewise. * src/parse-gram.c: Likewise. * src/tables.h: Likewise. * tests/calc.at: Likewise. --- ChangeLog | 73 +++++++++++++++++++ NEWS | 5 ++ TODO | 2 +- data/glr.c | 6 +- data/lalr1.cc | 20 +++--- data/yacc.c | 24 +++---- doc/bison.1 | 2 +- doc/bison.texinfo | 152 ++++++++++++++++++++-------------------- src/conflicts.c | 60 ++++++++-------- src/conflicts.h | 2 +- src/getargs.c | 10 +-- src/getargs.h | 2 +- src/lalr.c | 80 ++++++++++----------- src/lalr.h | 6 +- src/main.c | 4 +- src/output.c | 2 +- src/parse-gram.c | 24 +++---- src/print.c | 62 ++++++++-------- src/print_graph.c | 8 +-- src/state.c | 16 ++--- src/state.h | 12 ++-- src/tables.c | 14 ++-- src/tables.h | 2 +- tests/calc.at | 6 +- tests/glr-regression.at | 38 +++++----- tests/torture.at | 12 ++-- 26 files changed, 361 insertions(+), 283 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c22398e..b2e037d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,76 @@ +2006-06-09 Joel E. Denny + + For consistency, use `lookahead' instead of `look-ahead' or + `look_ahead'. Discussed starting at + + and then at + . + * NEWS: For the next release, note the change to `--report'. + * TODO, doc/bison.1: Update English. + * doc/bison.texinfo: Update English. + (Understanding Your Parser, Bison Options): Document as + `--report=lookahead' rather than `--report=look-ahead'. + * src/conflicts.c: Update English in comments. + (lookahead_set): Rename from look_ahead_set. + (flush_reduce): Rename argument look_ahead_tokens to lookahead_tokens. + (resolve_sr_conflict): Rename local look_ahead_tokens to + lookahead_tokens, and update other uses. + (flush_shift, set_conflicts, conflicts_solve, count_sr_conflicts, + count_rr_conflicts, conflicts_free): Update uses. + * src/getargs.c (report_args): Move "lookahead" before alternate + spellings. + (report_types): Update uses. + (usage): For `--report' usage description, state `lookahead' spelling + rather than `look-ahead'. + * src/getargs.h (report.report_lookahead_tokens): Rename from + report_look_ahead_tokens. + * src/lalr.c: Update English in comments. + (compute_lookahead_tokens): Rename from compute_look_ahead_tokens. + (state_lookahead_tokens_count): Rename from + state_look_ahead_tokens_count. + Rename local n_look_ahead_tokens to n_lookahead_tokens. + (lookahead_tokens_print): Rename from look_ahead_tokens_print. + Rename local n_look_ahead_tokens to n_lookahead_tokens. + Update other uses. + Update English in output. + (add_lookback_edge, initialize_LA, lalr, lalr_free): Update uses. + * src/print.c: Update English in comments. + (lookahead_set): Rename from look_ahead_set. + (print_reduction): Rename argument lookahead_token from + look_ahead_token. + (print_core, state_default_rule, print_reductions, print_results): + Update uses. + * src/print_graph.c: Update English in comments. + (print_core): Update uses. + * src/state.c: Update English in comments. + (reductions_new): Update uses. + (state_rule_lookahead_tokens_print): Rename from + state_rule_look_ahead_tokens_print, and update other uses. + * src/state.h: Update English in comments. + (reductions.lookahead_tokens): Rename from look_ahead_tokens. + (state_rule_lookahead_tokens_print): Rename from + state_rule_look_ahead_tokens_print. + * src/tables.c: Update English in comments. + (conflict_row, action_row): Update uses. + * tests/glr-regression.at + (Incorrect lookahead during deterministic GLR, + Incorrect lookahead during nondeterministic GLR): Rename + print_look_ahead to print_lookahead. + * tests/torture.at: Update English in comments. + (AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR): Rename from + AT_DATA_LOOK_AHEAD_TOKENS_GRAMMAR. + (Many lookahead tokens): Update uses. + * data/glr.c: Update English in comments. + * lalr1.cc: Likewise. + * yacc.c: Likewise. + * src/conflicts.h: Likewise. + * src/lalr.h: Likewise. + * src/main.c: Likewise. + * src/output.c: Likewise. + * src/parse-gram.c: Likewise. + * src/tables.h: Likewise. + * tests/calc.at: Likewise. + 2006-06-08 Joel E. Denny * src/flex-scanner.h (yytext): Remove stray `*/' in #define. diff --git a/NEWS b/NEWS index 3dca4fe0..13eaa358 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ Bison News ---------- +Changes in version 2.3+: + +* The option `--report=look-ahead' has been changed to `--report=lookahead'. + The old spelling still works but is not documented and will be removed. + Changes in version 2.3, 2006-06-05: * GLR grammars should now use `YYRECOVERING ()' instead of `YYRECOVERING', diff --git a/TODO b/TODO index b6e1a20a..96d5d2a4 100644 --- a/TODO +++ b/TODO @@ -36,7 +36,7 @@ Catch up with yacc.c. ** GLR How would Paul like to display the conflicted actions? In particular, -what when two reductions are possible on a given look-ahead token, but one is +what when two reductions are possible on a given lookahead token, but one is part of $default. Should we make the two reductions explicit, or just keep $default? See the following point. diff --git a/data/glr.c b/data/glr.c index b872bf40..f9b2a71f 100644 --- a/data/glr.c +++ b/data/glr.c @@ -67,7 +67,7 @@ m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) # b4_lyyerror_args # ---------------- -# Same as above, but on the look-ahead, hence &yylloc instead of yylocp. +# Same as above, but on the lookahead, hence &yylloc instead of yylocp. m4_define([b4_lyyerror_args], [b4_pure_if([b4_locations_if([&yylloc, ])])dnl m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) @@ -82,7 +82,7 @@ m4_define([b4_pure_args], # b4_lpure_args # ------------- -# Same as above, but on the look-ahead, hence &yylloc instead of yylocp. +# Same as above, but on the lookahead, hence &yylloc instead of yylocp. m4_define([b4_lpure_args], [b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args]) @@ -2178,7 +2178,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) /* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP, yylval, and yylloc are the syntactic category, semantic value, and location - of the look-ahead. */ + of the lookahead. */ /*ARGSUSED*/ static void yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) { diff --git a/data/lalr1.cc b/data/lalr1.cc index abcdcd5d..b8877f82 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -156,7 +156,7 @@ b4_syncline([@oline@], [@ofile@]) /// Generate an error message. /// \param state the state where the error occurred. - /// \param tok the look-ahead token. + /// \param tok the lookahead token. virtual std::string yysyntax_error_ (int yystate]dnl b4_error_verbose_if([, int tok])[); @@ -515,7 +515,7 @@ namespace ]b4_namespace[ int ]b4_parser_class_name[::parse () { - /// Look-ahead and look-ahead in internal form. + /// Lookahead and lookahead in internal form. int yychar = yyempty_; int yytoken = 0; @@ -528,9 +528,9 @@ namespace ]b4_namespace[ int yynerrs_ = 0; int yyerrstatus_ = 0; - /// Semantic value of the look-ahead. + /// Semantic value of the lookahead. semantic_type yylval; - /// Location of the look-ahead. + /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. location yyerror_range[2]; @@ -573,12 +573,12 @@ b4_syncline([@oline@], [@ofile@])])dnl /* Backup. */ yybackup: - /* Try to take a decision without look-ahead. */ + /* Try to take a decision without lookahead. */ yyn = yypact_[yystate]; if (yyn == yypact_ninf_) goto yydefault; - /* Read a look-ahead token. */ + /* Read a lookahead token. */ if (yychar == yyempty_) { YYCDEBUG << "Reading a token: "; @@ -621,7 +621,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[; if (yyn == yyfinal_) goto yyacceptlab; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ @@ -710,7 +710,7 @@ b4_error_verbose_if([, yytoken])[)); yyerror_range[0] = yylloc; if (yyerrstatus_ == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= yyeof_) @@ -726,7 +726,7 @@ b4_error_verbose_if([, yytoken])[)); } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -788,7 +788,7 @@ b4_error_verbose_if([, yytoken])[)); yyerror_range[1] = yylloc; // Using YYLLOC is tempting, but would change the location of - // the look-ahead. YYLOC is available though. + // the lookahead. YYLOC is available though. YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); diff --git a/data/yacc.c b/data/yacc.c index 1e8fa569..02cae1fb 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -964,15 +964,15 @@ yysyntax_error (char *yyresult, int yystate, int yychar) # Declare the variables that are global, or local to YYPARSE if # pure-parser. m4_define([b4_declare_parser_variables], -[/* The look-ahead symbol. */ +[/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs;b4_locations_if([ -/* Location data for the look-ahead symbol. */ +/* Location data for the lookahead symbol. */ YYLTYPE yylloc;]) ]) m4_divert_pop([KILL])dnl# ====================== End of M4 code. @@ -997,7 +997,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param) int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ + /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ @@ -1168,16 +1168,16 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1217,7 +1217,7 @@ yybackup: if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token unless it is eof. */ @@ -1341,7 +1341,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1358,7 +1358,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1423,7 +1423,7 @@ yyerrlab1: ]b4_locations_if([[ yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc;]])[ diff --git a/doc/bison.1 b/doc/bison.1 index 5e1d962d..f6faa1fb 100644 --- a/doc/bison.1 +++ b/doc/bison.1 @@ -284,7 +284,7 @@ so that the debugging facilities are compiled. .TP .B \-\-verbose Write an extra output file containing verbose descriptions of the -parser states and what is done for each type of look-ahead token in +parser states and what is done for each type of lookahead token in that state. .sp This file also describes all the conflicts, both those resolved by diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 6c67b593..84a7dee8 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -248,7 +248,7 @@ The Lexical Analyzer Function @code{yylex} The Bison Parser Algorithm -* Look-Ahead:: Parser looks one token ahead when deciding what to do. +* Lookahead:: Parser looks one token ahead when deciding what to do. * Shift/Reduce:: Conflicts: when either shifting or reduction is valid. * Precedence:: Operator precedence works by resolving conflicts. * Contextual Precedence:: When an operator's precedence depends on context. @@ -445,7 +445,7 @@ can handle almost all context-free grammars, Bison is optimized for what are called @acronym{LALR}(1) grammars. In brief, in these grammars, it must be possible to tell how to parse any portion of an input string with just a single -token of look-ahead. Strictly speaking, that is a description of an +token of lookahead. Strictly speaking, that is a description of an @acronym{LR}(1) grammar, and @acronym{LALR}(1) involves additional restrictions that are hard to explain simply; but it is rare in actual practice to find an @@ -461,11 +461,11 @@ more information on this. 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 uniquely determined by the preceding input and a fixed, finite portion -(called a @dfn{look-ahead}) of the remaining input. A context-free +(called a @dfn{lookahead}) 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{nondeterministic}, meaning that no fixed -look-ahead always suffices to determine the next grammar rule to apply. +lookahead 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} parsing (for Generalized @acronym{LR}). Bison's @acronym{GLR} parsers @@ -746,7 +746,7 @@ merged result. In the simplest cases, you can use the @acronym{GLR} algorithm to parse grammars that are unambiguous, but fail to be @acronym{LALR}(1). -Such grammars typically require more than one symbol of look-ahead, +Such grammars typically require more than one symbol of lookahead, or (in rare cases) fall into the category of grammars in which the @acronym{LALR}(1) algorithm throws away too much information (they are in @acronym{LR}(1), but not @acronym{LALR}(1), @ref{Mystery Conflicts}). @@ -786,7 +786,7 @@ type enum = (a); valid, and more-complicated cases can come up in practical programs.) These two declarations look identical until the @samp{..} token. -With normal @acronym{LALR}(1) one-token look-ahead it is not +With normal @acronym{LALR}(1) one-token lookahead it is not possible to decide between the two forms when the identifier @samp{a} is parsed. It is, however, desirable for a parser to decide this, since in the latter case @@ -825,7 +825,7 @@ reports a syntax error as usual. The effect of all this is that the parser seems to ``guess'' the correct branch to take, or in other words, it seems to use more -look-ahead than the underlying @acronym{LALR}(1) algorithm actually allows +lookahead than the underlying @acronym{LALR}(1) algorithm actually allows for. In this example, @acronym{LALR}(2) would suffice, but also some cases that are not @acronym{LALR}(@math{k}) for any @math{k} can be handled this way. @@ -1106,13 +1106,13 @@ action in a @acronym{GLR} parser. @vindex yylloc @cindex @acronym{GLR} parsers and @code{yylloc} In any semantic action, you can examine @code{yychar} to determine the type of -the look-ahead token present at the time of the associated reduction. +the lookahead token present at the time of the associated reduction. After checking that @code{yychar} is not set to @code{YYEMPTY} or @code{YYEOF}, you can then examine @code{yylval} and @code{yylloc} to determine the -look-ahead token's semantic value and location, if any. +lookahead token's semantic value and location, if any. In a nondeferred semantic action, you can also modify any of these variables to influence syntax analysis. -@xref{Look-Ahead, ,Look-Ahead Tokens}. +@xref{Lookahead, ,Lookahead Tokens}. @findex yyclearin @cindex @acronym{GLR} parsers and @code{yyclearin} @@ -3189,7 +3189,7 @@ always refers to the @code{expr} which precedes @code{bar} in the definition of @code{foo}. @vindex yylval -It is also possible to access the semantic value of the look-ahead token, if +It is also possible to access the semantic value of the lookahead token, if any, from a semantic action. This semantic value is stored in @code{yylval}. @xref{Action Features, ,Special Features for Use in Actions}. @@ -3377,8 +3377,8 @@ Now the parser is forced to decide whether to run the mid-rule action when it has read no farther than the open-brace. In other words, it must commit to using one rule or the other, without sufficient information to do it correctly. (The open-brace token is what is called -the @dfn{look-ahead} token at this time, since the parser is still -deciding what to do about it. @xref{Look-Ahead, ,Look-Ahead Tokens}.) +the @dfn{lookahead} token at this time, since the parser is still +deciding what to do about it. @xref{Lookahead, ,Lookahead Tokens}.) You might think that you could correct the problem by putting identical actions into the two rules, like this: @@ -3551,7 +3551,7 @@ exp: @dots{} @end example @vindex yylloc -It is also possible to access the location of the look-ahead token, if any, +It is also possible to access the location of the lookahead token, if any, from a semantic action. This location is stored in @code{yylloc}. @xref{Action Features, ,Special Features for Use in Actions}. @@ -3899,7 +3899,7 @@ code. @findex %initial-action Declare that the braced @var{code} must be invoked before parsing each time @code{yyparse} is called. The @var{code} may use @code{$$} and -@code{@@$} --- initial value and location of the look-ahead --- and the +@code{@@$} --- initial value and location of the lookahead --- and the @code{%parse-param}. @end deffn @@ -3971,7 +3971,7 @@ stacked symbols popped during the first phase of error recovery, @item incoming terminals during the second phase of error recovery, @item -the current look-ahead and the entire stack (except the current +the current lookahead and the entire stack (except the current right-hand side symbols) when the parser returns immediately, and @item the start symbol, when the parser succeeds. @@ -4309,7 +4309,7 @@ The number of parser states (@pxref{Parser States}). @deffn {Directive} %verbose Write an extra output file containing verbose descriptions of the -parser states and what is done for each type of look-ahead token in +parser states and what is done for each type of lookahead token in that state. @xref{Understanding, , Understanding Your Parser}, for more information. @end deffn @@ -4857,14 +4857,14 @@ Return immediately from @code{yyparse}, indicating success. @deffn {Macro} YYBACKUP (@var{token}, @var{value}); @findex YYBACKUP Unshift a token. This macro is allowed only for rules that reduce -a single value, and only when there is no look-ahead token. +a single value, and only when there is no lookahead token. It is also disallowed in @acronym{GLR} parsers. -It installs a look-ahead token with token type @var{token} and +It installs a lookahead token with token type @var{token} and semantic value @var{value}; then it discards the value that was going to be reduced by this rule. If the macro is used when it is not valid, such as when there is -a look-ahead token already, then it reports a syntax error with +a lookahead token already, then it reports a syntax error with a message @samp{cannot back up} and performs ordinary error recovery. @@ -4873,12 +4873,12 @@ In either case, the rest of the action is not executed. @deffn {Macro} YYEMPTY @vindex YYEMPTY -Value stored in @code{yychar} when there is no look-ahead token. +Value stored in @code{yychar} when there is no lookahead token. @end deffn @deffn {Macro} YYEOF @vindex YYEOF -Value stored in @code{yychar} when the look-ahead is the end of the input +Value stored in @code{yychar} when the lookahead is the end of the input stream. @end deffn @@ -4899,16 +4899,16 @@ is recovering from a syntax error, and 0 otherwise. @end deffn @deffn {Variable} yychar -Variable containing either the look-ahead token, or @code{YYEOF} when the -look-ahead is the end of the input stream, or @code{YYEMPTY} when no look-ahead +Variable containing either the lookahead token, or @code{YYEOF} when the +lookahead is the end of the input stream, or @code{YYEMPTY} when no lookahead has been performed so the next token is not yet known. Do not modify @code{yychar} in a deferred semantic action (@pxref{GLR Semantic Actions}). -@xref{Look-Ahead, ,Look-Ahead Tokens}. +@xref{Lookahead, ,Lookahead Tokens}. @end deffn @deffn {Macro} yyclearin; -Discard the current look-ahead token. This is useful primarily in +Discard the current lookahead token. This is useful primarily in error rules. Do not invoke @code{yyclearin} in a deferred semantic action (@pxref{GLR Semantic Actions}). @@ -4922,7 +4922,7 @@ errors. This is useful primarily in error rules. @end deffn @deffn {Variable} yylloc -Variable containing the look-ahead token location when @code{yychar} is not set +Variable containing the lookahead token location when @code{yychar} is not set to @code{YYEMPTY} or @code{YYEOF}. Do not modify @code{yylloc} in a deferred semantic action (@pxref{GLR Semantic Actions}). @@ -4930,7 +4930,7 @@ Actions}). @end deffn @deffn {Variable} yylval -Variable containing the look-ahead token semantic value when @code{yychar} is +Variable containing the lookahead token semantic value when @code{yychar} is not set to @code{YYEMPTY} or @code{YYEOF}. Do not modify @code{yylval} in a deferred semantic action (@pxref{GLR Semantic Actions}). @@ -5111,7 +5111,7 @@ to a single grouping whose symbol is the grammar's start-symbol This kind of parser is known in the literature as a bottom-up parser. @menu -* Look-Ahead:: Parser looks one token ahead when deciding what to do. +* Lookahead:: Parser looks one token ahead when deciding what to do. * Shift/Reduce:: Conflicts: when either shifting or reduction is valid. * Precedence:: Operator precedence works by resolving conflicts. * Contextual Precedence:: When an operator's precedence depends on context. @@ -5122,9 +5122,9 @@ This kind of parser is known in the literature as a bottom-up parser. * Memory Management:: What happens when memory is exhausted. How to avoid it. @end menu -@node Look-Ahead -@section Look-Ahead Tokens -@cindex look-ahead token +@node Lookahead +@section Lookahead Tokens +@cindex lookahead token The Bison parser does @emph{not} always reduce immediately as soon as the last @var{n} tokens and groupings match a rule. This is because such a @@ -5133,15 +5133,15 @@ reduction is possible, the parser sometimes ``looks ahead'' at the next token in order to decide what to do. When a token is read, it is not immediately shifted; first it becomes the -@dfn{look-ahead token}, which is not on the stack. Now the parser can +@dfn{lookahead token}, which is not on the stack. Now the parser can perform one or more reductions of tokens and groupings on the stack, while -the look-ahead token remains off to the side. When no more reductions -should take place, the look-ahead token is shifted onto the stack. This +the lookahead token remains off to the side. When no more reductions +should take place, the lookahead token is shifted onto the stack. This does not mean that all possible reductions have been done; depending on the -token type of the look-ahead token, some rules may choose to delay their +token type of the lookahead token, some rules may choose to delay their application. -Here is a simple case where look-ahead is needed. These three rules define +Here is a simple case where lookahead is needed. These three rules define expressions which contain binary addition operators and postfix unary factorial operators (@samp{!}), and allow parentheses for grouping. @@ -5176,7 +5176,7 @@ doing so would produce on the stack the sequence of symbols @code{expr @vindex yychar @vindex yylval @vindex yylloc -The look-ahead token is stored in the variable @code{yychar}. +The lookahead token is stored in the variable @code{yychar}. Its semantic value and location, if any, are stored in the variables @code{yylval} and @code{yylloc}. @xref{Action Features, ,Special Features for Use in Actions}. @@ -5204,7 +5204,7 @@ if_stmt: Here we assume that @code{IF}, @code{THEN} and @code{ELSE} are terminal symbols for specific keyword tokens. -When the @code{ELSE} token is read and becomes the look-ahead token, the +When the @code{ELSE} token is read and becomes the lookahead token, the contents of the stack (assuming the input is valid) are just right for reduction by the first rule. But it is also legitimate to shift the @code{ELSE}, because that would lead to eventual reduction by the second @@ -5338,7 +5338,7 @@ operators we prefer the former, which is called @dfn{left association}. The latter alternative, @dfn{right association}, is desirable for assignment operators. The choice of left or right association is a matter of whether the parser chooses to shift or reduce when the stack -contains @w{@samp{1 - 2}} and the look-ahead token is @samp{-}: shifting +contains @w{@samp{1 - 2}} and the lookahead token is @samp{-}: shifting makes right-associativity. @node Using Precedence @@ -5399,7 +5399,7 @@ specify explicitly the precedence of a rule. @xref{Contextual Precedence, ,Context-Dependent Precedence}.) Finally, the resolution of conflicts works by comparing the precedence -of the rule being considered with that of the look-ahead token. If the +of the rule being considered with that of the lookahead token. If the token's precedence is higher, the choice is to shift. If the rule's precedence is higher, the choice is to reduce. If they have equal precedence, the choice is made based on the associativity of that @@ -5408,7 +5408,7 @@ precedence level. The verbose output file made by @samp{-v} resolved. Not all rules and not all tokens have precedence. If either the rule or -the look-ahead token has no precedence, then the default is to shift. +the lookahead token has no precedence, then the default is to shift. @node Contextual Precedence @section Context-Dependent Precedence @@ -5502,9 +5502,9 @@ represent the entire sequence of terminal and nonterminal symbols at or near the top of the stack. The current state collects all the information about previous input which is relevant to deciding what to do next. -Each time a look-ahead token is read, the current parser state together -with the type of look-ahead token are looked up in a table. This table -entry can say, ``Shift the look-ahead token.'' In this case, it also +Each time a lookahead token is read, the current parser state together +with the type of lookahead token are looked up in a table. This table +entry can say, ``Shift the lookahead token.'' In this case, it also specifies the new parser state, which is pushed onto the top of the parser stack. Or it can say, ``Reduce using rule number @var{n}.'' This means that a certain number of tokens or groupings are taken off @@ -5512,7 +5512,7 @@ the top of the stack, and replaced by one grouping. In other words, that number of states are popped from the stack, and one new state is pushed. -There is one other alternative: the table can say that the look-ahead token +There is one other alternative: the table can say that the lookahead token is erroneous in the current state. This causes error processing to begin (@pxref{Error Recovery}). @@ -5670,7 +5670,7 @@ name_list: @end example It would seem that this grammar can be parsed with only a single token -of look-ahead: when a @code{param_spec} is being read, an @code{ID} is +of lookahead: when a @code{param_spec} is being read, an @code{ID} is a @code{name} if a comma or colon follows, or a @code{type} if another @code{ID} follows. In other words, this grammar is @acronym{LR}(1). @@ -5684,7 +5684,7 @@ a @code{return_spec}, are similar enough that Bison assumes they are the same. They appear similar because the same set of rules would be active---the rule for reducing to a @code{name} and that for reducing to a @code{type}. Bison is unable to determine at that stage of processing -that the rules would require different look-ahead tokens in the two +that the rules would require different lookahead tokens in the two contexts, so it makes a single parser state for them both. Combining the two contexts causes a conflict later. In parser terminology, this occurrence means that the grammar is not @acronym{LALR}(1). @@ -5757,13 +5757,13 @@ pp.@: 615--649 @uref{http://doi.acm.org/10.1145/69622.357187}. Bison produces @emph{deterministic} parsers that choose uniquely when to reduce and which reduction to apply -based on a summary of the preceding input and on one extra token of look-ahead. +based on a summary of the preceding input and on one extra token of lookahead. As a result, normal Bison handles a proper subset of the family of context-free languages. Ambiguous grammars, since they have strings with more than one possible sequence of reductions cannot have deterministic parsers in this sense. The same is true of languages that require more than one symbol of -look-ahead, since the parser lacks the information necessary to make a +lookahead, since the parser lacks the information necessary to make a decision at the point it must be made in a shift-reduce parser. Finally, as previously mentioned (@pxref{Mystery Conflicts}), there are languages where Bison's particular choice of how to @@ -5940,7 +5940,7 @@ and objects from the stack until it gets back to a state in which the @code{error} token is acceptable. (This means that the subexpressions already parsed are discarded, back to the last complete @code{stmnts}.) At this point the @code{error} token can be shifted. Then, if the old -look-ahead token is not acceptable to be shifted next, the parser reads +lookahead token is not acceptable to be shifted next, the parser reads tokens and discards them until it finds a token which is acceptable. In this example, Bison reads and discards input until the next newline so that the fourth rule can apply. Note that discarded symbols are @@ -5991,7 +5991,7 @@ error messages will be suppressed. This macro requires no arguments; @samp{yyerrok;} is a valid C statement. @findex yyclearin -The previous look-ahead token is reanalyzed immediately after an error. If +The previous lookahead token is reanalyzed immediately after an error. If this is unacceptable, then the macro @code{yyclearin} may be used to clear this token. Write the statement @samp{yyclearin;} in the error rule's action. @@ -6000,7 +6000,7 @@ action. For example, suppose that on a syntax error, an error handling routine is called that advances the input stream to some point where parsing should once again commence. The next symbol returned by the lexical scanner is -probably correct. The previous look-ahead token ought to be discarded +probably correct. The previous lookahead token ought to be discarded with @samp{yyclearin;}. @vindex YYRECOVERING @@ -6388,16 +6388,16 @@ beginning of the parsing, in the initial rule, right before the start symbol (here, @code{exp}). When the parser returns to this state right after having reduced a rule that produced an @code{exp}, the control flow jumps to state 2. If there is no such transition on a nonterminal -symbol, and the look-ahead is a @code{NUM}, then this token is shifted on +symbol, and the lookahead is a @code{NUM}, then this token is shifted on the parse stack, and the control flow jumps to state 1. Any other -look-ahead triggers a syntax error.'' +lookahead triggers a syntax error.'' @cindex core, item set @cindex item set core @cindex kernel, item set @cindex item set core Even though the only active rule in state 0 seems to be rule 0, the -report lists @code{NUM} as a look-ahead token because @code{NUM} can be +report lists @code{NUM} as a lookahead token because @code{NUM} can be at the beginning of any rule deriving an @code{exp}. By default Bison reports the so-called @dfn{core} or @dfn{kernel} of the item set, but if you want to see more detail you can invoke @command{bison} with @@ -6431,7 +6431,7 @@ state 1 @end example @noindent -the rule 5, @samp{exp: NUM;}, is completed. Whatever the look-ahead token +the rule 5, @samp{exp: NUM;}, is completed. Whatever the lookahead token (@samp{$default}), the parser will reduce it. If it was coming from state 0, then, after this reduction it will return to state 0, and will jump to state 2 (@samp{exp: go to state 2}). @@ -6454,7 +6454,7 @@ state 2 @noindent In state 2, the automaton can only shift a symbol. For instance, -because of the item @samp{exp -> exp . '+' exp}, if the look-ahead if +because of the item @samp{exp -> exp . '+' exp}, if the lookahead if @samp{+}, it will be shifted on the parse stack, and the automaton control will jump to state 4, corresponding to the item @samp{exp -> exp '+' . exp}. Since there is no default action, any other token than @@ -6531,7 +6531,7 @@ state 8 $default reduce using rule 1 (exp) @end example -Indeed, there are two actions associated to the look-ahead @samp{/}: +Indeed, there are two actions associated to the lookahead @samp{/}: either shifting (and going to state 7), or reducing rule 1. The conflict means that either the grammar is ambiguous, or the parser lacks information to make the right decision. Indeed the grammar is @@ -6549,14 +6549,14 @@ Note that all the previous states had a single possible action: either shifting the next token and going to the corresponding state, or reducing a single rule. In the other cases, i.e., when shifting @emph{and} reducing is possible or when @emph{several} reductions are -possible, the look-ahead is required to select the action. State 8 is -one such state: if the look-ahead is @samp{*} or @samp{/} then the action +possible, the lookahead is required to select the action. State 8 is +one such state: if the lookahead is @samp{*} or @samp{/} then the action is shifting, otherwise the action is reducing rule 1. In other words, the first two items, corresponding to rule 1, are not eligible when the -look-ahead token is @samp{*}, since we specified that @samp{*} has higher +lookahead token is @samp{*}, since we specified that @samp{*} has higher precedence than @samp{+}. More generally, some items are eligible only -with some set of possible look-ahead tokens. When run with -@option{--report=look-ahead}, Bison specifies these look-ahead tokens: +with some set of possible lookahead tokens. When run with +@option{--report=lookahead}, Bison specifies these lookahead tokens: @example state 8 @@ -6914,9 +6914,9 @@ separated list of @var{things} among: Description of the grammar, conflicts (resolved and unresolved), and @acronym{LALR} automaton. -@item look-ahead +@item lookahead Implies @code{state} and augments the description of the automaton with -each rule's look-ahead set. +each rule's lookahead set. @item itemset Implies @code{state} and augments the description of the automaton with @@ -8207,8 +8207,8 @@ A token name reserved for error recovery. This token may be used in grammar rules so as to allow the Bison parser to recognize an error in the grammar without halting the process. In effect, a sentence containing an error may be recognized as valid. On a syntax error, the -token @code{error} becomes the current look-ahead token. Actions -corresponding to @code{error} are then executed, and the look-ahead +token @code{error} becomes the current lookahead token. Actions +corresponding to @code{error} are then executed, and the lookahead token is reset to the token that originally caused the violation. @xref{Error Recovery}. @end deffn @@ -8348,20 +8348,20 @@ read, by making @code{yyparse} return 0 immediately. @end deffn @deffn {Macro} YYBACKUP -Macro to discard a value from the parser stack and fake a look-ahead +Macro to discard a value from the parser stack and fake a lookahead token. @xref{Action Features, ,Special Features for Use in Actions}. @end deffn @deffn {Variable} yychar External integer variable that contains the integer value of the -look-ahead token. (In a pure parser, it is a local variable within +lookahead token. (In a pure parser, it is a local variable within @code{yyparse}.) Error-recovery rule actions may examine this variable. @xref{Action Features, ,Special Features for Use in Actions}. @end deffn @deffn {Variable} yyclearin Macro used in error-recovery rule actions. It clears the previous -look-ahead token. @xref{Error Recovery}. +lookahead token. @xref{Error Recovery}. @end deffn @deffn {Macro} YYDEBUG @@ -8427,7 +8427,7 @@ variable within @code{yyparse}, and its address is passed to You can ignore this variable if you don't use the @samp{@@} feature in the grammar actions. @xref{Token Locations, ,Textual Locations of Tokens}. -In semantic actions, it stores the location of the look-ahead token. +In semantic actions, it stores the location of the lookahead token. @xref{Actions and Locations, ,Actions and Locations}. @end deffn @@ -8442,7 +8442,7 @@ value associated with a token. (In a pure parser, it is a local variable within @code{yyparse}, and its address is passed to @code{yylex}.) @xref{Token Values, ,Semantic Values of Tokens}. -In semantic actions, it stores the semantic value of the look-ahead token. +In semantic actions, it stores the semantic value of the lookahead token. @xref{Actions, ,Actions}. @end deffn @@ -8582,8 +8582,8 @@ tokens are parsed. @xref{Lexical Tie-ins}. @item Literal string token A token which consists of two or more fixed characters. @xref{Symbols}. -@item Look-ahead token -A token already read but not yet shifted. @xref{Look-Ahead, ,Look-Ahead +@item Lookahead token +A token already read but not yet shifted. @xref{Lookahead, ,Lookahead Tokens}. @item @acronym{LALR}(1) @@ -8593,7 +8593,7 @@ Conflicts, ,Mysterious Reduce/Reduce Conflicts}. @item @acronym{LR}(1) The class of context-free grammars in which at most one token of -look-ahead is needed to disambiguate the parsing of any piece of input. +lookahead is needed to disambiguate the parsing of any piece of input. @item Nonterminal symbol A grammar symbol standing for a grammatical construct that can diff --git a/src/conflicts.c b/src/conflicts.c index 13121f6e..7bb3e08e 100644 --- a/src/conflicts.c +++ b/src/conflicts.c @@ -1,4 +1,4 @@ -/* Find and resolve or report look-ahead conflicts for bison, +/* Find and resolve or report lookahead conflicts for bison, Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -43,7 +43,7 @@ static char *conflicts; static struct obstack solved_conflicts_obstack; static bitset shift_set; -static bitset look_ahead_set; +static bitset lookahead_set; @@ -147,7 +147,7 @@ flush_shift (state *s, int token) transitions *trans = s->transitions; int i; - bitset_reset (look_ahead_set, token); + bitset_reset (lookahead_set, token); for (i = 0; i < trans->num; i++) if (!TRANSITION_IS_DISABLED (trans, i) && TRANSITION_SYMBOL (trans, i) == token) @@ -157,14 +157,14 @@ flush_shift (state *s, int token) /*--------------------------------------------------------------------. | Turn off the reduce recorded for the specified token for the | -| specified look-ahead. Used when we resolve a shift-reduce conflict | +| specified lookahead. Used when we resolve a shift-reduce conflict | | in favor of the shift. | `--------------------------------------------------------------------*/ static void -flush_reduce (bitset look_ahead_tokens, int token) +flush_reduce (bitset lookahead_tokens, int token) { - bitset_reset (look_ahead_tokens, token); + bitset_reset (lookahead_tokens, token); } @@ -174,7 +174,7 @@ flush_reduce (bitset look_ahead_tokens, int token) | rule has a precedence. A conflict is resolved by modifying the | | shift or reduce tables so that there is no longer a conflict. | | | -| RULENO is the number of the look-ahead bitset to consider. | +| RULENO is the number of the lookahead bitset to consider. | | | | ERRORS can be used to store discovered explicit errors. | `------------------------------------------------------------------*/ @@ -187,12 +187,12 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors) /* Find the rule to reduce by to get precedence of reduction. */ rule *redrule = reds->rules[ruleno]; int redprec = redrule->prec->prec; - bitset look_ahead_tokens = reds->look_ahead_tokens[ruleno]; + bitset lookahead_tokens = reds->lookahead_tokens[ruleno]; int nerrs = 0; for (i = 0; i < ntokens; i++) - if (bitset_test (look_ahead_tokens, i) - && bitset_test (look_ahead_set, i) + if (bitset_test (lookahead_tokens, i) + && bitset_test (lookahead_set, i) && symbols[i]->prec) { /* Shift-reduce conflict occurs for token number i @@ -206,7 +206,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors) else if (symbols[i]->prec > redprec) { log_resolution (redrule, i, shift_resolution); - flush_reduce (look_ahead_tokens, i); + flush_reduce (lookahead_tokens, i); } else /* Matching precedence levels. @@ -221,7 +221,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors) case right_assoc: log_resolution (redrule, i, right_resolution); - flush_reduce (look_ahead_tokens, i); + flush_reduce (lookahead_tokens, i); break; case left_assoc: @@ -232,7 +232,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors) case non_assoc: log_resolution (redrule, i, nonassoc_resolution); flush_shift (s, i); - flush_reduce (look_ahead_tokens, i); + flush_reduce (lookahead_tokens, i); /* Record an explicit error for this token. */ errors[nerrs++] = symbols[i]; break; @@ -258,7 +258,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors) | Solve the S/R conflicts of state S using the | | precedence/associativity, and flag it inconsistent if it still has | | conflicts. ERRORS can be used as storage to compute the list of | -| look-ahead tokens on which S raises a syntax error (%nonassoc). | +| lookahead tokens on which S raises a syntax error (%nonassoc). | `-------------------------------------------------------------------*/ static void @@ -271,27 +271,27 @@ set_conflicts (state *s, symbol **errors) if (s->consistent) return; - bitset_zero (look_ahead_set); + bitset_zero (lookahead_set); FOR_EACH_SHIFT (trans, i) - bitset_set (look_ahead_set, TRANSITION_SYMBOL (trans, i)); + bitset_set (lookahead_set, TRANSITION_SYMBOL (trans, i)); - /* Loop over all rules which require look-ahead in this state. First + /* Loop over all rules which require lookahead in this state. First check for shift-reduce conflict, and try to resolve using precedence. */ for (i = 0; i < reds->num; ++i) if (reds->rules[i]->prec && reds->rules[i]->prec->prec - && !bitset_disjoint_p (reds->look_ahead_tokens[i], look_ahead_set)) + && !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set)) resolve_sr_conflict (s, i, errors); - /* Loop over all rules which require look-ahead in this state. Check + /* Loop over all rules which require lookahead in this state. Check for conflicts not resolved above. */ for (i = 0; i < reds->num; ++i) { - if (!bitset_disjoint_p (reds->look_ahead_tokens[i], look_ahead_set)) + if (!bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set)) conflicts[s->number] = 1; - bitset_or (look_ahead_set, look_ahead_set, reds->look_ahead_tokens[i]); + bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]); } } @@ -305,12 +305,12 @@ void conflicts_solve (void) { state_number i; - /* List of look-ahead tokens on which we explicitly raise a syntax error. */ + /* List of lookahead tokens on which we explicitly raise a syntax error. */ symbol **errors = xnmalloc (ntokens + 1, sizeof *errors); conflicts = xcalloc (nstates, sizeof *conflicts); shift_set = bitset_create (ntokens, BITSET_FIXED); - look_ahead_set = bitset_create (ntokens, BITSET_FIXED); + lookahead_set = bitset_create (ntokens, BITSET_FIXED); obstack_init (&solved_conflicts_obstack); for (i = 0; i < nstates; i++) @@ -342,18 +342,18 @@ count_sr_conflicts (state *s) if (!trans) return 0; - bitset_zero (look_ahead_set); + bitset_zero (lookahead_set); bitset_zero (shift_set); FOR_EACH_SHIFT (trans, i) bitset_set (shift_set, TRANSITION_SYMBOL (trans, i)); for (i = 0; i < reds->num; ++i) - bitset_or (look_ahead_set, look_ahead_set, reds->look_ahead_tokens[i]); + bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]); - bitset_and (look_ahead_set, look_ahead_set, shift_set); + bitset_and (lookahead_set, lookahead_set, shift_set); - src_count = bitset_count (look_ahead_set); + src_count = bitset_count (lookahead_set); return src_count; } @@ -378,7 +378,7 @@ count_rr_conflicts (state *s, bool one_per_token) int count = 0; int j; for (j = 0; j < reds->num; ++j) - if (bitset_test (reds->look_ahead_tokens[j], i)) + if (bitset_test (reds->lookahead_tokens[j], i)) count++; if (count >= 2) @@ -433,7 +433,7 @@ conflicts_output (FILE *out) /*--------------------------------------------------------. | Total the number of S/R and R/R conflicts. Unlike the | | code in conflicts_output, however, count EACH pair of | -| reductions for the same state and look-ahead as one | +| reductions for the same state and lookahead as one | | conflict. | `--------------------------------------------------------*/ @@ -530,6 +530,6 @@ conflicts_free (void) { free (conflicts); bitset_free (shift_set); - bitset_free (look_ahead_set); + bitset_free (lookahead_set); obstack_free (&solved_conflicts_obstack, NULL); } diff --git a/src/conflicts.h b/src/conflicts.h index 4389e5ec..2b8df518 100644 --- a/src/conflicts.h +++ b/src/conflicts.h @@ -1,4 +1,4 @@ -/* Find and resolve or report look-ahead conflicts for bison, +/* Find and resolve or report lookahead conflicts for bison, Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. diff --git a/src/getargs.c b/src/getargs.c index c1027d3b..ec861eb0 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -145,7 +145,7 @@ static const char * const report_args[] = "none", "state", "states", "itemset", "itemsets", - "look-ahead", "lookahead", "lookaheads", + "lookahead", "lookaheads", "look-ahead", "solved", "all", 0 @@ -156,9 +156,9 @@ static const int report_types[] = report_none, report_states, report_states, report_states | report_itemsets, report_states | report_itemsets, - report_states | report_look_ahead_tokens, - report_states | report_look_ahead_tokens, - report_states | report_look_ahead_tokens, + report_states | report_lookahead_tokens, + report_states | report_lookahead_tokens, + report_states | report_lookahead_tokens, report_states | report_solved_conflicts, report_all }; @@ -247,7 +247,7 @@ Output:\n\ THINGS is a list of comma separated words that can include:\n\ `state' describe the states\n\ `itemset' complete the core item sets with their closure\n\ - `look-ahead' explicitly associate look-ahead tokens to items\n\ + `lookahead' explicitly associate lookahead tokens to items\n\ `solved' describe shift/reduce conflicts solving\n\ `all' include all the above information\n\ `none' disable the report\n\ diff --git a/src/getargs.h b/src/getargs.h index 816eb956..2d764cba 100644 --- a/src/getargs.h +++ b/src/getargs.h @@ -84,7 +84,7 @@ enum report report_none = 0, report_states = 1 << 0, report_itemsets = 1 << 1, - report_look_ahead_tokens= 1 << 2, + report_lookahead_tokens = 1 << 2, report_solved_conflicts = 1 << 3, report_all = ~0 }; diff --git a/src/lalr.c b/src/lalr.c index 65c55ab7..e7f51455 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -1,4 +1,4 @@ -/* Compute look-ahead criteria for Bison. +/* Compute lookahead criteria for Bison. Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -22,7 +22,7 @@ /* Compute how to make the finite state machine deterministic; find - which rules need look-ahead in each state, and which look-ahead + which rules need lookahead in each state, and which lookahead tokens they accept. */ #include @@ -219,9 +219,9 @@ add_lookback_edge (state *s, rule *r, goto_number gotono) { int ri = state_reduction_find (s, r); goto_list *sp = xmalloc (sizeof *sp); - sp->next = lookback[(s->reductions->look_ahead_tokens - LA) + ri]; + sp->next = lookback[(s->reductions->lookahead_tokens - LA) + ri]; sp->value = gotono; - lookback[(s->reductions->look_ahead_tokens - LA) + ri] = sp; + lookback[(s->reductions->lookahead_tokens - LA) + ri] = sp; } @@ -314,7 +314,7 @@ compute_FOLLOWS (void) static void -compute_look_ahead_tokens (void) +compute_lookahead_tokens (void) { size_t i; goto_list *sp; @@ -332,27 +332,27 @@ compute_look_ahead_tokens (void) } -/*-----------------------------------------------------. -| Count the number of look-ahead tokens required for S | -| (N_LOOK_AHEAD_TOKENS member). | -`-----------------------------------------------------*/ +/*----------------------------------------------------. +| Count the number of lookahead tokens required for S | +| (N_LOOKAHEAD_TOKENS member). | +`----------------------------------------------------*/ static int -state_look_ahead_tokens_count (state *s) +state_lookahead_tokens_count (state *s) { int k; - int n_look_ahead_tokens = 0; + int n_lookahead_tokens = 0; reductions *rp = s->reductions; transitions *sp = s->transitions; - /* We need a look-ahead either to distinguish different + /* We need a lookahead either to distinguish different reductions (i.e., there are two or more), or to distinguish a reduction from a shift. Otherwise, it is straightforward, and the state is `consistent'. */ if (rp->num > 1 || (rp->num == 1 && sp->num && !TRANSITION_IS_DISABLED (sp, 0) && TRANSITION_IS_SHIFT (sp, 0))) - n_look_ahead_tokens += rp->num; + n_lookahead_tokens += rp->num; else s->consistent = 1; @@ -363,13 +363,13 @@ state_look_ahead_tokens_count (state *s) break; } - return n_look_ahead_tokens; + return n_lookahead_tokens; } -/*-----------------------------------------------------. -| Compute LA, NLA, and the look_ahead_tokens members. | -`-----------------------------------------------------*/ +/*----------------------------------------------------. +| Compute LA, NLA, and the lookahead_tokens members. | +`----------------------------------------------------*/ static void initialize_LA (void) @@ -377,10 +377,10 @@ initialize_LA (void) state_number i; bitsetv pLA; - /* Compute the total number of reductions requiring a look-ahead. */ + /* Compute the total number of reductions requiring a lookahead. */ nLA = 0; for (i = 0; i < nstates; i++) - nLA += state_look_ahead_tokens_count (states[i]); + nLA += state_lookahead_tokens_count (states[i]); /* Avoid having to special case 0. */ if (!nLA) nLA = 1; @@ -388,54 +388,54 @@ initialize_LA (void) pLA = LA = bitsetv_create (nLA, ntokens, BITSET_FIXED); lookback = xcalloc (nLA, sizeof *lookback); - /* Initialize the members LOOK_AHEAD_TOKENS for each state whose reductions - require look-ahead tokens. */ + /* Initialize the members LOOKAHEAD_TOKENS for each state whose reductions + require lookahead tokens. */ for (i = 0; i < nstates; i++) { - int count = state_look_ahead_tokens_count (states[i]); + int count = state_lookahead_tokens_count (states[i]); if (count) { - states[i]->reductions->look_ahead_tokens = pLA; + states[i]->reductions->lookahead_tokens = pLA; pLA += count; } } } -/*----------------------------------------------. -| Output the look-ahead tokens for each state. | -`----------------------------------------------*/ +/*---------------------------------------------. +| Output the lookahead tokens for each state. | +`---------------------------------------------*/ static void -look_ahead_tokens_print (FILE *out) +lookahead_tokens_print (FILE *out) { state_number i; int j, k; - fprintf (out, "Look-ahead tokens: BEGIN\n"); + fprintf (out, "Lookahead tokens: BEGIN\n"); for (i = 0; i < nstates; ++i) { reductions *reds = states[i]->reductions; bitset_iterator iter; - int n_look_ahead_tokens = 0; + int n_lookahead_tokens = 0; - if (reds->look_ahead_tokens) + if (reds->lookahead_tokens) for (k = 0; k < reds->num; ++k) - if (reds->look_ahead_tokens[k]) - ++n_look_ahead_tokens; + if (reds->lookahead_tokens[k]) + ++n_lookahead_tokens; - fprintf (out, "State %d: %d look-ahead tokens\n", - i, n_look_ahead_tokens); + fprintf (out, "State %d: %d lookahead tokens\n", + i, n_lookahead_tokens); - if (reds->look_ahead_tokens) + if (reds->lookahead_tokens) for (j = 0; j < reds->num; ++j) - BITSET_FOR_EACH (iter, reds->look_ahead_tokens[j], k, 0) + BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0) { fprintf (out, " on %d (%s) -> rule %d\n", k, symbols[k]->tag, reds->rules[j]->number); }; } - fprintf (out, "Look-ahead tokens: END\n"); + fprintf (out, "Lookahead tokens: END\n"); } void @@ -446,10 +446,10 @@ lalr (void) initialize_F (); build_relations (); compute_FOLLOWS (); - compute_look_ahead_tokens (); + compute_lookahead_tokens (); if (trace_flag & trace_sets) - look_ahead_tokens_print (stderr); + lookahead_tokens_print (stderr); } @@ -458,6 +458,6 @@ lalr_free (void) { state_number s; for (s = 0; s < nstates; ++s) - states[s]->reductions->look_ahead_tokens = NULL; + states[s]->reductions->lookahead_tokens = NULL; bitsetv_free (LA); } diff --git a/src/lalr.h b/src/lalr.h index a2c17537..af875d10 100644 --- a/src/lalr.h +++ b/src/lalr.h @@ -1,4 +1,4 @@ -/* Compute look-ahead criteria for bison, +/* Compute lookahead criteria for bison, Copyright (C) 1984, 1986, 1989, 2000, 2002, 2004 Free Software Foundation, Inc. @@ -33,12 +33,12 @@ # include "state.h" /* Compute how to make the finite state machine deterministic; find - which rules need look-ahead in each state, and which look-ahead + which rules need lookahead in each state, and which lookahead tokens they accept. */ void lalr (void); -/* Release the information related to look-ahead tokens. Can be performed +/* Release the information related to lookahead tokens. Can be performed once the action tables are computed. */ void lalr_free (void); diff --git a/src/main.c b/src/main.c index acf139d2..69e72fec 100644 --- a/src/main.c +++ b/src/main.c @@ -110,7 +110,7 @@ main (int argc, char *argv[]) timevar_pop (TV_LALR); /* Find and record any conflicts: places where one token of - look-ahead is not enough to disambiguate the parsing. In file + lookahead is not enough to disambiguate the parsing. In file conflicts. Also resolve s/r conflicts based on precedence declarations. */ timevar_push (TV_CONFLICTS); @@ -150,7 +150,7 @@ main (int argc, char *argv[]) if (complaint_issued) goto finish; - /* Look-ahead tokens are no longer needed. */ + /* Lookahead tokens are no longer needed. */ timevar_push (TV_FREE); lalr_free (); timevar_pop (TV_FREE); diff --git a/src/output.c b/src/output.c index 1391959a..4e7b5bf3 100644 --- a/src/output.c +++ b/src/output.c @@ -448,7 +448,7 @@ static void prepare_actions (void) { /* Figure out the actions for the specified state, indexed by - look-ahead token type. */ + lookahead token type. */ muscle_insert_rule_number_table ("defact", yydefact, yydefact[0], 1, nstates); diff --git a/src/parse-gram.c b/src/parse-gram.c index 00c39a5f..e9b7900d 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1456,15 +1456,15 @@ yyparse () #endif #endif { - /* The look-ahead symbol. */ + /* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; -/* Location data for the look-ahead symbol. */ +/* Location data for the lookahead symbol. */ YYLTYPE yylloc; int yystate; @@ -1472,7 +1472,7 @@ YYLTYPE yylloc; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ + /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ @@ -1640,16 +1640,16 @@ YYLTYPE yylloc; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1689,7 +1689,7 @@ yybackup: if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token unless it is eof. */ @@ -2216,7 +2216,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -2233,7 +2233,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -2298,7 +2298,7 @@ yyerrlab1: yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; diff --git a/src/print.c b/src/print.c index cb1600c9..82e78161 100644 --- a/src/print.c +++ b/src/print.c @@ -40,7 +40,7 @@ #include "symtab.h" static bitset shift_set; -static bitset look_ahead_set; +static bitset lookahead_set; #if 0 static void @@ -111,9 +111,9 @@ print_core (FILE *out, state *s) for (/* Nothing */; *sp >= 0; ++sp) fprintf (out, " %s", symbols[*sp]->tag); - /* Display the look-ahead tokens? */ - if (report_flag & report_look_ahead_tokens) - state_rule_look_ahead_tokens_print (s, &rules[r], out); + /* Display the lookahead tokens? */ + if (report_flag & report_lookahead_tokens) + state_rule_lookahead_tokens_print (s, &rules[r], out); fputc ('\n', out); } @@ -132,7 +132,7 @@ print_transitions (state *s, FILE *out, bool display_transitions_p) size_t width = 0; int i; - /* Compute the width of the look-ahead token column. */ + /* Compute the width of the lookahead token column. */ for (i = 0; i < trans->num; i++) if (!TRANSITION_IS_DISABLED (trans, i) && TRANSITION_IS_SHIFT (trans, i) == display_transitions_p) @@ -148,7 +148,7 @@ print_transitions (state *s, FILE *out, bool display_transitions_p) fputc ('\n', out); width += 2; - /* Report look-ahead tokens and shifts. */ + /* Report lookahead tokens and shifts. */ for (i = 0; i < trans->num; i++) if (!TRANSITION_IS_DISABLED (trans, i) && TRANSITION_IS_SHIFT (trans, i) == display_transitions_p) @@ -180,7 +180,7 @@ print_errs (FILE *out, state *s) size_t width = 0; int i; - /* Compute the width of the look-ahead token column. */ + /* Compute the width of the lookahead token column. */ for (i = 0; i < errp->num; ++i) if (errp->symbols[i]) max_length (&width, errp->symbols[i]->tag); @@ -192,7 +192,7 @@ print_errs (FILE *out, state *s) fputc ('\n', out); width += 2; - /* Report look-ahead tokens and errors. */ + /* Report lookahead tokens and errors. */ for (i = 0; i < errp->num; ++i) if (errp->symbols[i]) { @@ -218,11 +218,11 @@ state_default_rule (state *s) int cmax = 0; int i; - /* No need for a look-ahead. */ + /* No need for a lookahead. */ if (s->consistent) return reds->rules[0]; - /* 1. Each reduction is possibly masked by the look-ahead tokens on which + /* 1. Each reduction is possibly masked by the lookahead tokens on which we shift (S/R conflicts)... */ bitset_zero (shift_set); { @@ -237,7 +237,7 @@ state_default_rule (state *s) } } - /* 2. Each reduction is possibly masked by the look-ahead tokens on which + /* 2. Each reduction is possibly masked by the lookahead tokens on which we raise an error (due to %nonassoc). */ { errs *errp = s->errs; @@ -250,10 +250,10 @@ state_default_rule (state *s) { int count = 0; - /* How many non-masked look-ahead tokens are there for this + /* How many non-masked lookahead tokens are there for this reduction? */ - bitset_andn (look_ahead_set, reds->look_ahead_tokens[i], shift_set); - count = bitset_count (look_ahead_set); + bitset_andn (lookahead_set, reds->lookahead_tokens[i], shift_set); + count = bitset_count (lookahead_set); if (count > cmax) { @@ -264,27 +264,27 @@ state_default_rule (state *s) /* 3. And finally, each reduction is possibly masked by previous reductions (in R/R conflicts, we keep the first reductions). */ - bitset_or (shift_set, shift_set, reds->look_ahead_tokens[i]); + bitset_or (shift_set, shift_set, reds->lookahead_tokens[i]); } return default_rule; } -/*--------------------------------------------------------------------------. -| Report a reduction of RULE on LOOK_AHEAD_TOKEN (which can be `default'). | -| If not ENABLED, the rule is masked by a shift or a reduce (S/R and | -| R/R conflicts). | -`--------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------. +| Report a reduction of RULE on LOOKAHEAD_TOKEN (which can be `default'). | +| If not ENABLED, the rule is masked by a shift or a reduce (S/R and | +| R/R conflicts). | +`-------------------------------------------------------------------------*/ static void print_reduction (FILE *out, size_t width, - const char *look_ahead_token, + const char *lookahead_token, rule *r, bool enabled) { int j; - fprintf (out, " %s", look_ahead_token); - for (j = width - strlen (look_ahead_token); j > 0; --j) + fprintf (out, " %s", lookahead_token); + for (j = width - strlen (lookahead_token); j > 0; --j) fputc (' ', out); if (!enabled) fputc ('[', out); @@ -320,17 +320,17 @@ print_reductions (FILE *out, state *s) FOR_EACH_SHIFT (trans, i) bitset_set (shift_set, TRANSITION_SYMBOL (trans, i)); - /* Compute the width of the look-ahead token column. */ + /* Compute the width of the lookahead token column. */ if (default_rule) width = strlen (_("$default")); - if (reds->look_ahead_tokens) + if (reds->lookahead_tokens) for (i = 0; i < ntokens; i++) { bool count = bitset_test (shift_set, i); for (j = 0; j < reds->num; ++j) - if (bitset_test (reds->look_ahead_tokens[j], i)) + if (bitset_test (reds->lookahead_tokens[j], i)) { if (! count) { @@ -352,15 +352,15 @@ print_reductions (FILE *out, state *s) fputc ('\n', out); width += 2; - /* Report look-ahead tokens (or $default) and reductions. */ - if (reds->look_ahead_tokens) + /* Report lookahead tokens (or $default) and reductions. */ + if (reds->lookahead_tokens) for (i = 0; i < ntokens; i++) { bool defaulted = false; bool count = bitset_test (shift_set, i); for (j = 0; j < reds->num; ++j) - if (bitset_test (reds->look_ahead_tokens[j], i)) + if (bitset_test (reds->lookahead_tokens[j], i)) { if (! count) { @@ -563,11 +563,11 @@ print_results (void) new_closure (nritems); /* Storage for print_reductions. */ shift_set = bitset_create (ntokens, BITSET_FIXED); - look_ahead_set = bitset_create (ntokens, BITSET_FIXED); + lookahead_set = bitset_create (ntokens, BITSET_FIXED); for (i = 0; i < nstates; i++) print_state (out, states[i]); bitset_free (shift_set); - bitset_free (look_ahead_set); + bitset_free (lookahead_set); if (report_flag & report_itemsets) free_closure (); diff --git a/src/print_graph.c b/src/print_graph.c index 9580f3f1..0ba50b8e 100644 --- a/src/print_graph.c +++ b/src/print_graph.c @@ -88,21 +88,21 @@ print_core (struct obstack *oout, state *s) for (/* Nothing */; *sp >= 0; ++sp) obstack_fgrow1 (oout, " %s", symbols[*sp]->tag); - /* Experimental feature: display the look-ahead tokens. */ - if (report_flag & report_look_ahead_tokens) + /* Experimental feature: display the lookahead tokens. */ + if (report_flag & report_lookahead_tokens) { /* Find the reduction we are handling. */ reductions *reds = s->reductions; int redno = state_reduction_find (s, &rules[r]); /* Print them if there are. */ - if (reds->look_ahead_tokens && redno != -1) + if (reds->lookahead_tokens && redno != -1) { bitset_iterator biter; int k; char const *sep = ""; obstack_sgrow (oout, "["); - BITSET_FOR_EACH (biter, reds->look_ahead_tokens[redno], k, 0) + BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0) { obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag); sep = ", "; diff --git a/src/state.c b/src/state.c index 4eb39f9f..86fa1f49 100644 --- a/src/state.c +++ b/src/state.c @@ -105,7 +105,7 @@ reductions_new (int num, rule **reds) size_t rules_size = num * sizeof *reds; reductions *res = xmalloc (offsetof (reductions, rules) + rules_size); res->num = num; - res->look_ahead_tokens = NULL; + res->lookahead_tokens = NULL; memcpy (res->rules, reds, rules_size); return res; } @@ -218,26 +218,26 @@ state_errs_set (state *s, int num, symbol **tokens) -/*---------------------------------------------------. -| Print on OUT all the look-ahead tokens such that S | -| wants to reduce R. | -`---------------------------------------------------*/ +/*--------------------------------------------------. +| Print on OUT all the lookahead tokens such that S | +| wants to reduce R. | +`--------------------------------------------------*/ void -state_rule_look_ahead_tokens_print (state *s, rule *r, FILE *out) +state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out) { /* Find the reduction we are handling. */ reductions *reds = s->reductions; int red = state_reduction_find (s, r); /* Print them if there are. */ - if (reds->look_ahead_tokens && red != -1) + if (reds->lookahead_tokens && red != -1) { bitset_iterator biter; int k; char const *sep = ""; fprintf (out, " ["); - BITSET_FOR_EACH (biter, reds->look_ahead_tokens[red], k, 0) + BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0) { fprintf (out, "%s%s", sep, symbols[k]->tag); sep = ", "; diff --git a/src/state.h b/src/state.h index 440cd466..a2ae217f 100644 --- a/src/state.h +++ b/src/state.h @@ -46,11 +46,11 @@ Each core contains a vector of NITEMS items which are the indices in the RITEMS vector of the items that are selected in this state. - The two types of actions are shifts/gotos (push the look-ahead token + The two types of actions are shifts/gotos (push the lookahead token and read another/goto to the state designated by a nterm) and reductions (combine the last n things on the stack via a rule, replace them with the symbol that the rule derives, and leave the - look-ahead token alone). When the states are generated, these + lookahead token alone). When the states are generated, these actions are represented in two other lists. Each transition structure describes the possible transitions out @@ -185,7 +185,7 @@ errs *errs_new (int num, symbol **tokens); typedef struct { int num; - bitset *look_ahead_tokens; + bitset *lookahead_tokens; rule *rules[1]; } reductions; @@ -203,7 +203,7 @@ struct state reductions *reductions; errs *errs; - /* Nonzero if no look-ahead is needed to decide what to do in state S. */ + /* Nonzero if no lookahead is needed to decide what to do in state S. */ char consistent; /* If some conflicts were solved thanks to precedence/associativity, @@ -234,9 +234,9 @@ int state_reduction_find (state *s, rule *r); /* Set the errs of STATE. */ void state_errs_set (state *s, int num, symbol **errors); -/* Print on OUT all the look-ahead tokens such that this STATE wants to +/* Print on OUT all the lookahead tokens such that this STATE wants to reduce R. */ -void state_rule_look_ahead_tokens_print (state *s, rule *r, FILE *out); +void state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out); /* Create/destroy the states hash table. */ void state_hash_new (void); diff --git a/src/tables.c b/src/tables.c index c938139b..000d027c 100644 --- a/src/tables.c +++ b/src/tables.c @@ -198,7 +198,7 @@ conflict_row (state *s) /* Find all reductions for token J, and record all that do not match ACTROW[J]. */ for (i = 0; i < reds->num; i += 1) - if (bitset_test (reds->look_ahead_tokens[i], j) + if (bitset_test (reds->lookahead_tokens[i], j) && (actrow[j] != rule_number_as_item_number (reds->rules[i]->number))) { @@ -219,7 +219,7 @@ conflict_row (state *s) /*------------------------------------------------------------------. | Decide what to do for each type of token if seen as the | -| look-ahead in specified state. The value returned is used as the | +| lookahead in specified state. The value returned is used as the | | default action (yydefact) for the state. In addition, ACTROW is | | filled with what to do for each kind of token, index by symbol | | number, with zero meaning do the default action. The value | @@ -227,7 +227,7 @@ conflict_row (state *s) | situation is an error. The parser recognizes this value | | specially. | | | -| This is where conflicts are resolved. The loop over look-ahead | +| This is where conflicts are resolved. The loop over lookahead | | rules considered lower-numbered rules last, and the last rule | | considered that likes a token gets to handle it. | | | @@ -252,17 +252,17 @@ action_row (state *s) for (i = 0; i < ntokens; i++) actrow[i] = conflrow[i] = 0; - if (reds->look_ahead_tokens) + if (reds->lookahead_tokens) { int j; bitset_iterator biter; /* loop over all the rules available here which require - look-ahead (in reverse order to give precedence to the first + lookahead (in reverse order to give precedence to the first rule) */ for (i = reds->num - 1; i >= 0; --i) /* and find each token which the rule finds acceptable to come next */ - BITSET_FOR_EACH (biter, reds->look_ahead_tokens[i], j, 0) + BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0) { /* and record this rule as the rule to use if that token follows. */ @@ -410,7 +410,7 @@ save_row (state_number s) /*------------------------------------------------------------------. | Figure out the actions for the specified state, indexed by | -| look-ahead token type. | +| lookahead token type. | | | | The YYDEFACT table is output now. The detailed info is saved for | | putting into YYTABLE later. | diff --git a/src/tables.h b/src/tables.h index 911917fd..5f78df92 100644 --- a/src/tables.h +++ b/src/tables.h @@ -56,7 +56,7 @@ something else to do. YYPACT[S] = index in YYTABLE of the portion describing state S. - The look-ahead token's type is used to index that portion to find + The lookahead token's type is used to index that portion to find out what to do. If the value in YYTABLE is positive, we shift the token and go to diff --git a/tests/calc.at b/tests/calc.at index dedf568e..75010c11 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -503,8 +503,8 @@ _AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4], # # - test the action associated to `error' # -# - check the look-ahead that triggers an error is not discarded -# when we enter error recovery. Below, the look-ahead causing the +# - check the lookahead that triggers an error is not discarded +# when we enter error recovery. Below, the lookahead causing the # first error is ")", which is needed to recover from the error and # produce the "0" that triggers the "0 != 1" error. # @@ -518,7 +518,7 @@ _AT_CHECK_CALC_ERROR([$1], [0], calc: error: 4444 != 1]) # The same, but this time exercising explicitly triggered syntax errors. -# POSIX says the look-ahead causing the error should not be discarded. +# POSIX says the lookahead causing the error should not be discarded. _AT_CHECK_CALC_ERROR([$1], [0], [(!) + (0 0) = 1], [102], [1.9: syntax error, unexpected number calc: error: 2222 != 1]) diff --git a/tests/glr-regression.at b/tests/glr-regression.at index 9e3cec79..598ab8e8 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -1090,7 +1090,7 @@ AT_DATA_GRAMMAR([glr-regr13.y], #include static void yyerror (char const *); static int yylex (void); - static void print_look_ahead (char const *); + static void print_lookahead (char const *); #define USE(value) %} @@ -1104,32 +1104,32 @@ AT_DATA_GRAMMAR([glr-regr13.y], start: defstate_init defstate_shift 'b' change_lookahead 'a' { USE ($3); - print_look_ahead ("start <- defstate_init defstate_shift 'b'"); + print_lookahead ("start <- defstate_init defstate_shift 'b'"); } ; defstate_init: { - print_look_ahead ("defstate_init <- empty string"); + print_lookahead ("defstate_init <- empty string"); } ; defstate_shift: nondefstate defstate_look 'a' { USE ($3); - print_look_ahead ("defstate_shift <- nondefstate defstate_look 'a'"); + print_lookahead ("defstate_shift <- nondefstate defstate_look 'a'"); } ; defstate_look: { - print_look_ahead ("defstate_look <- empty string"); + print_lookahead ("defstate_look <- empty string"); } ; nondefstate: { - print_look_ahead ("nondefstate <- empty string"); + print_lookahead ("nondefstate <- empty string"); } | 'b' { USE ($1); - print_look_ahead ("nondefstate <- 'b'"); + print_lookahead ("nondefstate <- 'b'"); } ; change_lookahead: @@ -1158,7 +1158,7 @@ yylex (void) } static void -print_look_ahead (char const *reduction) +print_lookahead (char const *reduction) { printf ("%s:\n yychar=", reduction); if (yychar == YYEMPTY) @@ -1238,7 +1238,7 @@ AT_DATA_GRAMMAR([glr-regr14.y], #include static void yyerror (char const *); static int yylex (void); - static void print_look_ahead (char const *); + static void print_lookahead (char const *); static char merge (union YYSTYPE, union YYSTYPE); #define USE(value) %} @@ -1252,7 +1252,7 @@ AT_DATA_GRAMMAR([glr-regr14.y], start: merge 'c' stack_explosion { USE ($2); USE ($3); - print_look_ahead ("start <- merge 'c' stack_explosion"); + print_lookahead ("start <- merge 'c' stack_explosion"); } ; @@ -1260,44 +1260,44 @@ start: merge: nonconflict1 'a' 'b' nonconflict2 %dprec 1 { USE ($2); USE ($3); - print_look_ahead ("merge <- nonconflict1 'a' 'b' nonconflict2"); + print_lookahead ("merge <- nonconflict1 'a' 'b' nonconflict2"); } | conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2 { USE ($3); USE ($5); - print_look_ahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'" + print_lookahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'" " defstate_shift"); } ; nonconflict1: { - print_look_ahead ("nonconflict1 <- empty string"); + print_lookahead ("nonconflict1 <- empty string"); } ; nonconflict2: { - print_look_ahead ("nonconflict2 <- empty string"); + print_lookahead ("nonconflict2 <- empty string"); } | 'a' { USE ($1); - print_look_ahead ("nonconflict2 <- 'a'"); + print_lookahead ("nonconflict2 <- 'a'"); } ; conflict: { - print_look_ahead ("conflict <- empty string"); + print_lookahead ("conflict <- empty string"); } ; defstate_look: { - print_look_ahead ("defstate_look <- empty string"); + print_lookahead ("defstate_look <- empty string"); } ; /* yychar != YYEMPTY but lookahead need is yyfalse. */ defstate_shift: { - print_look_ahead ("defstate_shift <- empty string"); + print_lookahead ("defstate_shift <- empty string"); } ; @@ -1364,7 +1364,7 @@ yylex (void) } static void -print_look_ahead (char const *reduction) +print_lookahead (char const *reduction) { printf ("%s:\n yychar=", reduction); if (yychar == YYEMPTY) diff --git a/tests/torture.at b/tests/torture.at index ff373c21..629bf976 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -257,11 +257,11 @@ AT_CLEANUP -# AT_DATA_LOOK_AHEAD_TOKENS_GRAMMAR(FILE-NAME, SIZE) +# AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR(FILE-NAME, SIZE) # -------------------------------------------------- # Create FILE-NAME, containing a self checking parser for a grammar -# requiring SIZE look-ahead tokens. -m4_define([AT_DATA_LOOK_AHEAD_TOKENS_GRAMMAR], +# requiring SIZE lookahead tokens. +m4_define([AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR], [AT_DATA([[gengram.pl]], [[#! /usr/bin/perl -w @@ -362,12 +362,12 @@ mv stdout $1 ## ------------------------ ## -## Many look-ahead tokens. ## +## Many lookahead tokens. ## ## ------------------------ ## -AT_SETUP([Many look-ahead tokens]) +AT_SETUP([Many lookahead tokens]) -AT_DATA_LOOK_AHEAD_TOKENS_GRAMMAR([input.y], [1000]) +AT_DATA_LOOKAHEAD_TOKENS_GRAMMAR([input.y], [1000]) # GNU m4 requires about 70 MiB for this test on a 32-bit host. # Ask for 200 MiB, which should be plenty even on a 64-bit host. -- 2.45.2