comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Marc Bourguet <jm@bourguet.org>
Subject: Re: Calculator and Operator Precedence
Date: 22 Feb 2002 17:55:49 +0100
Date: 2002-02-22T17:55:49+01:00	[thread overview]
Message-ID: <3c76780d$1@news.cadence.com> (raw)
In-Reply-To: mailman.1014394382.27785.comp.lang.ada@ada.eu.org

"Steven Deller" <deller@smsail.com> writes:

> Interestingly, I just cobbled together Ada code to parse arbitrary Ada
> expressions consisting of just operators, parentheses, and literals (I'm
> probably going to make it handle type conversions as well).
> 
> It uses two stacks (one for operands, one for operators), and recursion
> (on parentheses). 

Why do you need recursion?  Parentheses can be handled with the two
stacks, pushing opening parenthese on the operator stack and applaying
operators till a openening parenthese is on TOS when seeing a close
parenthese.

BTW, This parsing technique can be extented (see weak operator
precedence in the litterature) and has been used quite a lot before
LALR grammar where showed to be usefull.

-- 
Jean-Marc



  reply	other threads:[~2002-02-22 16:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-19 16:26 Calculator and Operator Precedence jon
2002-02-19 17:24 ` Stephen Leake
2002-02-19 20:00 ` Matthew Heaney
2002-02-20  8:03 ` Phil Thornley
2002-02-20 15:28   ` Jon
2002-02-20 15:45     ` John English
2002-02-22 16:10       ` Steven Deller
2002-02-22 16:55         ` Jean-Marc Bourguet [this message]
2002-02-25  9:17           ` Dmitry A. Kazakov
2002-02-22 20:14         ` Vadim Godunko
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox