Crafting Interpreters in Rust: Introduction
For my #DecemberAdventure, I’m going to have another go at working through “Crafting
Interpreters” in Rust. The last time I tried this, I got to the end of Chapter 10.
For my #DecemberAdventure, I’m going to have another go at working through “Crafting
Interpreters” in Rust. The last time I tried this, I got to the end of Chapter 10.
For the parser, I’m going to use LALRPOP. I used it in my previous attempt at this, and I liked it.
In the previous post, we wrote a simple grammar that parses true or false as a boolean:
So far, we’ve got a grammar that can parse true, false and nil literals. In this post, we’ll add the ability to
parse numbers.
We’re implementing Lox’s primary rule. So far, we’ve done booleans, nil and numbers. Let’s move on to strings.
We’re implementing Lox’s primary rule. So far, we’ve done booleans, nil, numbers and strings. Let’s move on to some
basic expressions. In this post, we’ll deal with unary-NOT – !x.
In the last post, we implemented unary-not. In this one, we’ll implement the other unary operator: negation.
In the previous post, we finished implementing parsing of unary operators. In this post, we’ll take a look at the first of the binary operators: division and multiplication.
At the end of the previous post, we could parse division and multiplication operators. Because we used an LALRPOP macro, it should be relatively simple to add addition and subtraction operators.
So far, we implemented parsing for numbers, strings, booleans, nil, unary operators ! and -, multiplication and
division, and addition and subtraction. Next on the list are comparison operators (greater-than, less-than, etc.) and
equality operators.
We’re almost done with expressions. Next we add grouping with parentheses.