#include <config.h>
#include "system.h"
+#include "c-ctype.h"
#include "complain.h"
#include "conflicts.h"
#include "files.h"
#include "quotearg.h"
#include "reader.h"
#include "symlist.h"
+#include "symtab.h"
#include "scan-gram.h"
#include "scan-code.h"
#include "xmemdup0.h"
#define YYTYPE_UINT8 uint_fast8_t
}
-%debug
%verbose
%defines
-%locations
-%pure-parser
-%define parse.error "verbose"
+%define locations
+%define api.pure
+%define parse.error verbose
%define parse.lac full
-%name-prefix="gram_"
+%define parse.trace
+%name-prefix "gram_"
%expect 0
%initial-action
%token TAG_NONE "<>"
%type <character> CHAR
-%printer { fputs (char_name ($$), stderr); } CHAR
+%printer { fputs (char_name ($$), yyo); } CHAR
/* braceless is not to be used for rule or symbol actions, as it
calls code_props_plain_init. */
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
%type <code> "{...}" "%?{...}"
-%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
+%printer { fputs (quotearg_style (c_quoting_style, $$), yyo); }
STRING
-%printer { fprintf (stderr, "{\n%s\n}", $$); }
+%printer { fprintf (yyo, "{\n%s\n}", $$); }
braceless content.opt "{...}" "%{...%}" EPILOGUE
%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG tag variable
-%printer { fputs ($$, stderr); } <uniqstr>
-%printer { fprintf (stderr, "[%s]", $$); } BRACKETED_ID
-%printer { fprintf (stderr, "%s:", $$); } ID_COLON
-%printer { fprintf (stderr, "%%%s", $$); } PERCENT_FLAG
-%printer { fprintf (stderr, "<%s>", $$); } TAG tag
+%printer { fputs ($$, yyo); } <uniqstr>
+%printer { fprintf (yyo, "[%s]", $$); } BRACKETED_ID
+%printer { fprintf (yyo, "%s:", $$); } ID_COLON
+%printer { fprintf (yyo, "%%%s", $$); } PERCENT_FLAG
+%printer { fprintf (yyo, "<%s>", $$); } TAG tag
%type <integer> INT
-%printer { fprintf (stderr, "%d", $$); } <integer>
+%printer { fprintf (yyo, "%d", $$); } <integer>
%type <symbol> id id_colon string_as_id symbol symbol.prec
-%printer { fprintf (stderr, "%s", $$->tag); } <symbol>
-%printer { fprintf (stderr, "%s:", $$->tag); } id_colon
+%printer { fprintf (yyo, "%s", $$->tag); } <symbol>
+%printer { fprintf (yyo, "%s:", $$->tag); } id_colon
%type <assoc> precedence_declarator
%type <list> symbols.1 symbols.prec generic_symlist generic_symlist_item
{
grammar_start_symbol_set ($2, @2);
}
-| "%destructor" "{...}" generic_symlist
+| code_props_type "{...}" generic_symlist
{
- symbol_list *list;
- for (list = $3; list; list = list->next)
- symbol_list_code_props_set (list, $1, @2, $2);
- symbol_list_free ($3);
- }
-| "%printer" "{...}" generic_symlist
- {
- symbol_list *list;
- for (list = $3; list; list = list->next)
- symbol_list_code_props_set (list, printer, @2, $2);
- symbol_list_free ($3);
+ code_props code;
+ code_props_symbol_action_init (&code, $2, @2);
+ code_props_translate_code (&code);
+ {
+ symbol_list *list;
+ for (list = $3; list; list = list->next)
+ symbol_list_code_props_set (list, $1, &code);
+ symbol_list_free ($3);
+ }
}
| "%default-prec"
{
}
;
+%type <code_type> code_props_type;
+%union {code_props_type code_type;};
+%printer { fprintf (yyo, "%s", code_props_type_string ($$)); } <code_type>;
+code_props_type:
+ "%destructor" { $$ = destructor; }
+| "%printer" { $$ = printer; }
+;
/*---------.
| %union. |
/* Strip the surrounding '{' and '}', and any blanks just inside
the braces. */
- while (*--p == ' ' || *p == '\t')
- continue;
+ --p;
+ while (c_isspace ((unsigned char) *p))
+ --p;
p[1] = '\0';
- while (*++decl == ' ' || *decl == '\t')
- continue;
+ ++decl;
+ while (c_isspace ((unsigned char) *decl))
+ ++decl;
}
if (! name_start)
- complain_at (loc, complaint,
- _("missing identifier in parameter declaration"));
+ complain (&loc, complaint, _("missing identifier in parameter declaration"));
else
{
char *name = xmemdup0 (name_start, strspn (name_start, alphanum));
{
if (strverscmp (version, PACKAGE_VERSION) > 0)
{
- complain_at (*loc, complaint, "require bison %s, but have %s",
- version, PACKAGE_VERSION);
+ complain (loc, complaint, "require bison %s, but have %s",
+ version, PACKAGE_VERSION);
exit (EX_MISMATCH);
}
}
static void
gram_error (location const *loc, char const *msg)
{
- complain_at (*loc, complaint, "%s", msg);
+ complain (loc, complaint, "%s", msg);
}
char const *