Jim's
Tutorials

Spring 2019
course
site

Nick Says

I haven't written any code this week; i've been thinking about what I would like to do for the final project and gathering resources here.

After our conversation last week, I've been thinking about transpiling/source-to-source compiling and how one might go about writing a source to source compiler. It seems to me that all the components of a compiler that I've taken a look at so far are definitely necessary, but from the looks of a case study I found, there's a couple of steps in the process that I haven't yet taken a shot at.

so far, it looks like writing a transpiler requires

I haven't really heard the specific term "action tree" in use, but found a case study of a guy writing his own transpiler, where he wrote his own language and transpiled it to C++, then compiled that C++ source code using GCC. It seems like, because his language is interpreted, there might be different motivations for using the action tree. I do remember we spoke about a similar structure last week, basically an abstract syntax tree with more information. Part of me thinks that this step could be combined with parsing without too much issue...

Someone on stackexchange reccommended reading this article about life after parsing, which is more general than the case study mentioned above. I also read Matt Might - Compiling to Java, which has source code to poke around in. I think taking a closer look at this will help me figure out how to do something similar with Python.

For the actual project, I'm thinking about compiling some small part of Fortran to Python. I was able to find a grammar for Fortran 77/90, just from looking at the way F77 is written compared to F90, and the trickiness of some of the obsolete bits of F77, I'll be focusing on the structures specific to F90. I'm thinking of handling if/elif/else statements as a dummy example, which could be tested by writing something like a working fizzbuzz test in F90, then seeing if the transpiler generates a working version of fizzbuzz in python. this would also require implementing variable assignment and integer arithmetic, which is not a huge addition I believe.

Fortran Syntactic Analysis Specification (grammar) Fortran 90 tutorial/language features (easier to actually learn Fortran this way, rather than staring at the grammar right away)

in class

Jim thinks that lisp might be more fun. And cooler to show off.

https://cs.marlboro.college /cours /spring2019 /jims_tutorials /ncreel /apr11
last modified Sat April 27 2024 6:52 pm