Parser Routine in C#

  • Thread starter Thread starter David
  • Start date Start date
D

David

I need to write a small routine in C# that will parse/decode/evaluate
a complex if statement that will be entered by a user.

, ex. "a= 1 and b = 2 and ((c = 3 and d = 4) or (e = 1 and f = 3))

I know that this is compiler 101, but I have not done this is 20 years
and need some points on how to proceed. I remember using a tree.

Code examples in VB, C++, etc. would be great. All I need is a
direction and I go from there.

Thanks
 
Hi David,

I suggest you to use third party tools because you need more than one
year for building own good parser.
Try Cioina.dll from pkCioinaEval package
http://www.geocities.com/alexei_cioina/cioinaeval.html

Cioina.dll equivalent of your expression is:
And(Eq(a,1), Eq(b, 2) ,Or(And(Eq(c, 3),Eq(d ,4)),And(Eq(e, 1),Eq(f ,
3))))
 

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

Back
Top