Today is the day! Today is the day we take our APL programs and interpret them, so that something like ÷ 1 2 3 -⍨ 1.1 2.2 3.3 can output 10 5 3.33333333.
If you recall, in the last blog post of the series (which was also the first!) we created a simple program that took a basic APL expression (APL is a really cool array-oriented programming language), tokenized it and then parsed it into an AST, an Abstract Syntax Tree.
(writing this list was easy, I just went to the previous blog post and copied the list of things we would get done for today!)
Additionaly, to make the above changes easier to implement, I am also going to redesign some of the things that were already done. Please don't be mad at me! Quoting my previous post,
So we are actually starting with refactoring the parser and the way we represent monadic/dyadic function application. I decided to make this change when I realized implementing all the APL operators was going to be a real headache with the format I chose before.
To make my changes easier to understand, we will study the AST generated for the simple expression 1 +⍨⍨ 2. If you test it, the program will print MOp(⍨ MOp(⍨ Dyad(+ S(1) S(2)))), which can be drawn as: