This is a compiler for a large subset of Fortran 77, targeting a hypothetical CPU assembly language. The output is a file containing assembly code for the Fortran source code being compiled.
Right now, here's the progress:
- Lexer
- Parser
- Expression parser
- Statement parser
- Program unit parser (for the main program, functions, subroutines)
-
program
-
function
-
subroutine
-
- Type checking
- Code generation
- Optimization
There's probably a lot I could be doing better, like my handling of ownership of lexemes in Tokens. I'm probably going to write an interpreter, and use it to profile performance on computing Fibonacci numbers (or whatever), before I spend a lot of time worrying about performance and memory management.
For the subset of FORTRAN 77 supported, this is discussed in the notes/
subdirectory documentation.
Why FORTRAN 77? Well, this is arguably some subset of fixed-form Fortran 90, but there are two reasons:
- It is suitably simple enough to parse and compile, which means the possibility of having a bug in the compiler is small (compared to complicated languages like, say, Julia).
- It's considered one of the top 10 algorithms of the 20th century according to Computing in Science and Engineering
- Fortran 77 Standard HTML and PDF
- Fortran 90 Standard PDF which has FORTRAN 77 as a subset
- Jan Derricks' F90 Grammar
- William Waite and James Cordy's Fortran 90 Grammar