Big changes to Chap. 3: A Calculator Language
Hello again!
Yesterday we published another update to the book, with some fairly extensive changes to Chapter 3: A Calculator Language. We added a new section where we extend the grammar to support multiplication and division:
This was a bit tricker than you might think!
We made the decision to keep the grammar simple and give all binary operators the same precedence. But there was no support for parentheses…and a language with ➕/➖ and ✖️/➗ and no parentheses is awkward!
So we also added support for parentheses in Chapter 3…but this required introducing a specific feature of Ohm (inline rule declarations) earlier in the book than we did before:
And of course, we had to refactor the code in all the later chapters to account for this. 😅
But we think it makes the book better! And we'll be able to use the *
operator to make the code in the "Drawing to a Canvas" chapter a bit more straightforward.
Until next week!
Patrick & Mariano