Hi, I want to make a C or C# code that will be used to convert from some expressiont to do some work such as like Addition or sub.
A:
Lexing and Parsing is an entire sub-discipline of Computer Science - you're not going to get a complete solution that you can just pick up and drop into place.
If you want to use C, check out Flex and Bison, two tools that will help you create a working parser.
If you want to use C#, try Antlr.
If you're willing consider other .NET solutions, try FsLex and FsYacc which work with F# to create a parser that works from any .NET language.
Bevan
2010-10-10 18:22:16
I've found FsLex and FsYacc to be a bit unrefined as tools go.
ChaosPandion
2010-10-10 18:38:24
A:
I suspect this doesn't answer your question, but it is technically an answer for the question as you described it.
Expression<Func<int, int, int>> addition = (x, y) => x + y;
addition
now holds your expression tree, which you can interrogate to your heart's content.
Kirk Woll
2010-10-10 18:33:19