3 ms·
Alternate interpretation of topic: On the strictly theory side, changing c source code to fortran source code in an automated/direct 1:1 transform would involv
by sargstuff 3y ago
Alternate interpretation of topic:
On the strictly theory side, changing c source code to fortran source code in an automated/direct 1:1 transform would involve using bnf/ebnf definition of c language and defining how that corresponds to the equivalent enbf/ebnf definition of fortran or parser combinator[3].
Fortran language bindings to be able to use C inside of a fortran program bit easier to manage.
BFNC can generate a compiler from bnf/ebnf definition.[1]
So, mess around with c as subset of python till get bnf/ebnf grammar that corresponds to bnf/enbf fortran. Convert the aforementioned C subset to fortran program into ebnf/bnf format. use bnfc[1][2] to create a compilter that will transform c source code into fortran source code.
----
compiling vs. transpiling: https://crystallize.com/answers/tech-dev/compiling-vs-transpiling https://crystallize.com/answers/tech-dev/compiling-vs-transp...
[1] : https://bnfc.digitalgrammars.com/ https://bnfc.digitalgrammars.com/
[2] : https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=171c79e76f9056675496a69f622917bd0c623983 https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&d...
[3] : https://en.wikipedia.org/wiki/Parser_combinator https://en.wikipedia.org/wiki/Parser_combinator