Crafting Interpreters in Rust: Parsing groups
We’re almost done with expressions. Next we add grouping with parentheses.
We’re almost done with expressions. Next we add grouping with parentheses.
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.
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.
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.
In the last post, we implemented unary-not. In this one, we’ll implement the other unary operator: negation.
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.
We’re implementing Lox’s primary rule. So far, we’ve done booleans, nil and numbers. Let’s move on to strings.
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.
In the previous post, we wrote a simple grammar that parses true or false as a boolean:
For the parser, I’m going to use LALRPOP. I used it in my previous attempt at this, and I liked it.
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.