In this series of posts, we write a bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: In this series

A Bytecode VM for Arithmetic: The Parser

submited by
Style Pass
2025-08-02 13:00:07

In this series of posts, we write a bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics:

In this series of posts, we write a bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics:

The language that we are going to work with is that of basic arithmetic expressions, with integer values, and addition, subtraction, multiplication and integer division operations. However, our expression language has a small twist: it is possible to introduce a variable using a let binding and use the variable in the expressions in the body of let1. Furthermore, we use the same syntax for let as Haskell does. Here are some examples of valid expressions in our language:

The only gotcha here is that the body of a let expression extends as far as possible while accounting for nested lets. It becomes clear when we look at parsed expressions later.

Leave a Comment
Related Posts