Logo-c2iec.png (2832 bytes)


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:

feature C ST
expressions a = b * (c + d) * e; a := b * ( c + d ) * e;
lvalues c++; ((c:=c+1)-1);
case switch (value) CASE value OF
for for (i=0; i < 5; i++) WHILE i < 5;
while while (x < 10) WHILE x < 10 DO
named structs / unions struct test TYPE test: STRUCT
unnamed structs / unions union ...; flattened as members into the type in which they are embedded
typedef typedef struct ... t_struct; TYPE t_struct: Id2036658550;
arrays char arr2[1][2]; arr2: ARRAY[0..(1-1),0..(2-1)] OF BYTE;


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)
  • Function pointers
  • Pointer arithmetics
  • 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 your code is proberly pre processed, you can quickly try it with the web-version of the transpiler.