You may write your own
expression parser
(see, for instance [
^] or you may use a tool, such
flex
[
^]+
bison
[
^] or
ANTLR
[
^], for this task.
You may even embed a script language (like, for instance
Lua
[
^]) in your application and make it evaluate the expression for you.