Programming Language Translation

1.2k views Asked by At

I want to translate a simple programming language to another programming language. I only need that the output be syntactically valid so the code-generation part can me ditched.

Say, a subset of Python to C. I feel like I can cheat a bit and just 'copy-paste' most of the code, but say I wanted to have the list/string splicing of Python translated to C then it becomes non-trivial (for me, at the moment).

I made it all the way to a top-down recursive descent parser (actual grammar pending). What do I do next? I have a copy of the dragon book (2nd ed) but skimming ahead of where I am now, I don't see how I can do this and at the same time ditch code generation. I'm not sure if it's possible to ditch, but I don't need to produce an executable nor extend the program for other output languages to need intermediate code.

I'm stuck. The program is being written in C.

1

There are 1 answers

0
Anderson Green On

Several Python-to-C compilers have already been developed. For example, there is a subset of Python called RPython that can be translated to C automatically.