- compiler for Andrew Appel's Tiger language with a few tweaks.
- written in Free Pascal.
- compiles to inefficient assembly language for Mac OS X86_64.
- hand written recursive descent lexer and parser.
mod
(integer division remainder) operator.&
operator (logical and) changed toand
.|
operator (logical or) changed toor
.- boolean data type. Relational operators return booleans,
true
andfalse
are pre-defined contants. - char data type. Char literals are
#
followed by a single letter in quotation marks. eg#"a"
or escape sequences#"\n"
. - file data type (C
FILE*
pointer) - sequences are enclosed in
begin
andend
instead of parentheses. - semicolon separators are optional between expressions in sequences.
- variable declarations:
var
keyword not used, format is<id>
[: <type>
]= <exp>
(uses=
instead of:=
). - function declarations:
function
keyword not used, format is<id>(
[<id>: <type>
{, <id>: <type>
}]) = <exp>
. - strings can include line breaks and span multiple lines.
- comments are SML style
(* ... *)
- no nested comments
- type aliases are not implemented.
break
is not implemented.- string comparison operators (
<
,<=
,>
,>=
) not implemented -- usestring_compare
function instead. use "<file_name>"
to include external definition file inlet
declaration block- enum types.
type <id> = <id>
{| <id>
}. Exampletype color = red | green | blue
. - case expression
case <exp> of <const> : <exp>
{| <const> : <exp>
}else <exp>
.
- array bounds checking
- tail call optimization
- anonymous functions, first class functions
- type inference
- closures
- array literals
- garbage collector
- algebraic types and polymorphic functions
- modules
- optimization
- ffi
- unicode
- alternate backends
- STD_INPUT
- STD_OUTPUT
- STD_ERROR
- EOF
- open_input(path: string): file
- open_output(path: string): file
- close_file(f: file)
- getchar(): char
- putchar(c: char)
- file_getchar(f: file): char
- file_putchar(c: char, f: file)
- write(s: string)
- writeln(s: string)
- file_write(s: string, f: file)
- file_writeln(s: string, f: file)
- command_argcount(): int
- command_arg(n: int): string
- halt(n: int)
- str(i: int): string (converts int to string)
- num(s: string): int (converts string to int) (todo)
- ord(ch: char): int
- chr(n: int): char
- length(s: string): int
- substring(s: string, start: int, len: int): string
- string_concat(s1: string, s2: string): string
- string_compare(s1: string, s2: string): int
- make_string(size: int): string
- true
- false
- not(b: bool): bool
- is_digit(c: char): bool
- is_space(c: char): bool
- is_upper(c: char): bool
- is_lower(c: char): bool
- is_alpha(c: char): bool
- min(m: int, n: int): int
- max(m: int, n: int): int