| [reply] |
...for even further reading, the next step would be the classical
Dragon book on compiler design...
Essentially, a compiler translates from one language into another
— typically from a higher level language to a lower one, but
there's no reason (in theory) it couldn't convert from Perl to C++ source.
It's just that compilers are usually non-trivial to write, so no one
may have done it yet...
In this particular case (as parsing Perl is a particularly
non-trivial task), it would probably be a good idea to reuse existing
code (such as the regular source of the Perl interpreter, or PPI) for the side of
parsing and constructing a syntax tree.
You'd "just" :) have to add code generation for the target language from
the syntax tree, paying particular attention on how to realize the highly dynamic facilities which Perl provides in a more "static" language like C/C++.
| [reply] |
In fact, "The Dragon Book" is the book I refer to in the opening lines of the link I posted earlier (but by it's proper name, "Compilers: Tool Tips and Techniques"). It's great. Huge. Dense. But well written. I will never finish it...
There's some pretty in depth stuff on lex and yacc in there, too.
| [reply] |