🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.pascal.misc
17 messages
17 total messages Started by Aristotle Tue, 13 Feb 1996 01:39
Writing an expression evaluator
#1
Author: Aristotle
Date: Tue, 13 Feb 1996 01:39
7 lines
929 bytes
Does anyone have any tips on how to go about writing an expression 
evaluator(one complex enough to handle Trig. functions). I am writing a 
program that uses expression and I would like to have the user be able to 
 enter their own expressions and have my program implement them. Any help 
 would be appreciated. Thanks in advance!
		
				John M. "Aristotle" De Cristofaro
Re: Writing an expression evaluator
#36
Author: Taj Khattra
Date: Thu, 15 Feb 1996 19:20
15 lines
1320 bytes
Andrew Koenig (ark@research.att.com) wrote:
: In article <311FEBD8.7305@cnj.digex.net> Aristotle <johndc@cnj.digex.net> writes:

: > Does anyone have any tips on how to go about writing an expression 
: > evaluator(one complex enough to handle Trig. functions). I am writing a 
: > program that uses expression and I would like to have the user be able to 
: >  enter their own expressions and have my program implement them. Any help 
: >  would be appreciated. Thanks in advance!

: Read ``The UNIX Programming Environment'' by Kernighan and Pike (Prentice-Hall).

The code for the calculator described in this bible is available at
ftp://plan9.att.com/csrc/hoc.bundle.Z

-taj
Re: Writing an expression evaluator
#60
Author: Simen Svale Skogsrud
Date: Thu, 15 Feb 1996 20:38
25 lines
1744 bytes

On 15 Feb 1996, Taj Khattra wrote:

> Andrew Koenig (ark@research.att.com) wrote:
> : In article <311FEBD8.7305@cnj.digex.net> Aristotle <johndc@cnj.digex.net> writes:
> 
> : > Does anyone have any tips on how to go about writing an expression 
> : > evaluator(one complex enough to handle Trig. functions). I am writing a 
> : > program that uses expression and I would like to have the user be able to 
> : >  enter their own expressions and have my program implement them. Any help 
> : >  would be appreciated. Thanks in advance!
> 
> : Read ``The UNIX Programming Environment'' by Kernighan and Pike (Prentice-Hall).
> 
> The code for the calculator described in this bible is available at
> ftp://plan9.att.com/csrc/hoc.bundle.Z
> 

I have a expression evaluator written in Turbo Pascal, it is part of a 
numerical solver I wrote with Staale Schumacher years back. It is as far 
as I can remember quite stable and safe. You can have it if you want it. 
If I don't remember wrong it has some ability to "define" functions aswell.

Simen Svale Skogsrud
Re: Writing an expression evaluator
#41
Author: Malcolm Smith
Date: Fri, 16 Feb 1996 06:56
24 lines
1245 bytes
Aristotle <johndc@cnj.digex.net> wrote:
>
> Does anyone have any tips on how to go about writing an expression 
> evaluator(one complex enough to handle Trig. functions). I am writing a 
> program that uses expression and I would like to have the user be able to 
>  enter their own expressions and have my program implement them. Any help 
>  would be appreciated. Thanks in advance!
> 		
> 				John M. "Aristotle" De Cristofaro


I have an expression evaluator written in C based on Polish notation.

It was primarily designed for normal mathemtical functions such as
add, subtract, multiply and divide.  It does, however, manager
brackets - using recursion.

It could be modified to include further functions.

Email me if you want the source code.


Malcolm Smith
mjsmith@mpx.com.au
Re: Writing an expression evaluator
#52
Author: Tom Wheeley
Date: Fri, 16 Feb 1996 22:07
26 lines
1595 bytes
In article <4g19rq$288@inferno.mpx.com.au>
           mjsmith@mpx.com.au "Malcolm Smith" writes:

> 
> I have an expression evaluator written in C based on Polish notation.
> 
> It was primarily designed for normal mathemtical functions such as
> add, subtract, multiply and divide.  It does, however, manager
> brackets - using recursion.
> 

That's cheating isn't it ?  r.p.n is a doddle to code :)

If you are doing this in Pascal (First in your newsgroups line) then check
out SWAG, which has several infix parsers (how you write math. expressions
in your code).

