Currently I am trying to improve some fpc-debuggers. It started with the ability to call functions from within the (fpdebug) debugger. To be able to do so, small changes to the expression-evaluator were needed.
And then it struck me that fpDebug has it’s own expression-parser, while fpc itself comes with fcl-passrc, a full blown Pascal-parser. Martin Friebe, who knows the debugger-code inside out, ensured me that it was not difficult to extend the existing parser. Nevertheless I tried if it was possible to use fcl-passrc to parser the expressions. After all, a stand-alone expression-evaluator could also be useful for other projects.
For a commercial project we at CNOC once wrote a form-validation system, based on Pascal expressions. Users can build their own forms, and enter Pascal-expressions which are evaluated to validate the input. Both server-side and client-side. It also uses fcl-passrc and it could work as a base for the new expression-evaluator.
The result can be found here. A separate package that adds the ability to fcl-passrc to not ony parse, but also evaluate expressions. It comes with a small example which shows how easy it is to embed it into your own application. And even supports function-calls. After all, that’s where it all started about.
There are some caveats, though. It only works with fpc version 3.2.1 and above, so not with the current release. And I know that it is not able to parse floating-point values. Both easy solvable, but I leave it to others to do so. This way, by improving the expression-evaluator in their own applications, they help me to receive my goal to improve debugging Free Pascal applications.