Re: Expression parser
From: Cor Ligthert (notmyfirstname_at_planet.nl)
Date: Wed, 5 Jan 2005 09:59:27 +0100
Interesting answer, I keep it in mind.
> You can do this with Regular expressions. Francesco Balena's book
> "Programming Microsoft Visual Basic.Net" has a complete solution with full
> code on the companion CD. There is a newer version of the book for .Net
> 2003 but it still has all the code you need. It is surprisingly compact
> when done with Regex and uses only one class to do all the work.
> "Joe" <J_no_spam@_no_spam_Fishinbrain.com> wrote in message
>>I have a screen which allows the user to create mathematical expressions
>> using a combination of literal values, other expressions and field
>> For example if I have the following:
>> // fields
>> string val1 = "2";
>> string val2 = "1";
>> string val3 = "4.5";
>> string expr1 = "8 * val1 / val2 + val3";
>> string expr2 = "val2 * expr1 + 3";
>> I need to parse this out to perform the actually calculation.
>> string expr2 would expand to 1 * 8 * 2 / 1 + 3 + 3;
>> Any suggestions on how to do this? I already created a number of classes
>> handle this but I'm still missing some possible combinations.