Libre RISC-V Mailing list Archives (accessible via public-inbox)
 help / color / Atom feed
From: Jacob Lifshay <programmerjake@gmail.com>
To: Libre-RISCV General Development <libre-riscv-dev@lists.libre-riscv.org>
Subject: Re: [libre-riscv-dev] parser precedence, code review / checking needed
Date: Fri, 3 Apr 2020 13:08:18 -0700
Message-ID: <CAC2bXD7hd1zUA1bkWUsJguOfukN56ZW2rVCRi+51cCumRScmkA@mail.gmail.com> (raw)
In-Reply-To: <CAPweEDz7zK4Db-qM+=aUd2ctsTjHJjBmRt9W3VMtbF9NV6rc9w@mail.gmail.com>

On Fri, Apr 3, 2020 at 11:50 AM Luke Kenneth Casson Leighton
<lkcl@lkcl.net> wrote:
>
> On Fri, Apr 3, 2020 at 7:23 PM Jacob Lifshay <programmerjake@gmail.com> wrote:
> >
> > On Fri, Apr 3, 2020, 08:20 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
> > wrote:
> >
> > > if anyone knows how to resolve operator precedence, my logic-dyslexia
> > > is kicking in and i am having difficulty working out which operators
> > > are supposed to be in which order, for bit-wise AND, OR, and
> > > PLUS/MINUS, MUL/DIV.  someone else did the PLUS/MINUS MUL/DIV, i'm
> > > attempting to add AND and OR and am getting it wrong
> > >
> >
> > The way I always did it is by changing the grammar to have one non-terminal
> > symbol per precedence level. Example code from my LR(1) parser generator:
> > https://github.com/programmerjake/parser-generator/blob/master/test.parser#L108-L120
>
> ply has something called "precedence" which is a list-of-tuples that
> helps resolve parser ambiguities.

Just because something has a feature, doesn't mean that it's the best
way to do it.

As far as I can tell, it's working now.

Jacob

_______________________________________________
libre-riscv-dev mailing list
libre-riscv-dev@lists.libre-riscv.org
http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 15:19 Luke Kenneth Casson Leighton
2020-04-03 18:22 ` Jacob Lifshay
2020-04-03 18:49   ` Luke Kenneth Casson Leighton
2020-04-03 20:08     ` Jacob Lifshay [this message]
2020-04-03 21:44       ` Luke Kenneth Casson Leighton
2020-04-03 20:41   ` Hendrik Boom

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=CAC2bXD7hd1zUA1bkWUsJguOfukN56ZW2rVCRi+51cCumRScmkA@mail.gmail.com \
    --to=programmerjake@gmail.com \
    --cc=libre-riscv-dev@lists.libre-riscv.org \
    /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

Libre RISC-V Mailing list Archives (accessible via public-inbox)

Archives are clonable: git clone --mirror https://inbox.libre-soc.org/libre-riscv-dev

Example config snippet for mirrors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git