Rename <!> to <>. Discussed starting at

<http://lists.gnu.org/archive/html/bison-patches/2006-11/msg00039.html>.
* NEWS (2.3a+): Update.
* doc/bison.texinfo (Freeing Discarded Symbols, Bison Symbols):
Update.
* src/parse-gram.y (TYPE_TAG_NONE, generic_symlist_item): Implement.
* src/scan-gram.l (INITIAL): Implement.
* src/symlist.c (symbol_list_default_tagless_new): Update comment.
* src/symlist.h (symbol_list, symbol_list_default_tagless_new): Update
comment.
* tests/actions.at (Default tagless %printer and %destructor,
Default tagged and per-type %printer and %destructor,
Default %printer and %destructor are not for error or $undefined,
Default %printer and %destructor are not for $accept,
Default %printer and %destructor for mid-rule values): Update.
* tests/input.at (Default %printer and %destructor redeclared,
Unused values with default %destructor): Update.
This commit is contained in:
Joel E. Denny
2006-11-21 00:43:26 +00:00
parent 26b8a43805
commit 3ebecc240d
10 changed files with 69 additions and 49 deletions

View File

@@ -1,3 +1,23 @@
2006-11-20 Joel E. Denny <jdenny@ces.clemson.edu>
Rename <!> to <>. Discussed starting at
<http://lists.gnu.org/archive/html/bison-patches/2006-11/msg00039.html>.
* NEWS (2.3a+): Update.
* doc/bison.texinfo (Freeing Discarded Symbols, Bison Symbols):
Update.
* src/parse-gram.y (TYPE_TAG_NONE, generic_symlist_item): Implement.
* src/scan-gram.l (INITIAL): Implement.
* src/symlist.c (symbol_list_default_tagless_new): Update comment.
* src/symlist.h (symbol_list, symbol_list_default_tagless_new): Update
comment.
* tests/actions.at (Default tagless %printer and %destructor,
Default tagged and per-type %printer and %destructor,
Default %printer and %destructor are not for error or $undefined,
Default %printer and %destructor are not for $accept,
Default %printer and %destructor for mid-rule values): Update.
* tests/input.at (Default %printer and %destructor redeclared,
Unused values with default %destructor): Update.
2006-11-17 Joel E. Denny <jdenny@ces.clemson.edu> 2006-11-17 Joel E. Denny <jdenny@ces.clemson.edu>
Don't let %prec take a nonterminal. Don't let %prec take a nonterminal.
@@ -160,7 +180,7 @@
* doc/bison.texinfo (Freeing Discarded Symbols): Document this and the * doc/bison.texinfo (Freeing Discarded Symbols): Document this and the
previous change today related to mid-rules. previous change today related to mid-rules.
(Bison Symbols): Remove %symbol-default and add <*> and <!>. (Bison Symbols): Remove %symbol-default and add <*> and <!>.
* src/parser-gram.y (PERCENT_SYMBOL_DEFAULT): Remove. * src/parse-gram.y (PERCENT_SYMBOL_DEFAULT): Remove.
(TYPE_TAG_ANY): Add as <*>. (TYPE_TAG_ANY): Add as <*>.
(TYPE_TAG_NONE): Add as <!>. (TYPE_TAG_NONE): Add as <!>.
(generic_symlist_item): Remove RHS for %symbol-default and add RHS's (generic_symlist_item): Remove RHS for %symbol-default and add RHS's

4
NEWS
View File

