comp.lang.ada
 help / color / mirror / Atom feed
From: "Vadim Godunko" <vgodunko@vipmail.ru>
Subject: Re: Calculator and Operator Precedence
Date: Fri, 22 Feb 2002 23:14:20 +0300
Date: 2002-02-22T23:14:20+03:00	[thread overview]
Message-ID: <mailman.1014408962.1100.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: mailman.1014394382.27785.comp.lang.ada@ada.eu.org

Hello,

Please send me those sources. Very intresting.

Regards,
Vadim
----- Original Message ----- 
From: "Steven Deller" <deller@smsail.com>
Newsgroups: comp.lang.ada
Sent: Friday, February 22, 2002 7:10 PM
Subject: RE: Calculator and Operator Precedence


> 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).  Since each stack only needs a maximum of 5 entries
> (because of Ada's left to right evaluation for equal precedence
> operators) they could have been done with simple arrays (though I used a
> stack package abstraction).
> 
> You don't need trees.  
> 
> I thought about using a grammar-based parse (Matthew H's solution), but
> it has some problems with recognizing where you are in the grammar.
> 
> Unary operators are the biggest complication.
> 
> About 50 lines of code.  If you can prove you're not doing a student
> exercise, I'd be glad to send you the sources.
> 
> Regards,
> Steve
> 




      parent reply	other threads:[~2002-02-22 20:14 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
2002-02-25  9:17           ` Dmitry A. Kazakov
2002-02-22 20:14         ` Vadim Godunko [this message]
replies disabled

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