Re: Compiling expressions

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Fri, 4 Jan 2013 10:18:26 +0100

          From comp.compilers

Related articles
[3 earlier articles]
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-02)
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-02)
Re: Compiling expressions matzebraun@googlemail.com (matzebraun@googlemail.com) (2013-01-03)
Re: Compiling expressions torbenm@diku.dk (2013-01-03)
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-03)
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-03)
Re: Compiling expressions mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2013-01-04)
Re: Compiling expressions james.harris.1@gmail.com (James Harris) (2013-01-06)
Re: Compiling expressions vonbrand@inf.utfsm.cl (Horst von Brand) (2013-01-14)
Re: Compiling expressions james.harris.1@gmail.com (James Harris \(es\)) (2013-03-07)
| List of all articles for this month |
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Newsgroups: comp.compilers
Date: Fri, 4 Jan 2013 10:18:26 +0100
Organization: cbb software GmbH
References: 12-12-035 12-12-038 13-01-012
Keywords: parse
Posted-Date: 04 Jan 2013 11:41:50 EST

On Thu, 3 Jan 2013 12:01:33 -0800 (PST), James Harris wrote:


>> I extended the method, which fairly old, towards non-associativity (#6),
>> advanced parenthesis (#5, keyed parameter associations), and split
>> association priorities into left-right pairs. But basically it is still the
>> same twin-stack method. Everything is table-driven, of course.
>
> Is it based on a Pratt parser? I see your comment and saw left and
> right priorities mentioned. I have never spent the time to understand
> Pratt parsers or why they need both. To deal with left- and right-
> associativity if I ever need to I was thinking to use the lowest bit
> of the precedence - something along the lines of clearing the bit on
> one side before a comparison. Then each operator would only need a
> single precedence.


Priority + direction sufficiently less general. For example it fails to
capture asymmetrically associated operations, e.g. assignment. Provided you
wanted assignment as an operator, you would like to have it rather this
way:


      a + b := c + d --> a + (b := (c + d))


Priority + direction model cannot handle this. Here the left priority of :=
must be sufficiently higher than the right one.


--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.