%{/* Bison Grammar Parser -*- C -*-
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
- Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
%token PERCENT_DPREC "%dprec"
%token PERCENT_MERGE "%merge"
-
/*----------------------.
| Global Declarations. |
`----------------------*/
;
%token BRACED_CODE "{...}"
+%token BRACED_PREDICATE "%?{...}"
+%token BRACKETED_ID "[identifier]"
%token CHAR "char"
%token EPILOGUE "epilogue"
%token EQUAL "="
%token TAG "<tag>"
%token TAG_ANY "<*>"
%token TAG_NONE "<>"
-%token BRACKETED_ID "[identifier]"
%type <character> CHAR
%printer { fputs (char_name ($$), stderr); } 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> "{...}"
+%type <code> "{...}" "%?{...}"
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
STRING
%printer { fprintf (stderr, "{\n%s\n}", $$); }
braceless content.opt "{...}" "%{...%}" EPILOGUE
-%type <uniqstr> TAG ID ID_COLON BRACKETED_ID PERCENT_FLAG variable
-%type <named_ref> named_ref.opt
-%printer { fputs ($$, stderr); } ID variable
+%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG 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
%type <integer> INT
-%printer { fprintf (stderr, "%d", $$); } INT
+%printer { fprintf (stderr, "%d", $$); } <integer>
-%type <symbol> id id_colon symbol symbol.prec string_as_id
-%printer { fprintf (stderr, "%s", $$->tag); } id symbol string_as_id
+%type <symbol> id id_colon string_as_id symbol symbol.prec
+%printer { fprintf (stderr, "%s", $$->tag); } <symbol>
%printer { fprintf (stderr, "%s:", $$->tag); } id_colon
%type <assoc> precedence_declarator
%type <list> symbols.1 symbols.prec generic_symlist generic_symlist_item
+%type <named_ref> named_ref.opt
/*---------.
| %param. |
CASE(parse, parse-param);
CASE(both, param);
#undef CASE
+ case param_none: aver (false); break;
}
} <param>;
| rhs symbol named_ref.opt
{ grammar_current_rule_symbol_append ($2, @2, $3); }
| rhs "{...}" named_ref.opt
- { grammar_current_rule_action_append ($2, @2, $3); }
+ { grammar_current_rule_action_append ($2, @2, $3, false); }
+| rhs "%?{...}"
+ { grammar_current_rule_action_append ($2, @2, NULL, true); }
| rhs "%prec" symbol
{ grammar_current_rule_prec_set ($3, @3); }
| rhs "%dprec" INT
BRACKETED_ID { $$ = named_ref_new($1, @1); }
;
-
/*---------------------------.
| variable and content.opt. |
`---------------------------*/
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"_"
"0123456789";
+
char const *name_start = NULL;
- char *p;
-
- /* Stop on last actual character. */
- for (p = decl; p[1]; p++)
- if ((p == decl
- || ! memchr (alphanum, p[-1], sizeof alphanum))
- && memchr (alphanum, p[0], sizeof alphanum - 10))
- name_start = p;
-
- /* Strip the surrounding '{' and '}', and any blanks just inside
- the braces. */
- while (*--p == ' ' || *p == '\t')
- continue;
- p[1] = '\0';
- while (*++decl == ' ' || *decl == '\t')
- continue;
+ {
+ char *p;
+ /* Stop on last actual character. */
+ for (p = decl; p[1]; p++)
+ if ((p == decl
+ || ! memchr (alphanum, p[-1], sizeof alphanum))
+ && memchr (alphanum, p[0], sizeof alphanum - 10))
+ name_start = p;
+
+ /* Strip the surrounding '{' and '}', and any blanks just inside
+ the braces. */
+ while (*--p == ' ' || *p == '\t')
+ continue;
+ p[1] = '\0';
+ while (*++decl == ' ' || *decl == '\t')
+ continue;
+ }
if (! name_start)
complain_at (loc, _("missing identifier in parameter declaration"));