This is something I've recently engaged upon myself, and let me tell you,
it's no small effort. I'm probably about a third of the way there (I'm
currently building a parse tree). Mind you I haven't looked at the
System.CodeDom.Compiler namespace though I now intend to - it's the first
I've heard about it.
Here is a good tutorial on one way to go about it,
http://www.flipcode.com/tutorials/tut_scr01.shtml
That uses the old Lex/Yacc tools, or at least their win32 counterparts and
implements it in C/C++. Those tools still only get you about half way and
learning to use them again requires a bit of effort. Personally I've read up
on compiler theory and design and am coding everything from the start
myself. So far so good I just need to dedicate more hours (days/weeks) to
the job.
BTW, the basic constituents of any scripting engine are the
Lexer -> Abstract Syntax Tree/Parse Tree -> Byte Code Generator -> Virtual
Machine
The Tree can be optional but it avails you a nice structure for analysing
the code (debugging etc) and probably simplifies the process of getting from
token stream to byte code.
As for C# generating compiler tools there is
http://www.scifac.ru.ac.za/coco/. All the tools require you to learn a bit
about compiler theory (grammars and BNF notation etc) so you can specify
your language and also of course there own usage and in the end they only
get part of the job done, hence of chosen to avoid them.
That said if I can get System.CodeDom.Compiler to do it for me I will be
taking a new route.