Re: Is This Expression Parsing Feasible?

Jeff Kenton <jeffrey.kenton@comcast.net>
Sat, 30 Jun 2007 13:16:58 -0400

          From comp.compilers

Related articles
Is This Expression Parsing Feasible? Milburn.Young@gmail.com (2007-06-27)
Re: Is This Expression Parsing Feasible? martin@gkc.org.uk (Martin Ward) (2007-06-28)
Re: Is This Expression Parsing Feasible? torbenm@app-3.diku.dk (2007-06-28)
Re: Is This Expression Parsing Feasible? milburn.young@gmail.com (Milburn Young) (2007-06-28)
Re: Is This Expression Parsing Feasible? jeffrey.kenton@comcast.net (Jeff Kenton) (2007-06-29)
Re: Is This Expression Parsing Feasible? jeffrey.kenton@comcast.net (Jeff Kenton) (2007-06-30)
| List of all articles for this month |

From: Jeff Kenton <jeffrey.kenton@comcast.net>
Newsgroups: comp.compilers
Date: Sat, 30 Jun 2007 13:16:58 -0400
Organization: Compilers Central
References: 07-06-066 <200706280937.53681.martin@gkc.org.uk> 07-06-069
Keywords: parse, comment
Posted-Date: 30 Jun 2007 15:03:04 EDT

Milburn Young wrote:
> On 6/28/07, Martin Ward <martin@gkc.org.uk> wrote:
>> On Wednesday 27 Jun 2007 19:37, Milburn.Young@gmail.com wrote:
>>> The parser would scan through the entire list of tokens (left
>>> to right) noting the token(s) with the highest precedence and making
>>> sub-trees out of those tokens
.. . .


>> What about parentheses in the expression?
.. . .


> I see parentheses
> as a (paired) unary operator with the highest of precedences.


Another way to deal with parentheses is to increase the precedence of
each operator according to the nesting of the parens. If you have 20
precedence levels, just add (paren depth) * (highest precedence, i.e.,
20) to each operator's precedence on a first pass. Then remove the
parens and continue according to your original plan.


Another good use for the first pass is to validate the input expression
syntax.


jeff
[How can you validate the input expression syntax without parsing it? -John]


Post a followup to this message

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