Path: utzoo!attcan!uunet!lll-winken!lll-lcc!lll-tis!helios.ee.lbl.gov!nosc!ucsd!ucsdhub!ucrmath!merlin From: merlin@ucrmath.UUCP (Mike Sullivan) Newsgroups: comp.lang.c Subject: Re: yacc with multiple attributes Message-ID: <368@ucrmath.UUCP> Date: 22 Jul 88 07:04:33 GMT References: <16345@brl-adm.ARPA> <838@garth.UUCP> <18773@cornell.UUCP> <859@garth.UUCP> <18840@cornell.UUCP> Sender: news@ucrmath.UUCP Reply-To: merlin@ucrmath.UUCP (Mike Sullivan) Organization: University of California at Riverside Lines: 36 In article <18840@cornell.UUCP> blandy@cs.cornell.edu (Jim Blandy) writes: >In article <859@garth.UUCP> smryan@garth.UUCP (Steven Ryan) writes: >>>Yacc will choke on: >>> >>>prod: >>> a { fiddle something } b c { first result } >>> | b { identical fiddle } b c { different result } >>> ; >> >>Do you mean? >> >> prod -> a {sem1} b {sem2} | a {sem3} c {sem4} > >No, I don't think so. Lots of stuff deleted. > >His problem was that yacc DOESN'T realize that >the two fiddles are the same, and thus has a conflict, since the one- >token lookahead won't solve this problem. Note that, yes, I do want >the same token after the { fiddle } s. However, in this case yacc doesn't NEED to realize that the two fiddles are the same, because both these productions appear in different states (being distinguished by the first token), and so there is no conflict. Notice that yacc knows which rule it is in by seeing an 'a' for the first and a 'b' for the second, there is no problem in this case. A case to demonstrate the problem in question here is this: prod: a { fiddle something } b c { first result } | a { identical fiddle } b c { different result } ; Now there is a reduce/reduce conflict on 'b', since yacc is in both rules at the same time (essentially), and 'b' does not distinguish the two rules. Mike Sullivan ucsd!ucrmath!merlin