Re: Expression parser

From: Cor Ligthert (notmyfirstname_at_planet.nl)
Date: 01/05/05


Date: Wed, 5 Jan 2005 09:59:27 +0100

Robby,

Interesting answer, I keep it in mind.

Thanks,

Cor

"Robby" <edmund@not.my.email.com>

>
> 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.
>
> Robby
>
>
> "Joe" <J_no_spam@_no_spam_Fishinbrain.com> wrote in message
> news:eKDshQu8EHA.2060@TK2MSFTNGP10.phx.gbl...
>>I have a screen which allows the user to create mathematical expressions
>> using a combination of literal values, other expressions and field
>> values.
>>
>>
>> For example if I have the following:
>>
>> // fields
>> string val1 = "2";
>> string val2 = "1";
>> string val3 = "4.5";
>>
>> //expressions
>> 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
>> to
>> handle this but I'm still missing some possible combinations.
>>
>>
>
>



Relevant Pages

  • Re: Question about Sun JAVAC
    ... I discuss this problem in my book "Design Your Own .Net Language and ... My book contains a discussion of regular expressions which attempts to ... I was last spring engaged in work which involved frequently searching ...
    (comp.programming)
  • Re: bash, grep, and regular expressions
    ... > |them lately using Jeffrey Friedl's book Mastering Regular Expressions ... > specifically requests listing all hidden files and directories, ... > the grep command. ...
    (Debian-User)
  • Re: Regex.IsMatch help
    ... You could use the Parse or the TryParse methods on the Single, Double or Decimal structs, depending on your needs and your framework version. ... if you wanted to find a regex for a more ... of regular expressions - expressions that will work in .NET may not ...
    (microsoft.public.dotnet.general)
  • Re: Fast NFA engine anyone?
    ... Regular expressions are exactly what one can match with a ... sub-expressions and back-references. ... ideas of how to leave markers in a DFA implementation of regexps. ...
    (comp.compilers)
  • Re: Regular Express Pattern Help!
    ... that's probably because you never learned regular expressions. ... they don't produce exceptions or endless loops due to bad/unexpected data ... i.e. the pattern can't mess around with any ...
    (microsoft.public.dotnet.general)