www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D expression evaluator?

reply Chad J <gamerChad _spamIsBad_gmail.com> writes:
Has anyone written (in D, or something compilable to D like enki bnf) a 
D expression evaluator?  Even a parser?

For clarity, what I'm looking for is something that parses and evaluates 
D expressions like (a && foo(b))

This is related to my other post about a unittest helper module, since 
this is one component that would fulfill like 90% of the work for that 
project.

Apparently Don has something close in BLADE that works at compile time, 
though I don't know what source files do the parsing or how to use it 
for simply evaluating expressions rather than codegen.

Any help would be appreciated.
Aug 29 2007
next sibling parent reply BLS <nanali nospam-wanadoo.fr> writes:
I guess Jascha's APaged is all you need.
On http://apaged.mainia.de/ you'll find an example grammar that does 
simple expression evaluation.
HTH
Bjoern

Chad J schrieb:
 Has anyone written (in D, or something compilable to D like enki bnf) a 
 D expression evaluator?  Even a parser?
 
 For clarity, what I'm looking for is something that parses and evaluates 
 D expressions like (a && foo(b))
 
 This is related to my other post about a unittest helper module, since 
 this is one component that would fulfill like 90% of the work for that 
 project.
 
 Apparently Don has something close in BLADE that works at compile time, 
 though I don't know what source files do the parsing or how to use it 
 for simply evaluating expressions rather than codegen.
 
 Any help would be appreciated.

Aug 30 2007
parent Jascha Wetzel <"[firstname]" mainia.de> writes:
BLS wrote:
 I guess Jascha's APaged is all you need.
 On http://apaged.mainia.de/ you'll find an example grammar that does 
 simple expression evaluation.
 HTH
 Bjoern

the examples are very simplistic, but the D grammar from seatd has complete expression support: http://seatd.mainia.de/ it doesn't evaluate them yet, though.
Sep 05 2007
prev sibling parent Don Clugston <dac nospam.com.au> writes:
Chad J wrote:
 Has anyone written (in D, or something compilable to D like enki bnf) a 
 D expression evaluator?  Even a parser?
 
 For clarity, what I'm looking for is something that parses and evaluates 
 D expressions like (a && foo(b))
 
 This is related to my other post about a unittest helper module, since 
 this is one component that would fulfill like 90% of the work for that 
 project.
 
 Apparently Don has something close in BLADE that works at compile time, 
 though I don't know what source files do the parsing or how to use it 
 for simply evaluating expressions rather than codegen.

At present, my code doesn't cope with function calls, so it won't do what you want.
 
 Any help would be appreciated.

Sep 05 2007