This semester we will implement a compiler for Andrew Appel's Tiger programming language. This language is the source language is his series of books, "Modern Compiler Implementation in ...". We will not be following the book, though. We are just using the syntax and semantics of the language as a guide.
An identifier is a sequence of letters, digits, and underscores that starts with a letter. Case is significant.
Whitespace (spaces, tabs, newlines, returns, and formfeeds) may appear anywhere between tokens and is ignored.
A comment starts with
An integer literal is a sequence of one or more decimal digits. There are no negative integer literals -- negative numbers are specified by applying unary minus to a positive literal.
A string literal is a sequence of zero or more printable characters, spaces, or escape sequences surrounded by double quotes. Each escape sequence starts with a backslash and stands for some sequence of special characters:
|The character with ASCII code ddd (three decimal digits)|
|Any sequence of whitespace characters enclosed in backslashes is ignored. This allows string literals to span multiple lines by ending on one line and restarting on the following line with backslashes|
Reserved words in the language are:
Delimiters and operators consist of the following one or two-character
A Tiger program consists of a single expression. The
In the grammar below, we use the following conventions. We use colors/fonts
Overall program structure:
Kinds of expresions:
Declarations and types: