The syntax is:
- Name = Can use letters, numbers, underscore, and apostrophe, but must start with a letter or underscore. Names are case-sensitive.
- Number = Specify by digits 0 to 9 in decimal notation.
- Program = Series of declarations separated by semicolons.
- Declaration = Name, equal sign, and the expression which is its definition.
- Comment = Start by # and end at a line break.
Expressions can be:
- [x] means a lambda expression returning x.
- A number is a De Bruijn index to use a lambda variable.
- A function application is two expressions followed by . to apply. If you have x y. then it means y is function and x is the argument.
- : is a shortcut for ...
- Inside of a expression if there is not enough . it add sufficient trailing . at the end, automatically.
- If there is too much . or empty expression then it can add 0 on the left as much as is required.
Free variables are permitted (for example, Free = ; has a free variable). They remain free when this name is used in another expression, unless you use $ as a prefix which treats it as a macro substitution instead of a value substitution.
Input/output is done by running the final declaration in the program; its value is one of these things decides what I/O to do. I/O functions:
- / is function taking one argument. Its result means to output a zero bit and then its argument is the next program.
- \ is like / but output a one bit instead.
- ? takes three arguments. Its result means to take a single bit of input, and continue with the first argument as the program if zero bit is input, second argument if one bit is input, and third argument if end of input.
- * takes no arguments, causing program to terminate.
Program to halt with no effects:
Program copying input to output:
main = *main\.main/.?;