You can start by looking at
http://www.antlr.org/[
^]
and
http://boost-spirit.com/home/[
^]
Antlr is a parser generator, with lots of extra goodies. Generates code for java, c#, c, and other programming laguages.
boost spirit allows you to define your parser directly in C++, using constructs that closely resembles Extended Backus–Naur Form.
compilation involves parsing as the first step towards code generation.
parse programming language, possibly optimize, generate machine code - or possibly other stuff ...
Regards
Espen Harlinn