SWAG is big though, but it is a superlative programming resource.  It is
accessible from the clpb mini-FAQ (sorry, con't remember the swag url)
that FAQ is also on the Web at:

http://www.geocities.com/TimesSquare/2678/clpbfaq.html
-- 
* TQ 1.0 * The 'Just So Quotes'.
"Waiter, there's no fly in my soup!"
    	-- Kermit the frog
Re: Writing an expression evaluator
#19
Author: G. C. Straty
Date: Fri, 16 Feb 1996 23:52
20 lines
1524 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a basic 
spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found I 
still have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#20
Author: G. C. Straty
Date: Fri, 16 Feb 1996 23:52
20 lines
1524 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a basic 
spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found I 
still have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#21
Author: G. C. Straty
Date: Fri, 16 Feb 1996 23:53
20 lines
1524 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a basic 
spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found I 
still have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#22
Author: G. C. Straty
Date: Fri, 16 Feb 1996 23:54
28 lines
1985 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De CristofaroAristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a basic 
spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found I still 
have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#23
Author: G. C. Straty
Date: Fri, 16 Feb 1996 23:55
28 lines
1985 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De CristofaroAristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a basic 
spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found I still 
have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#24
Author: G. C. Straty
Date: Fri, 16 Feb 1996 23:56
28 lines
1985 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De CristofaroAristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a basic 
spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found I still 
have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#25
Author: G. C. Straty
Date: Fri, 16 Feb 1996 23:57
28 lines
1985 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De CristofaroAristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a basic 
spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found I still 
have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#26
Author: G. C. Straty
Date: Sat, 17 Feb 1996 00:00
20 lines
1547 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a
basic spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found 
I still have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#27
Author: G. C. Straty
Date: Sat, 17 Feb 1996 00:01
20 lines
1547 bytes
Aristotle wrote:
> 
> Does anyone have any tips on how to go about writing an expression
> evaluator(one complex enough to handle Trig. functions). I am writing a
> program that uses expression and I would like to have the user be able to
>  enter their own expressions and have my program implement them. Any help
>  would be appreciated. Thanks in advance!
> 
>                                 John M. "Aristotle" De Cristofaro

Borland Pascal-3 (if you can remember that far back) included
source code for what they called MicroCalc, sample code for a
basic spread sheet. In that code was a reasonably good function 
interpreter and evaluator which I have used often with good results. 
It will handle fairly complicated expressions as long as parens are
not to deep. In digging through my stack of old 5.25 DDs I found 
I still have it. If you are interested, I would be happy to make it
available to you.

straty@bldrdoc.gov
Re: Writing an expression evaluator
#49
Author: Timo Salmi
Date: Sat, 17 Feb 1996 06:37
20 lines
1394 bytes
Aristotle <johndc@cnj.digex.net> wrote:
> Does anyone have any tips on how to go about writing an expression 
> evaluator(one complex enough to handle Trig. functions). I am writing a 

There is information of Turbo Pascal experssion parsing in the
inevitable

 93045 Jan 1 09:31 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
 tsfaqp.zip Common Turbo Pascal Questions and Timo's answers

   All the best, Timo

P.S. Please let's cut back on the crossposting a bit. Followups
redirected to news:comp.lang.pascal.borland.

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
ts@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101,  Finland
Re: Writing an expression evaluator
#3
Author: anh
Date: Tue, 20 Feb 1996 01:46
14 lines
1070 bytes
Have you tried LEX and YACC? The tools could be an overkill but for more 
complex parsing stuff, they will save you time.

Anh

In article <31251AAF.2D0B@harrier.bldrdoc.gov>, "G. C. Straty" <straty@harrier.bldrdoc.gov> writes:
> Aristotle wrote:
>> 
>> Does anyone have any tips on how to go about writing an expression
>> evaluator(one complex enough to handle Trig. functions). I am writing a
>> program that uses expression and I would like to have the user be able to
>>  enter their own expressions and have my program implement them. Any help
>>  would be appreciated. Thanks in advance!
>> 
Re: Writing an expression evaluator
#6
Author: Samuel McGrath
Date: Thu, 22 Feb 1996 09:37
17 lines
1150 bytes
No no no, you're doing this all wrong!  The correct way to write an 
expression evaluator is with QBASIC.  Observe:

    PRINT "Enter an expression:"
    INPUT E$
    OPEN "TEMP.BAS" FOR OUTPUT AS #1
    PRINT #1, "PRINT " + E$
    PRINT #1, "RUN "+CHR$(34)+"THISPROG.BAS"+CHR$(34)
    CLOSE #1
    RUN "TEMP.BAS"

Jeez guys, I don't know why your complicating the issue with things like 
parsing and recursion.  Go figure.
 
-Sam McGrath

[insert smiley face here.  I refuse to.]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads