Undocumented feature (or bug) in yacc

Inventor of micro-S sambo at ukma.UUCP
Thu May 16 07:11:02 AEST 1985


     I think I have found an undocumented feature or bug in yacc.  Perhaps
someone will be able to correct me on this, or confirm that I am speaking
the truth.
     Here is the scenario: I have told yacc that the each element in the
value stack is to be a union.  In addition, I have specified that certain
nonterminals return certain union members.  Suppose I have a rule of the form:
          rulex: s1 s2 {$$ = $2;} s3 ;
where rulex is supposed to return something of type tx, and s2 also returns
something of type tx, but s1 and s3 return something of some other type.  I
want rulex to return the same thing s2 returned, as can be seen from the
action between s2 and s3.  However, since this action does not appear after
s3, i.e. the last symbol in the rule, yacc doesn't know what this rule is
returning, and therefore produces an error saying that the default action for
this rule will possibly produce a type clash.  (Incidentally, the line number
mentioned in the error message is some line number after the line number where
the rule actually appeared.)  So, is this the way it's supposed to work, and if
so, why isn't it documented anywhere (by anywhere I mean the paper `Yacc: Yet
Another Compiler-Compiler' by Stephen C. Johnson)?
     Please respond to me by mail, since I do not subscribe to this group.  I
will summarize the responses I receive at a later time.
-----------------------------------------
Samuel A. Figueroa, Dept. of CS, Univ. of KY, Lexington, KY  40506-0027
ARPA: ukma!sambo<@ANL-MCS>, or sambo%ukma.uucp at anl-mcs.arpa,
      or even anlams!ukma!sambo at ucbvax.arpa
UUCP: {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!sambo,
      or cbosgd!ukma!sambo

	"Micro-S is great, if only people would start using it."



More information about the Comp.unix.wizards mailing list