Automatic Translation of C to RPython

13 views
Skip to first unread message

HartsAntler

unread,
Sep 28, 2010, 3:10:06 AM9/28/10
to rpython, eli...@gmail.com
Just starting this project, at the moment it can only translate a
subset of C to Python.

http://code.google.com/p/rpythonic/


# input C code
struct {
int id;
char* name;
} joe;

void foo(void) {
printf("hi");
}
int bar( char x ) {
if (x=="A") { return 1; }
if (x=="B") { return 2; }
}

int main()
{
int i;
int j;
j=55;
while (i<10) {
foo();
bar( "A" );
i += 1;
}
return 0;
}

# output Python code
class joe(object):
id=0 #declare
name = [""] # <pointer>
def foo( ):
printf( "hi", )
def bar( x, ):
if (x == "A"):
return 1
if (x == "B"):
return 2
def main( ):
i=0 #declare
j=0 #declare
j = 55
while (i < 1000000000):
foo( )
bar( "A", )
i += 1
return 0
Reply all
Reply to author
Forward
0 new messages