This post is part of the Stack Based Virtual Machines series. In the previous part we have started writing some code for our stack based virtual machine. In this part, we’re going to extend the catalog of instructions that our CPU can support. The code for this article can be found on github. Arithmetics Our VM can already handle additions, so teaching it to add subtractions, multiplications and (integer) division won’t be very hard.| andreabergia.com
This post is part of the Introduction to parsing series. In the last part we started adapting our parser to work with an AST, as a step towards handling function definitions. In this part, we’ll continue on that road. More nodes type The last time we implemented a NumberNode and an AdditionNode. It’s time to implement the nodes for the other three basic operations. The tests are: CASE("SubtractionNode") { NumberNode n1(1), n2(2); SubtractionNode node(n1, n2); EXPECT("1 - 2" == node.| andreabergia.com