Intermezzo #
At this point, we have something that is ugly looking, but seems like a real compiler! After all, it does the four stages as promised:
- Lexing: the splitting of whitespace and division of tokens
- Parsing: the creation of the syntax tree based on ordering of operations
- Translation: a no-op, because the syntax tree is good enough
- Code Generation: Python “machine code” as valid infix math, or a JIT library running routines
But still, you can’t really call this a langauge. Even aside from Turing Completeness, it’s really missing some basic features: variables, flow control and other math operations.
More subtle and fundamental is that each “program” is a single statement. There isn’t even an ability to have a subroutine you can define then call into, let alone do things like recursion.
Let’s see if we can add a couple. Then perhaps these tools and approaches will stop seeming like overkill and boilerplate, and start to shine.