Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: "James Harris \(es\)" Newsgroups: comp.compilers Subject: Re: Compiling expressions Date: Thu, 7 Mar 2013 11:11:59 -0000 Organization: A noiseless patient Spider Lines: 35 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-03-005@comp.compilers> References: <12-12-035@comp.compilers> <13-01-013@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1362711211 28766 64.57.183.58 (8 Mar 2013 02:53:31 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 8 Mar 2013 02:53:31 +0000 (UTC) Keywords: parse Posted-Date: 07 Mar 2013 21:53:31 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:866 "James Harris" wrote in message > On Dec 29 2012, 1:11 pm, James Harris wrote: > ... > >> 1. Hand-written, not the output of a parser generator. >> 2. Efficient and without backtracking. >> 3. Precedences (and possibly associativities) defined in tables. >> 4. Output to be a tree structure. >> 5. Parenthesised subexpressions allowed. >> 6. Some operator families are *not* to associate with each other. See >> below. >> 7. Monadic prefix, dyadic infix and monadic postfix operators are all >> allowed. >> 8. Prefix and infix operators can use some same symbols (e.g. minus >> sign). >> >> Infix and postfix operators use distinct symbols. > > ... > > Here is an idea for an expression parser to try to address the points > mentioned. I am not sure if it covers all the bases yet. In case anyone is later looking for some code to parse expressions I should say that I have placed an updated copy at https://groups.google.com/group/comp.lang.misc/browse_frm/thread/c21bf4f4cd55f345 The most important changes were to allow for low-precedence postfix operators (the original code here only allowed them to be highest precedence) and add some detailed documentation. James