Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news.misty.com!news.iecc.com!.POSTED!nerds-end From: "Dmitry A. Kazakov" Newsgroups: comp.compilers Subject: Re: Compiling expressions Date: Fri, 4 Jan 2013 10:18:26 +0100 Organization: cbb software GmbH Lines: 29 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-01-014@comp.compilers> References: <12-12-035@comp.compilers> <12-12-038@comp.compilers> <13-01-012@comp.compilers> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: leila.iecc.com 1357317710 782 64.57.183.58 (4 Jan 2013 16:41:50 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 4 Jan 2013 16:41:50 +0000 (UTC) Keywords: parse Posted-Date: 04 Jan 2013 11:41:50 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:837 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