Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!think!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!aries!mcdonald From: mcdonald@aries.scs.uiuc.edu (Doug McDonald) Newsgroups: comp.lang.c Subject: Re: Wanted: Expression Evaluator Message-ID: <1990Feb19.012607.22402@ux1.cso.uiuc.edu> Date: 19 Feb 90 01:26:07 GMT References: <4365@jarthur.Claremont.EDU> Sender: news@ux1.cso.uiuc.edu (News) Reply-To: mcdonald@aries.scs.uiuc.edu (Doug McDonald) Organization: School of Chemical Sciences, Univ. of Illinois at Urbana-Champaign Lines: 40 In article <4365@jarthur.Claremont.EDU> ssdken@jarthur.Claremont.EDU (Ken Nelson) writes: >Hi: > > I need the C source for an expression evaluator. Something that can > understand things like this: > > A/B*LOG(D) > > > The evaluator would get A B and D from a symbol table, evaluate the > expression and return the result. > > Anybody have such a beast???? > > > Thanks, > > > Ken Nelson > Principal Engineer > Software Systems Design > 3627 Padua Av. > Claremont, CA 91711 > (714) 624-3402 I have the guts of two, one an interpreter, one a compiler. The compiler requires that your machine be able to execute data - many Unixes are seriously deficient in this regard. And, of course, you have to put in the opcodes for your computer if you want the compiler. The presently finished ones assume doubles. They have a very limited hard-coded set of symbols, but adding a symbol table lookup is trivial - except, of course, you have to code in the symbol table at compile time. These will evaluate an expression of arbitrary complexity by recursive descent. They have a fairly good syntax checker. Interestingly, the code is amazingly small. Send me e-mail if interested. Doug McDonald (mcdonald@aries.scs.uiuc.edu)