mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 15:23:02 +00:00
Use the new code_props interface in parse-gram.y.
* src/parse-gram.y (prologue_declaration, braceless, epilogue.opt): Update all uses of translate_* functions to use the new code_props interface and to use gram_scanner_last_string_free and code_scanner_last_string_free where possible. (grammar_declaration): symbol_list_destructor_set and symbol_list_printer_set now perform the translation, so don't do it here. Use gram_scanner_last_string_free where possible. * src/scan-code.h, src/scan-code.l (translate_symbol_action, translate_code): Remove, no longer used. * src/symlist.h, src/symlist.c (symbol_list_destructor_set, symbol_list_printer_set): Perform code translation here rather than depending on the caller to do so. * src/symlist.h (struct symbol_list): Correct some documentation typos. * src/scan-gram.h (gram_last_string): Remove declaration. * src/scan-gram.l (last_string): Declare it static.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
%{/* Bison Grammar Parser -*- C -*-
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
@@ -185,7 +186,7 @@ static int current_prec = 0;
|
||||
%printer { fputs (char_name ($$), stderr); } CHAR
|
||||
|
||||
/* braceless is not to be used for rule or symbol actions, as it
|
||||
calls translate_code. */
|
||||
calls code_props_plain_init. */
|
||||
%type <chars> STRING "%{...%}" EPILOGUE braceless content content.opt
|
||||
%type <code> "{...}"
|
||||
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
||||
@@ -225,7 +226,15 @@ prologue_declarations:
|
||||
|
||||
prologue_declaration:
|
||||
grammar_declaration
|
||||
| "%{...%}" { prologue_augment (translate_code ($1, @1), @1, union_seen); }
|
||||
| "%{...%}"
|
||||
{
|
||||
code_props plain_code;
|
||||
code_props_plain_init (&plain_code, $1, @1);
|
||||
code_props_translate_code (&plain_code);
|
||||
gram_scanner_last_string_free ();
|
||||
prologue_augment (plain_code.code, @1, union_seen);
|
||||
code_scanner_last_string_free ();
|
||||
}
|
||||
| "%debug" { debug_flag = true; }
|
||||
| "%define" STRING content.opt { muscle_insert ($2, $3); }
|
||||
| "%defines" { defines_flag = true; }
|
||||
@@ -246,7 +255,12 @@ prologue_declaration:
|
||||
}
|
||||
| "%initial-action" "{...}"
|
||||
{
|
||||
muscle_code_grow ("initial_action", translate_symbol_action ($2, @2), @2);
|
||||
code_props action;
|
||||
code_props_symbol_action_init (&action, $2, @2);
|
||||
code_props_translate_code (&action);
|
||||
gram_scanner_last_string_free ();
|
||||
muscle_code_grow ("initial_action", action.code, @2);
|
||||
code_scanner_last_string_free ();
|
||||
}
|
||||
| "%language" STRING { language_argmatch ($2, 1, &@1); }
|
||||
| "%lex-param" "{...}" { add_param ("lex_param", $2, @2); }
|
||||
@@ -279,17 +293,15 @@ grammar_declaration:
|
||||
| "%destructor" "{...}" generic_symlist
|
||||
{
|
||||
symbol_list *list;
|
||||
const char *action = translate_symbol_action ($2, @2);
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_list_destructor_set (list, action, @2);
|
||||
symbol_list_destructor_set (list, $2, @2);
|
||||
symbol_list_free ($3);
|
||||
}
|
||||
| "%printer" "{...}" generic_symlist
|
||||
{
|
||||
symbol_list *list;
|
||||
const char *action = translate_symbol_action ($2, @2);
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_list_printer_set (list, action, @2);
|
||||
symbol_list_printer_set (list, $2, @2);
|
||||
symbol_list_free ($3);
|
||||
}
|
||||
| "%default-prec"
|
||||
@@ -340,6 +352,7 @@ grammar_declaration:
|
||||
|
||||
union_seen = true;
|
||||
muscle_code_grow ("stype", body, @3);
|
||||
gram_scanner_last_string_free ();
|
||||
}
|
||||
;
|
||||
|
||||
@@ -522,8 +535,12 @@ content.opt:
|
||||
braceless:
|
||||
"{...}"
|
||||
{
|
||||
code_props plain_code;
|
||||
$1[strlen ($1) - 1] = '\n';
|
||||
$$ = translate_code ($1 + 1, @1);
|
||||
code_props_plain_init (&plain_code, $1+1, @1);
|
||||
code_props_translate_code (&plain_code);
|
||||
gram_scanner_last_string_free ();
|
||||
$$ = plain_code.code;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -569,8 +586,12 @@ epilogue.opt:
|
||||
/* Nothing. */
|
||||
| "%%" EPILOGUE
|
||||
{
|
||||
muscle_code_grow ("epilogue", translate_code ($2, @2), @2);
|
||||
code_props plain_code;
|
||||
code_props_plain_init (&plain_code, $2, @2);
|
||||
code_props_translate_code (&plain_code);
|
||||
gram_scanner_last_string_free ();
|
||||
muscle_code_grow ("epilogue", plain_code.code, @2);
|
||||
code_scanner_last_string_free ();
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user