A type-safe functional programming language using Reverse Polish Notation.
A Suffix program is made of top-level instructions. The two most important instructions are &
(push) and .
(call): &2 &3 .+
calls the +
function with arguments 2
and 3
. Suffix uses RPN, so it has a stack you can push values to. Functions take a certain amount of stack elements, and push new ones instead.
Contrary to most RPN languages, Suffix is type-safe: all function declare how much values they take, their type, and what they return. As such, the value stack only exists at compilation.
There are no variables and no loops, only constants (called bindings) and recursion.
Identifiers can contain many characters, including spaces. Types and values are in a different name space.
The different instructions are:
&
push a value to the stack.
call a function by name>
pop a value and bind it a name:&2 > two
meanstwo
now refers to the value2
func
declare a functionrecord
declare a record (an immutable data structure)
To run the driver, build the suffix
command line tool with swift build --product suffix
.
The different commands are:
suffix lex <file.suffix>
: Prints a debug list of tokens from the lexersuffix parse <file.suffix>
: Prints a debug AST view from the parser- more to come...
SuffixLang
contains the lexer, the parser, and the AST structsSema
(Coming Soon) contains the type checkerIRGen
(Coming Soon) contains the LLVM IR code generatorDriver
contains the command line toolLSP
(Coming Soon) contains the LSP server for integration with IDEs