From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d5ed2292349acc76 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-19 09:36:15 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!194.213.69.151!news.algonet.se!algonet!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Calculator and Operator Precedence Date: 19 Feb 2002 12:24:50 -0500 Organization: NASA Goddard Space Flight Center Message-ID: References: <3C727CCF.505D83E0@brighton.ac.uk> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1014139751 17056 128.183.220.71 (19 Feb 2002 17:29:11 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 19 Feb 2002 17:29:11 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:20127 Date: 2002-02-19T17:29:11+00:00 List-Id: jon 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