Can someone point me in the right direction, I have a parser in lex I want to use in C#, has anyone before done something like this, or mixed c/c++ with C#?
EDIT: More specifically I would like to parse mathematical expressions and XML.
Can someone point me in the right direction, I have a parser in lex I want to use in C#, has anyone before done something like this, or mixed c/c++ with C#?
EDIT: More specifically I would like to parse mathematical expressions and XML.
There are a number of C# Lex processors out there. For instance:
You can make a dll of c code and use it in c# with PlatformInvoke mechanisms available.
Even you can create a solution containing two projects, one of them is a Library Project containing the c/c++ source and another one is c#.
If you will be using this module in desktop/server applications only (and not on Silverlight or Compact Framework for example) you could build your C/C++ code with clr support and use it from C#.
I have used a C++ version of flex with great success.
You can get the windows pre-built binaries from
http://www.kohsuke.org/flex++bison++/
Specifically, I have used this to parse an EBNF grammer of more than a dozen rules ( too many for boost::spirit ) which take as input user scripts with statements like
IF a > 10 AND b < -22 THEN OUTPUT X
So I think it would do fine for the mathematical expressions you mention.
Parsing XML is a different story. There are so many purpose built libraries for parsing XML why would you want to roll your own? There is TinyXML ( http://www.grinninglizard.com/tinyxml/ ) and CMarkup ( http://www.firstobject.com/dn_markup.htm ) both of which I have used successfully on several projects.