+/* Set the precedence symbol of the current rule to PRECSYM. */
+
+static void
+grammar_current_rule_prec_set (symbol_t *precsym)
+{
+ if (current_rule->ruleprec)
+ complain (_("two @prec's in a row"));
+ current_rule->ruleprec = precsym;
+}
+
+/* Check that the last rule (CURRENT_RULE) is properly defined. For
+ instance, there should be no type clash on the default action. */
+
+static void
+grammar_current_rule_check (void)
+{
+ symbol_t *lhs = current_rule->sym;
+ symbol_t *first_rhs = current_rule->next->sym;
+
+ /* If there is an action, then there is nothing we can do: the user
+ is allowed to shoot in her foot. */
+ if (current_rule->action)
+ return;
+
+ /* If $$ is being set in default way, report if any type mismatch.
+ */
+ if (first_rhs)
+ {
+ const char *lhs_type = lhs->type_name ? lhs->type_name : "";
+ const char *rhs_type = first_rhs->type_name ? first_rhs->type_name : "";
+ if (strcmp (lhs_type, rhs_type))
+ complain (_("type clash (`%s' `%s') on default action"),
+ lhs_type, rhs_type);
+ }
+ /* Warn if there is no default for $$ but we need one. */
+ else
+ {
+ if (lhs->type_name)
+ complain (_("empty rule for typed nonterminal, and no action"));
+ }
+}
+