in reply to Language Conversion

If you don't find anything, I would start by writing C/C++ functions to replace all the perl built-ins used. This is a very very complicated project IMO.

Hashes, if not basically all variables, will have to be the product of some function, as will regex's. I do not think any kind of "find and replace" strategy will work very well in the end: you should investigate lexing and parsing if you are not already familiar with the topic. This might give you the general idea, read supplementary to something else:

http://www.intergate.com/~halfcountplus/CBCP/parsing.html

(there's some simple examples in C of how a language parser works, based on the "Dragon Book" stuff mentioned by almut; fascinating and fun -- good luck!)

Replies are listed 'Best First'.
Re^2: Language Conversion
by Bloodnok (Vicar) on Sep 09, 2009 at 16:03 UTC
    ...for further reading i.e. as the exercise for the interested reader, Steve_BZ could do worse than get a copy of the O'Reilly lex & yacc nutshell reference - IMO, most enlightening.

    A user level that continues to overstate my experience :-))

      ...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++.

        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.