6 Statements
A function body is a block of statements, also called commands, in braces. A block may be empty or may
contain a sequence of statements. Statements in the block may be separated with semicolons, but this is not
necessary, even if they’re on the same line.
The legal statements are the following:
• An if statement, with the same syntax as C and Java, modulo semicolons.
• A while statement, with the same syntax as C and Java, modulo semicolons.
• A return statement. In a procedure, this is written just as return; in a function with a return type, the
value(s) to be returned follow the return keyword, separated by commas. A return statement may
only be used inside a block and must be the last statement in its block.
• A call to a procedure (but not a function).
• A block of statements, each optionally terminated by a semicolon. A block may be empty. Anywhere
a statement is expected, a block may be used instead, except in a function declaration. However, a
return statement may not be used in place of a block.
• A variable declaration, with an optional initialization expression.
• An assignment to one or more variables.
There are no empty statements as in C and Java.
7 Lexical considerations
The language is case-sensitive. An input file is a sequence of Unicode characters, encoded using UTF-8.
Therefore ASCII input is always valid.
Comments are indicated by a double slash // followed by any sequence of characters until a newline
character.
Keywords (if, while, else, break, return, use, length) may not be used as identifiers. Nor may the
names or values of the primitive types (int, bool, true, false).
String and character constants should support some reasonable set of character escapes, certainly in-
cluding “\\”, “\n”, and “\’”.
8 Source files
The Xi compiler compiles a source file with extension .xi to runnable code. It may also read in interface
files that describe external code to be used by the program.
Interface files contain a set of function declarations without implementations. Interface files have the
extension .ixi. To use the functions declared in interface file F.ixi, a program contains the top-level
declaration “use F”. All such declarations must precede all function definitions.
9 Current library interfaces
Interfaces for I/O and corresponding libraries are available, including the following functions from inter-
face file io:
5