From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] bison problem, not plan9 related
Date: Wed, 21 Oct 2009 11:47:36 -0700 [thread overview]
Message-ID: <dd6fe68a0910211147n56655babse510d8fc02112582@mail.gmail.com> (raw)
In-Reply-To: <a560a5d00910211052q2995c2afoae585c94f555947b@mail.gmail.com>
> %token ATOM
> %left '+'
> %left REP
>
> block: ATOM
> | REP block
> | block block %prec '+'
> 5 block: REP block .
> 6 | block . block
>
> ATOM shift, and go to state 3
>
> ATOM [reduce using rule 5 (block)]
This says that yacc isn't sure how to decide,
having read REP block, between shifting ATOM
or applying the REP block reduction.
> 6 block: block . block
> 6 | block block .
>
> ATOM shift, and go to state 3
>
> ATOM [reduce using rule 6 (block)]
This says that yacc isn't sure how to decide,
having read block block, between shifting ATOM
or applying the block block reduction.
To know how to decide, yacc needs a precedence
for the thing being shifted and the rule. You've
given precedences for each rule (REP block has
REP's precedence, and block block has +'s thanks
to the override) but not to ATOM.
Concretely, when yacc sees REP block ATOM
it isn't sure whether that's (REP block) ATOM or
REP (block ATOM).
Instead of
> %token ATOM
> %left '+'
> %left REP
you probably want
%left '+'
%left REP
%nonassoc ATOM
This wasn't an issue in the first grammar because the shift/reduce
decision had to be made when looking at the '+' instead
of when looking at ATOM, and the '+' did have a precedence.
Russ
next prev parent reply other threads:[~2009-10-21 18:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-21 17:52 Rudolf Sykora
2009-10-21 18:03 ` Rudolf Sykora
2009-10-21 18:46 ` Skip Tavakkolian
2009-10-21 19:44 ` Rudolf Sykora
2009-10-21 18:47 ` Russ Cox [this message]
2009-10-21 19:41 ` Rudolf Sykora
2009-10-21 19:48 ` Rudolf Sykora
2009-10-21 20:21 ` Russ Cox
2009-10-21 20:28 ` Rudolf Sykora
2009-10-21 20:03 ` Bakul Shah
2009-10-21 20:18 ` Rudolf Sykora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd6fe68a0910211147n56655babse510d8fc02112582@mail.gmail.com \
--to=rsc@swtch.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).