- for (;;)
- {
- t = lex ();
- if (t == tok_prec)
- {
- t = lex ();
- crule->ruleprec = symval;
- t = lex ();
- }
-
- if (!(t == tok_identifier || t == tok_left_curly))
- break;
-
- /* If next token is an identifier, see if a colon follows it.
- If one does, exit this rule now. */
- if (t == tok_identifier)
- {
- bucket *ssave;
- token_t t1;
-
- ssave = symval;
- t1 = lex ();
- unlex (t1);
- symval = ssave;
- if (t1 == tok_colon)
- break;
-
- if (!first_rhs) /* JF */
- first_rhs = symval;
- /* Not followed by colon =>
- process as part of this rule's rhs. */
- }
-
- /* If we just passed an action, that action was in the middle
- of a rule, so make a dummy rule to reduce it to a
- non-terminal. */
- if (action_flag)
- {
- bucket *sdummy;
-
- /* Since the action was written out with this rule's
- number, we must give the new rule this number by
- inserting the new rule before it. */
-
- /* Make a dummy nonterminal, a gensym. */
- sdummy = gensym ();
-
- /* Make a new rule, whose body is empty,
- before the current one, so that the action
- just read can belong to it. */
- nrules++;
- nitems++;
- record_rule_line ();
- p = XCALLOC (symbol_list, 1);
- if (crule1)
- crule1->next = p;
- else
- grammar = p;
- p->sym = sdummy;
- crule1 = XCALLOC (symbol_list, 1);
- p->next = crule1;
- crule1->next = crule;
-
- /* Insert the dummy generated by that rule into this
- rule. */
- nitems++;
- p = XCALLOC (symbol_list, 1);
- p->sym = sdummy;
- p1->next = p;
- p1 = p;
-
- action_flag = 0;
- }
-
- if (t == tok_identifier)
- {
- nitems++;
- p = XCALLOC (symbol_list, 1);
- p->sym = symval;
- p1->next = p;
- p1 = p;
- }
- else /* handle an action. */
- {
- copy_action (crule, rulelength);
- action_flag = 1;
- xactions++; /* JF */
- }
- rulelength++;
- } /* end of read rhs of rule */
-
- /* Put an empty link in the list to mark the end of this rule */
- p = XCALLOC (symbol_list, 1);
- p1->next = p;
- p1 = p;