9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Rudolf Sykora <rudolf.sykora@gmail.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 22:28:02 +0200	[thread overview]
Message-ID: <a560a5d00910211328j34c7bb17x192f81cc7234cb5e@mail.gmail.com> (raw)
In-Reply-To: <dd6fe68a0910211321x57fc61a6i8f2943d20e644bfd@mail.gmail.com>

I must say, many thanks!
Ruda

2009/10/21 Russ Cox <rsc@swtch.com>:
>> Ok, thanks, this seems to have solved it.
>> So the %nonassoc says to the parser that
>> (REP block) ATOM
>> is the right decision as opposed to
>> REP (block ATOM)
>> right?
>
> %token declares its arguments as tokens but
> does not give them any precedence level.
>
> %left, %right, and %nonassoc also declare their
> arguments as tokens.  in addition, each such line
> introduces a new precedence level stronger than
> the ones introduced by previous lines.
>
> if a shift/reduce conflict involves different precedences,
> the stronger precedence always wins.
>
> if a shift/reduce conflict is a tie between identical precedences,
> the resolution depends on which of the three lines
> (%left, %right, or %nonassoc) introduced the precedence.
>
> precedences introduced by %left resolve the tie
> by reducing; this creates left-to-right associativity (x-y-z).
>
> precedences introduced by %right resolve the tie
> by shifting; this creates right-to-left associativity (x^y^z in hoc).
>
> precedences introduced by %nonassoc do not resolve
> the tie.  they leave it as a conflict that gets reported.
>
> if you're defining a precedence that is not intended
> to be associative, much of the time it doesn't matter
> which you pick, because your grammar is likely to
> be such that ties never happen.  but %nonassoc is
> still the safe choice.
>
> in the running example, %nonassoc by itself
> doesn't say which of those two is right.  it just
> defines a precedence for ATOM, which is used
> as the precedence for shifting ATOM.
> because the REP block and block block rules
> have precedences too, the ambiguity can be
> resolved by comparing the precedences.
> which way things get resolved depends on whether
> the %nonassoc line comes before or after the
> other precedences, not on the meaning of %nonassoc.
>
> i said
>
>> %left '+'
>> %left REP
>> %nonassoc ATOM
>
> and that will give you REP block ATOM == REP (block ATOM)
> which is probably not what you want.  to tweak it,
> just move the %nonassoc line above the two %left lines.
>
> russ
>
>



  reply	other threads:[~2009-10-21 20:28 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
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 [this message]
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=a560a5d00910211328j34c7bb17x192f81cc7234cb5e@mail.gmail.com \
    --to=rudolf.sykora@gmail.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).