Equation parser - where did I see it?

T

trashman.horlicks

Hi,
A few months ago, I saw an equation parser, written in c#, and using
regular expressions (I think!), but now I cannot recall where I saw
it- if anyone saw anything like this, could they please post the url?
From memory,
the parser not only dealt with operator precedence, but also the use
of brackets, so that any complicated expession could be re-written as
an equation that could be read from left-to-right, as a simple
sequence of sub-equations using basic operators, +,-,/,*

The reason why I ask is that I am anticipating user input into a form
as a string, and I need to convert it into
an equation. The user inputted expression could be something like (a+
(b-d)*(e-c))/f so I need to find a way to parse it.

TIA

Paul
 
C

ClayB

One other comment is that there are commercial products that would
allow you to write code that would input a string like (a+(b-c)*(e-c)/
f, identify the unknowns a,b,c,d,e,f, and then allow your user to
input the values for these unknowns and finally compute the entered
expression.

===============================
Clay Burch
Syncfusion, Inc.
 
W

William Stacey [C# MVP]

Taking a dependancy on powershell may not work for you, but would allow you
to invoke any expression you can do on the command line and also can use any
..net lib (i.e. system.math) or external lib. And you can script your host
with it too if needed.

--
William Stacey [C# MVP]
PCR concurrency library: www.codeplex.com/pcr
PSH Scripts Project www.codeplex.com/psobject


| Hi,
| A few months ago, I saw an equation parser, written in c#, and using
| regular expressions (I think!), but now I cannot recall where I saw
| it- if anyone saw anything like this, could they please post the url?
| >From memory,
| the parser not only dealt with operator precedence, but also the use
| of brackets, so that any complicated expession could be re-written as
| an equation that could be read from left-to-right, as a simple
| sequence of sub-equations using basic operators, +,-,/,*
|
| The reason why I ask is that I am anticipating user input into a form
| as a string, and I need to convert it into
| an equation. The user inputted expression could be something like (a+
| (b-d)*(e-c))/f so I need to find a way to parse it.
|
| TIA
|
| Paul
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top