&SPL – Creating a simple imperative programming language

SPL sample code

&SPL is an acronym for Simple Programming Language, and is a C-like imperative programming language, with classes, lists, and tuples. For example, the following code produces the Fibonacci sequence.

The language is formally defined with a context-free grammar and typing rules. In this post an implementation of an &SPL source code compiler implemented in Haskell will be discussed. The compiler compiles the source code into assembly for a Simple Stack Machine [1] (http://www.staff.science.uu.nl/~dijks106/SSM/) in a four-part process of lexing, parsing, typing and code generation. The source code is available on GitHub.

Continue reading “&SPL – Creating a simple imperative programming language”

[1] A. Dijkstra, “Simple stack machine.”
title = {Simple Stack Machine},
author = {Atze Dijkstra},
timestamp = {2017-06-18},
url = {http://www.staff.science.uu.nl/~dijks106/SSM/},