@@ -33,12 +33,12 @@ Changes in version 2.3a+ (????-??-??):
%destructor/%printer for all grammar symbols for which you have formally %destructor/%printer for all grammar symbols for which you have formally
declared semantic type tags. declared semantic type tags.
2. Place `<!>' in a %destructor/%printer symbol list to define a default 2. Place `<>' in a %destructor/%printer symbol list to define a default
%destructor/%printer for all grammar symbols without declared semantic %destructor/%printer for all grammar symbols without declared semantic
type tags. type tags.
Bison no longer supports the `%symbol-default' notation from Bison 2.3a. Bison no longer supports the `%symbol-default' notation from Bison 2.3a.
`<*>' and `<!>' combined achieve the same effect with one exception: Bison no `<*>' and `<>' combined achieve the same effect with one exception: Bison no
longer applies any %destructor to a mid-rule value if that mid-rule value is longer applies any %destructor to a mid-rule value if that mid-rule value is
not actually ever referenced using either $$ or $n in a semantic action. not actually ever referenced using either $$ or $n in a semantic action.

View File

@@ -4237,7 +4237,7 @@ For instance, if your locations use a file name, you may use
@cindex freeing discarded symbols @cindex freeing discarded symbols
@findex %destructor @findex %destructor
@findex <*> @findex <*>
@findex <!> @findex <>
During error recovery (@pxref{Error Recovery}), symbols already pushed During error recovery (@pxref{Error Recovery}), symbols already pushed
on the stack and tokens coming from the rest of the file are discarded 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, until the parser falls on its feet. If the parser runs out of memory,
@@ -4271,7 +4271,7 @@ grammar symbol that has that semantic type tag unless that symbol has its own
per-symbol @code{%destructor}. per-symbol @code{%destructor}.
Finally, you can define two different kinds of default @code{%destructor}s. Finally, you can define two different kinds of default @code{%destructor}s.
You can place each of @code{<*>} and @code{<!>} in the @var{symbols} list of You can place each of @code{<*>} and @code{<>} in the @var{symbols} list of
exactly one @code{%destructor} declaration in your grammar file. exactly one @code{%destructor} declaration in your grammar file.
The parser will invoke the @var{code} associated with one of these whenever it The parser will invoke the @var{code} associated with one of these whenever it
discards any user-defined grammar symbol that has no per-symbol and no per-type discards any user-defined grammar symbol that has no per-symbol and no per-type
@@ -4279,7 +4279,7 @@ discards any user-defined grammar symbol that has no per-symbol and no per-type
The parser uses the @var{code} for @code{<*>} in the case of such a grammar The parser uses the @var{code} for @code{<*>} in the case of such a grammar
symbol for which you have formally declared a semantic type tag (@code{%type} symbol for which you have formally declared a semantic type tag (@code{%type}
counts as such a declaration, but @code{$<tag>$} does not). counts as such a declaration, but @code{$<tag>$} does not).
The parser uses the @var{code} for @code{<!>} in the case of such a grammar The parser uses the @var{code} for @code{<>} in the case of such a grammar
symbol that has no declared semantic type tag. symbol that has no declared semantic type tag.
@end deffn @end deffn
@@ -4300,7 +4300,7 @@ For example:
%destructor @{ @} <character> %destructor @{ @} <character>
%destructor @{ free ($$); @} <*> %destructor @{ free ($$); @} <*>
%destructor @{ free ($$); printf ("%d", @@$.first_line); @} STRING1 string1 %destructor @{ free ($$); printf ("%d", @@$.first_line); @} STRING1 string1
%destructor @{ printf ("Discarding tagless symbol.\n"); @} <!> %destructor @{ printf ("Discarding tagless symbol.\n"); @} <>
@end smallexample @end smallexample
@noindent @noindent
@@ -4339,7 +4339,7 @@ not reference @code{$$} in the mid-rule's action or @code{$@var{n}} (where
@var{n} is the RHS symbol position of the mid-rule) in any later action in that @var{n} is the RHS symbol position of the mid-rule) in any later action in that
rule. rule.
However, if you do reference either, the Bison-generated parser will invoke the However, if you do reference either, the Bison-generated parser will invoke the
@code{<!>} @code{%destructor} whenever it discards the mid-rule symbol. @code{<>} @code{%destructor} whenever it discards the mid-rule symbol.
@ignore @ignore
@noindent @noindent
@@ -8572,7 +8572,7 @@ Used to define a default tagged @code{%destructor} or default tagged
@xref{Destructor Decl, , Freeing Discarded Symbols}. @xref{Destructor Decl, , Freeing Discarded Symbols}.
@end deffn @end deffn
@deffn {Directive} <!> @deffn {Directive} <>
Used to define a default tagless @code{%destructor} or default tagless Used to define a default tagless @code{%destructor} or default tagless
@code{%printer}. @code{%printer}.
@xref{Destructor Decl, , Freeing Discarded Symbols}. @xref{Destructor Decl, , Freeing Discarded Symbols}.

View File

@@ -699,7 +699,7 @@ static const char *const yytname[] =
"\"%requires\"", "\"%skeleton\"", "\"%start\"", "\"%token-table\"", "\"%requires\"", "\"%skeleton\"", "\"%start\"", "\"%token-table\"",
"\"%verbose\"", "\"%yacc\"", "\"{...}\"", "\"char\"", "\"epilogue\"", "\"%verbose\"", "\"%yacc\"", "\"{...}\"", "\"char\"", "\"epilogue\"",
"\"=\"", "\"identifier\"", "\"identifier:\"", "\"%%\"", "\"|\"", "\"=\"", "\"identifier\"", "\"identifier:\"", "\"%%\"", "\"|\"",
"\"%{...%}\"", "\";\"", "\"type\"", "\"<*>\"", "\"<!>\"", "\"%union\"", "\"%{...%}\"", "\";\"", "\"type\"", "\"<*>\"", "\"<>\"", "\"%union\"",
"$accept", "input", "prologue_declarations", "prologue_declaration", "$accept", "input", "prologue_declarations", "prologue_declaration",
"grammar_declaration", "union_name", "symbol_declaration", "$@1", "$@2", "grammar_declaration", "union_name", "symbol_declaration", "$@1", "$@2",
"precedence_declaration", "precedence_declarator", "type.opt", "precedence_declaration", "precedence_declarator", "type.opt",

View File

@@ -176,7 +176,7 @@ static int current_prec = 0;
%token SEMICOLON ";" %token SEMICOLON ";"
%token TYPE "type" %token TYPE "type"
%token TYPE_TAG_ANY "<*>" %token TYPE_TAG_ANY "<*>"
%token TYPE_TAG_NONE "<!>" %token TYPE_TAG_NONE "<>"
%type <character> CHAR %type <character> CHAR
%printer { fputs (char_name ($$), stderr); } CHAR %printer { fputs (char_name ($$), stderr); } CHAR
@@ -397,7 +397,7 @@ generic_symlist_item:
symbol { $$ = symbol_list_sym_new ($1, @1); } symbol { $$ = symbol_list_sym_new ($1, @1); }
| TYPE { $$ = symbol_list_type_new ($1, @1); } | TYPE { $$ = symbol_list_type_new ($1, @1); }
| "<*>" { $$ = symbol_list_default_tagged_new (@1); } | "<*>" { $$ = symbol_list_default_tagged_new (@1); }
| "<!>" { $$ = symbol_list_default_tagless_new (@1); } | "<>" { $$ = symbol_list_default_tagless_new (@1); }
; ;
/* One token definition. */ /* One token definition. */

View File

@@ -210,7 +210,7 @@ splice (\\[ \f\t\v]*\n)*
"|" return PIPE; "|" return PIPE;
";" return SEMICOLON; ";" return SEMICOLON;
"<*>" return TYPE_TAG_ANY; "<*>" return TYPE_TAG_ANY;
"<!>" return TYPE_TAG_NONE; "<>" return TYPE_TAG_NONE;
{id} { {id} {
val->uniqstr = uniqstr_new (yytext); val->uniqstr = uniqstr_new (yytext);

View File

@@ -91,9 +91,9 @@ symbol_list_default_tagged_new (location loc)
} }
/*----------------------------------------. /*---------------------------------------.
| Create a list containing a <!> at LOC. | | Create a list containing a <> at LOC. |
`----------------------------------------*/ `---------------------------------------*/
symbol_list * symbol_list *
symbol_list_default_tagless_new (location loc) symbol_list_default_tagless_new (location loc)

View File

@@ -30,7 +30,7 @@ typedef struct symbol_list
{ {
/** /**
* Whether this node contains a symbol, a semantic type, a \c <*>, or a * Whether this node contains a symbol, a semantic type, a \c <*>, or a
* \c <!>. * \c <>.
*/ */
enum { enum {
SYMLIST_SYMBOL, SYMLIST_TYPE, SYMLIST_SYMBOL, SYMLIST_TYPE,
@@ -81,7 +81,7 @@ symbol_list *symbol_list_type_new (uniqstr type_name, location loc);
/** Create a list containing a \c <*> at \c loc. */ /** Create a list containing a \c <*> at \c loc. */
symbol_list *symbol_list_default_tagged_new (location loc); symbol_list *symbol_list_default_tagged_new (location loc);
/** Create a list containing a \c <!> at \c loc. */ /** Create a list containing a \c <> at \c loc. */
symbol_list *symbol_list_default_tagless_new (location loc); symbol_list *symbol_list_default_tagless_new (location loc);
/** Print this list. /** Print this list.

View File

@@ -614,11 +614,11 @@ AT_DATA_GRAMMAR([[input.y]],
} <*> } <*>
%printer { %printer {
fprintf (yyoutput, "<!> printer for '%c' @ %d", $$, @$.first_column); fprintf (yyoutput, "<> printer for '%c' @ %d", $$, @$.first_column);
} <!> } <>
%destructor { %destructor {
fprintf (stdout, "<!> destructor for '%c' @ %d.\n", $$, @$.first_column); fprintf (stdout, "<> destructor for '%c' @ %d.\n", $$, @$.first_column);
} <!> } <>
%printer { %printer {
fprintf (yyoutput, "'b'/'c' printer for '%c' @ %d", $$, @$.first_column); fprintf (yyoutput, "'b'/'c' printer for '%c' @ %d", $$, @$.first_column);
@@ -667,15 +667,15 @@ main (void)
AT_CHECK([bison -o input.c input.y]) AT_CHECK([bison -o input.c input.y])
AT_COMPILE([input]) AT_COMPILE([input])
AT_PARSER_CHECK([./input], 1, AT_PARSER_CHECK([./input], 1,
[[<!> destructor for 'd' @ 4. [[<> destructor for 'd' @ 4.
'b'/'c' destructor for 'c' @ 3. 'b'/'c' destructor for 'c' @ 3.
'b'/'c' destructor for 'b' @ 2. 'b'/'c' destructor for 'b' @ 2.
<!> destructor for 'a' @ 1. <> destructor for 'a' @ 1.
]], ]],
[[Starting parse [[Starting parse
Entering state 0 Entering state 0
Reading a token: Next token is token 'a' (1.1-1.1: <!> printer for 'a' @ 1) Reading a token: Next token is token 'a' (1.1-1.1: <> printer for 'a' @ 1)
Shifting token 'a' (1.1-1.1: <!> printer for 'a' @ 1) Shifting token 'a' (1.1-1.1: <> printer for 'a' @ 1)
Entering state 1 Entering state 1
Reading a token: Next token is token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2) Reading a token: Next token is token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
Shifting token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2) Shifting token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
@@ -683,18 +683,18 @@ Entering state 3
Reading a token: Next token is token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3) Reading a token: Next token is token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
Shifting token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3) Shifting token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
Entering state 5 Entering state 5
Reading a token: Next token is token 'd' (1.4-1.4: <!> printer for 'd' @ 4) Reading a token: Next token is token 'd' (1.4-1.4: <> printer for 'd' @ 4)
Shifting token 'd' (1.4-1.4: <!> printer for 'd' @ 4) Shifting token 'd' (1.4-1.4: <> printer for 'd' @ 4)
Entering state 6 Entering state 6
Reading a token: Now at end of input. Reading a token: Now at end of input.
syntax error, unexpected $end, expecting 'e' syntax error, unexpected $end, expecting 'e'
Error: popping token 'd' (1.4-1.4: <!> printer for 'd' @ 4) Error: popping token 'd' (1.4-1.4: <> printer for 'd' @ 4)
Stack now 0 1 3 5 Stack now 0 1 3 5
Error: popping token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3) Error: popping token 'c' (1.3-1.3: 'b'/'c' printer for 'c' @ 3)
Stack now 0 1 3 Stack now 0 1 3
Error: popping token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2) Error: popping token 'b' (1.2-1.2: 'b'/'c' printer for 'b' @ 2)
Stack now 0 1 Stack now 0 1
Error: popping token 'a' (1.1-1.1: <!> printer for 'a' @ 1) Error: popping token 'a' (1.1-1.1: <> printer for 'a' @ 1)
Stack now 0 Stack now 0
Cleanup: discarding lookahead token $end (1.5-1.5: ) Cleanup: discarding lookahead token $end (1.5-1.5: )
Stack now 0 Stack now 0
@@ -723,8 +723,8 @@ AT_DATA_GRAMMAR([[input.y]],
%} %}
%printer { %printer {
fprintf (yyoutput, "<!> printer should not be called.\n"); fprintf (yyoutput, "<> printer should not be called.\n");
} <!> } <>
%union { int field0; int field1; int field2; } %union { int field0; int field1; int field2; }
%type <field0> start 'a' 'g' %type <field0> start 'a' 'g'
@@ -750,8 +750,8 @@ AT_DATA_GRAMMAR([[input.y]],
%destructor { fprintf (stdout, "'d' destructor.\n"); } 'd' %destructor { fprintf (stdout, "'d' destructor.\n"); } 'd'
%destructor { %destructor {
fprintf (yyoutput, "<!> destructor should not be called.\n"); fprintf (yyoutput, "<> destructor should not be called.\n");
} <!> } <>
%% %%
@@ -851,8 +851,8 @@ AT_SETUP([Default %printer and %destructor for user-defined end token])
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN], m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN],
[m4_if($1, 0, [m4_if($1, 0,
[m4_pushdef([kind], [!]) m4_pushdef([not_kind], [*])], [m4_pushdef([kind], []) m4_pushdef([not_kind], [*])],
[m4_pushdef([kind], [*]) m4_pushdef([not_kind], [!])]) [m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
AT_DATA_GRAMMAR([[input]]$1[[.y]], AT_DATA_GRAMMAR([[input]]$1[[.y]],
[[%error-verbose [[%error-verbose
@@ -983,10 +983,10 @@ AT_DATA_GRAMMAR([[input.y]],
%printer { %printer {
fprintf (yyoutput, "'%c'", $$); fprintf (yyoutput, "'%c'", $$);
} <!> <*> } <> <*>
%destructor { %destructor {
fprintf (stderr, "DESTROY '%c'\n", $$); fprintf (stderr, "DESTROY '%c'\n", $$);
} <!> <*> } <> <*>
%% %%
@@ -1098,11 +1098,11 @@ AT_DATA_GRAMMAR([[input.y]],
%printer { %printer {
char chr = $$; char chr = $$;
fprintf (yyoutput, "'%c'", chr); fprintf (yyoutput, "'%c'", chr);
} <!> <*> } <> <*>
%destructor { %destructor {
char chr = $$; char chr = $$;
fprintf (stderr, "DESTROY '%c'\n", chr); fprintf (stderr, "DESTROY '%c'\n", chr);
} <!> <*> } <> <*>
%union { char chr; } %union { char chr; }
%type <chr> start %type <chr> start
@@ -1162,8 +1162,8 @@ AT_DATA_GRAMMAR([[input.y]],
# define YY_LOCATION_PRINT(File, Loc) # define YY_LOCATION_PRINT(File, Loc)
%} %}
%printer { fprintf (yyoutput, "%d", @$); } <!> %printer { fprintf (yyoutput, "%d", @$); } <>
%destructor { fprintf (stderr, "DESTROY %d\n", @$); } <!> %destructor { fprintf (stderr, "DESTROY %d\n", @$); } <>
%printer { fprintf (yyoutput, "<*> printer should not be called"); } <*> %printer { fprintf (yyoutput, "<*> printer should not be called"); } <*>
%destructor { fprintf (yyoutput, "<*> destructor should not be called"); } <*> %destructor { fprintf (yyoutput, "<*> destructor should not be called"); } <*>

View File

@@ -188,11 +188,11 @@ AT_DATA([[input.y]],
%destructor { destroy ($$); } <*> %destructor { destroy ($$); } <*>
%printer { destroy ($$); } <*> %printer { destroy ($$); } <*>
%destructor { destroy ($$); } <!> <!> %destructor { destroy ($$); } <> <>
%printer { destroy ($$); } <!> <!> %printer { destroy ($$); } <> <>
%destructor { destroy ($$); } <!> %destructor { destroy ($$); } <>
%printer { destroy ($$); } <!> %printer { destroy ($$); } <>
%% %%
@@ -201,8 +201,8 @@ start: ;
%destructor { destroy ($$); } <*>; %destructor { destroy ($$); } <*>;
%printer { destroy ($$); } <*>; %printer { destroy ($$); } <*>;
%destructor { destroy ($$); } <!>; %destructor { destroy ($$); } <>;
%printer { destroy ($$); } <!>; %printer { destroy ($$); } <>;
]]) ]])
AT_CHECK([bison input.y], [1], [], AT_CHECK([bison input.y], [1], [],
@@ -285,7 +285,7 @@ AT_CLEANUP
AT_SETUP([Unused values with default %destructor]) AT_SETUP([Unused values with default %destructor])
AT_DATA([[input.y]], AT_DATA([[input.y]],
[[%destructor { destroy ($$); } <!> [[%destructor { destroy ($$); } <>
%type <tag> tagged %type <tag> tagged
%% %%