Programming Language Converter for Javascript
s2sc (Source to Source Converter) is a javascript code convertion framework that aims to connect other programming languages to web browsers by interpreting codes from a programming language then converting it to another programming language.
At this moment, s2sc supports the following code conversions: Python -> C (Progress)
By calling out s2sc.convert() will instruct s2sc to generate an equivalent code from another language base on the source language that was given to it. The convert function has 3 parameters, the first one specifies the source language, while the second specifies the target language and the third parameter is the string of the source code. It can be called directly and be used by other functions since the result of the convert function is just a string that can be manipulated directly by other applications.
s2sc.convert(s2sc.language.python2, s2sc.language.c, "print(\"Hello World!\")")
/*******************************************************
Code generated by s2sc.js
*******************************************************/
#include <stdio.h>
int main ( void ) {
printf("%s", "Hello World!");
return 0;
}
After the beta release
Python to C
def add(a, b):
return a + b
c = add(200, 100)
if c == 300:
print("It is 300")
else:
print(c)
/*******************************************************
Code generated by s2sc.js
*******************************************************/
#include <stdio.h>
int add (int a, int b) {
return a + b;
}
int main ( void ) {
int c = add(200, 100);
if ( c == 300 ) {
printf("%s", "It is 300");
}
else {
printf("%d", c);
}
return 0;
}
===========