comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Calculator and Operator Precedence
Date: 19 Feb 2002 12:24:50 -0500
Date: 2002-02-19T17:29:11+00:00	[thread overview]
Message-ID: <uheodjsf1.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 3C727CCF.505D83E0@brighton.ac.uk

jon <jkjw@brighton.ac.uk> writes:

> i ve built a basic calculator which asks user for expression using a
> console.
> 
> eg
> 
> Enter expression : 1 + 2 + 3 * 4
> 
> now i need to make it so it can handle Operator Precendence
> 
> whats the best way of doing this ? Arrays ?

You need a tree structure, with operators at the nodes and operands at
the leaves.

You can implement a tree using arrays, or linked lists, or many other
things. Or you can use an existing package from on of the Ada
libraries available. See http://www.adapower.com/reuse/index.html

Hmm, I just noticed my library isn't there; I'll have to fix that :).
See http://users.erols.com/leakstan/Stephe/Ada/sal.html

-- 
-- Stephe



  reply	other threads:[~2002-02-19 17:24 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 [this message]
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
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