+ c = getc (finput);
+ }
+ if (c == '$')
+ {
+ fprintf (faction, "yyval");
+ if (!type_name)
+ type_name = get_type_name (0, rule);
+ if (type_name)
+ fprintf (faction, ".%s", type_name);
+ if (!type_name && typed)
+ complain (_("$$ of `%s' has no declared type"),
+ rule->sym->tag);
+ }
+ else if (isdigit (c) || c == '-')
+ {
+ ungetc (c, finput);
+ n = read_signed_integer (finput);
+ c = getc (finput);
+
+ if (!type_name && n > 0)
+ type_name = get_type_name (n, rule);
+
+ fprintf (faction, "yyvsp[%d]", n - stack_offset);
+ if (type_name)
+ fprintf (faction, ".%s", type_name);
+ if (!type_name && typed)
+ complain (_("$%d of `%s' has no declared type"),
+ n, rule->sym->tag);
+ continue;
+ }
+ else
+ complain (_("$%s is invalid"), printable_version (c));
+
+ break;
+
+ case '@':
+ copy_at (finput, faction, stack_offset);
+ break;
+
+ case EOF:
+ fatal (_("unmatched %s"), "`{'");
+
+ default:
+ putc (c, faction);
+ }
+
+ c = getc (finput);
+ }
+
+ /* above loop exits when c is '}' */
+
+ if (--count)
+ {
+ putc (c, faction);
+ c = getc (finput);
+ }
+ }
+
+ fprintf (faction, ";\n break;}");
+}
+\f
+/*-------------------------------------------------------------------.
+| After `%guard' is seen in the input file, copy the actual guard |
+| into the guards file. If the guard is followed by an action, copy |
+| that into the actions file. STACK_OFFSET is the number of values |
+| in the current rule so far, which says where to find `$0' with |
+| respect to the top of the stack, for the simple parser in which |
+| the stack is not popped until after the guard is run. |
+`-------------------------------------------------------------------*/
+
+static void
+copy_guard (symbol_list * rule, int stack_offset)
+{
+ int c;
+ int n;
+ int count;
+ char *type_name;
+ int brace_flag = 0;
+
+ /* offset is always 0 if parser has already popped the stack pointer */
+ if (semantic_parser)
+ stack_offset = 0;
+
+ fprintf (fguard, "\ncase %d:\n", nrules);
+ if (!nolinesflag)
+ fprintf (fguard, "#line %d \"%s\"\n", lineno, infile);
+ putc ('{', fguard);
+
+ count = 0;
+ c = getc (finput);
+
+ while (brace_flag ? (count > 0) : (c != ';'))
+ {
+ switch (c)
+ {
+ case '\n':
+ putc (c, fguard);
+ lineno++;
+ break;
+
+ case '{':
+ putc (c, fguard);
+ brace_flag = 1;
+ count++;
+ break;
+
+ case '}':
+ putc (c, fguard);
+ if (count > 0)
+ count--;
+ else
+ {
+ complain (_("unmatched %s"), "`}'");
+ c = getc (finput); /* skip it */
+ }
+ break;
+
+ case '\'':
+ case '"':
+ copy_string (finput, fguard, c);
+ break;
+
+ case '/':
+ putc (c, fguard);
+ c = getc (finput);
+ if (c != '*' && c != '/')
+ continue;
+ copy_comment (finput, fguard, c);
+ break;
+
+ case '$':
+ c = getc (finput);
+ type_name = NULL;
+
+ if (c == '<')
+ {
+ char *cp = token_buffer;
+
+ while ((c = getc (finput)) != '>' && c > 0)