A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/jayconrod/imp-interpreter below:

jayconrod/imp-interpreter: A minimal interpreter for the toy language, IMP, used as an example for building interpreters.

IMP is a simple, minimal programming language. It was taught to me in a class in grad school on proving semantics of programming languages. I decided to write a simple interpreter for it as a running example in a series of blog posts on building interpreters.

IMP programs have three syntactic entities:

A program consists of a single statement, but statements can contain other statements. Arithmetic expressions are simple expressions that evaluate to integers. Boolean expressions evaluate to true or false. There are no values, other than integers and Booleans.

Variables may be assigned in IMP. All variables are global. There are no functions or scopes, so non-global variables wouldn't really make sense anyway. When an IMP program is finished executing, the interpreter prints the value of each variable. There is no other way for IMP programs to interact with the outside world.

if a < b then
  x := 1
else
  y := 2
end
while x > 0 do
  x := x - 1
end
Arithmetic expressions (aexps) Boolean expressions (bexps) Structure of the interpreter

TODO: write this section after refactoring.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4