This is an interpreter for the imperative toy language IMP from the course Formal Methods and Functional Programming at ETH Zürich. It is published under the MIT license.
To start the REPL, just run impli with no arguments. Pass the path of an IMP source file as argument to interpret it. Directly execute a statement with the --command option or print its AST with --ast. In the initial state all variables are uninitialized with zero and no procedure is defined. Find some sample programs in docs/examples/.
Build artifacts for macOS, Linux, and Windows are available under GitHub Releases. You can download the latest version directly using curl. Replace <BIN> with the OS appropriate binary name found on the releases page, for example impli-aarch64-darwin or impli-x86_64-windows.exe.
curl -L "https://github.com/bfeitknecht/impli/releases/latest/download/<BIN>" -o impliYou may need to modify execution privileges and remove the quarantine attribute on macOS.
chmod +x impli
xattr -d com.apple.quarantine impliThe most apparent deviations from the specifications are that parentheses are not required for arithmetic or boolean operations in expressions, and sequential composition in statements. Additionally, the write-only placeholder variable _ allows discarding of values. It can only be used on the lefthandside of variable definitions. For complete specification of the syntax refer to the EBNF.
The table below depicts the correspondence between semantics functions defined in the lectures and according functions in this project for state. For an overview of all natural semantics inference rules, check out the paper.
| FMFP | impli |
|---|---|
IMP.State.initial |
|
IMP.State.getVar state x |
|
IMP.State.setVar state x n |
|
IMP.Semantics.Natural.run (s, state) |
|
IMP.Semantics.Structural.step (s, [state]) |
|
IMP.Semantics.Structural.steps (s, [state]) |
|
n |
|
IMP.Expression.evaluate a state |
|
IMP.Expression.evaluate b state |