News for hackers. Stuff that matters.
Re:Ask HN: Writng a transpiler – What language/runtime shoul... by sargstuff on Thursday February 22, 2024 @02:38PM (#39471959)
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-transp...

[1] : https://bnfc.digitalgrammars.com/

[2] : https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&d...

[3] : https://en.wikipedia.org/wiki/Parser_combinator

There are no comments on this comment yet.