Similar to the recently removed %before-header, add %code-top as the

alternative to the pre-prologue.  Mentioned at
<http://lists.gnu.org/archive/html/bison-patches/2006-10/msg00063.html>.
Also, let the prologue alternatives appear in the grammar section.
* src/parse-gram.y (PERCENT_CODE_TOP): New token.
(prologue_declaration): Move the existing prologue alternatives to...
(grammar_declaration): ... here and add %code-top.
* src/scan-gram.l (PERCENT_CODE_TOP): New token.

Clean up and extend documentation for the prologue alternatives.
* NEWS (2.3a+): Describe prologue alternatives.
* doc/bison.texinfo (Prologue): Move discussion of prologue
alternatives to...
(Prologue Alternatives): ... this new section, and extend it to discuss
all 4 directives in detail.
(Bison Symbols): Clean up discussion of prologue alternatives and add
%code-top.
This commit is contained in:
Joel E. Denny
2006-10-16 05:25:36 +00:00
parent f209868ed0
commit 2cbe6b7f8f
8 changed files with 975 additions and 628 deletions

View File

@@ -134,6 +134,7 @@ static int current_prec = 0;
%token
PERCENT_CODE "%code"
PERCENT_CODE_TOP "%code-top"
PERCENT_DEBUG "%debug"
PERCENT_DEFAULT_PREC "%default-prec"
PERCENT_DEFINE "%define"
@@ -221,7 +222,6 @@ prologue_declarations:
prologue_declaration:
grammar_declaration
| "%{...%}" { prologue_augment (translate_code ($1, @1), @1, union_seen); }
| "%code" braceless { prologue_augment ($2, @2, true); }
| "%debug" { debug_flag = true; }
| "%define" STRING content.opt { muscle_insert ($2, $3); }
| "%defines" { defines_flag = true; }
@@ -245,11 +245,9 @@ prologue_declaration:
| "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" "=" STRING { spec_outfile = $3; }
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
| "%provides" braceless { muscle_code_grow ("provides", $2, @2); }
| "%pure-parser" { pure_parser = true; }
| "%push-parser" { push_parser = true; }
| "%require" STRING { version_check (&@2, $2); }
| "%requires" braceless { muscle_code_grow ("requires", $2, @2); }
| "%skeleton" STRING { skeleton = $2; }
| "%token-table" { token_table_flag = true; }
| "%verbose" { report_flag = report_states; }
@@ -288,6 +286,10 @@ grammar_declaration:
{
default_prec = false;
}
| "%code" braceless { prologue_augment ($2, @2, true); }
| "%code-top" braceless { prologue_augment ($2, @2, false); }
| "%provides" braceless { muscle_code_grow ("provides", $2, @2); }
| "%requires" braceless { muscle_code_grow ("requires", $2, @2); }
;