Hi. It’s been a while. Though the pace of blog posts fell off a cliff last year[1], I’ve continued working on my toy programming language on and off.
build a programming language posts
Subscribe to just build a programming language posts via RSS.
Part 11: Lexical Scope
After adding variables, I added boolean values and comparison operators, because why not. With that in place, I figured it would be a good time to add if statements. Parsing them is straightforward—you just look for the if
keyword, followed by a bunch of stuff—so I won’t go into the details. But actually evaluating them was a bit more complicated.
Part 10: Variable Declarations
Now that the parser can handle multiple statements and the usage of variables, let’s add the ability to actually declare variables.
Part 9: Statements
So the parser can handle a single expression, but since we’re not building a Lisp, that’s not enough. It needs to handle multiple statements. For context, an expression is a piece of code that represents a value whereas a statement is a piece of code that can be executed but does not result in a value.
Part 8: Variable Lookups and Function Calls
Arithmetic expressions are all well and good, but they don’t really feel much like a programming language. To fix that, let’s start working on variables and function calls.