SAPL Interpreter

Summer 2021
alpaca.jpg

Shiny Alpaca Preprocessing Language (SAPL) is a dynamically typed language based on Rust, OCaml, Python, and C++. The name was chosen since shiny is an antonym of rusty, as in Rust, and the alpaca is somewhat similar to a camel, as in OCaml. The preprocessing language part was because originally the plan was for SAPL to be a preprocessor to any arbitrary language such as C or Javascript.

The language has features of imperative languages such as loops, classes, interfaces, and mutable arrays, but also has many functional features like pipelining, lambdas, and partial application.

I started this project after taking a class in functional programming, where one assignment was to build an interpreter for the language JoCalf. This project essentially “extends” JoCalf but with a modified syntax and is implemented in Rust.

The big takeaway from this project is to really think about the syntax and semantics of language features. I kind of added stuff that I thought would be cool without much thought, leading to certain combinations of features interacting in slightly strange ways. Notably, the intersection of lambdas, universal function call syntax, partial application, and class members can combine in a somewhat strange way.

Interesting Implementations:

  • Universal function call syntax
  • Checked precondition and postcondition expressions
  • Iterators

Source