ST is a very robust and easy to understand language. A good fit for industrial applications. But on the internet you find by far more example algorithms, applications and libraries written in C or other languages. The mission of this project is to make the step from a working C example code to a working ST code as small as possible.
The transpiler is built using the very old but famous and solid compiler builder tools flex and yacc / bison. So the code transformation consists only of two steps:
flex: tokenize the ANSI C code
bison: parse and transform the tokens to ST code
As the transformations from the tokens to the resulting ST code is done in just one step, we have to live with a few limitations, which can't be transformed as the ST language doesn't support those language constructs.
The following features are currently tested, and should work therefore:
a = b * (c + d) * e;
a := b * ( c + d ) * e;
CASE value OF
for (i=0; i < 5; i++)
WHILE i < 5;
while (x < 10)
WHILE x < 10 DO
named structs / unions
TYPE test: STRUCT
unnamed structs / unions
flattened as members into the type in which they are embedded
The following features will definitely not be supported by this transpiler, because of its design.
Explicit type conversions of user defined data types (e.g. structs)
Static variables or functions
This project is in a proof-of-concept phase. So it can't be easily used, yet, nor would I try to encourage non-experienced people to use it in this state. If you understand the Makefile and the code you can give it try, though.