Interpreters (lecture summary)
An S interpreter accepts code expressed in language S, and immediately executes that
An interpreter works by fetching, analysing, and executing one instruction at a time.
If an instruction is fetched repeatedly, it wil
Programming Languages 3
Fun is a simple imperative language. Its purpose is to illustrate some aspects of programming
language concepts and implementation.
Here is an example of a Fun program:
bool verbose = true
func int fac
Application of Regular Expressions (lecture summary)
Application of REs: Unix shell (1)
The Unix shell scripting language uses an ad hoc pattern-matching notation in which:
 matches any one of the enclosed characters
? (on its own) matches any single
Grammars (lecture summary)
To specify the syntax of nested phrases such as expressions and commands, we
need a (context-free) grammar.
The grammar of a language is a set of rules specifying how the phrases of that
language are formed.
Each rule s
Compilation (lecture summary)
Recall: A compiler translates a source program to object code, provided that it
conforms to the source languages syntax and scope/type rules.
This suggests a decomposition of the compiler into three phases:
Syntax regular expressions (lecture summary)
What is syntax?
The syntax of a PL is concerned with the form of programs: how expressions,
commands, declarations, and other constructs are arranged to make a well-formed
When learning a new PL, we ne
Translators (lecture summary)
An S T translator accepts code expressed in one language S, and
translates it to equivalent code expressed in another language T:
S is the source language
T is the target language.
Examples of translators:
Programming Languages 3
SVM is a simple virtual machine. It is suitable for execution of programs in simple imperative
1 Machine state
The virtual machine consists of:
a code store of 32,768 bytes, which contains the programs
Values and types (lecture summary)
Values are grouped into types according to the operations that may be performed on
Different PLs support a bewildering variety of types:
C: integers, floats, structs, arrays, unions, pointers to variables, pointers
Lists and strings (lecture summary)
A list is a sequence of 0 or more component values.
A list is either:
non-empty, in which case it consists of a head (its first component) and a tail (a list
consisting of all but its first component).