# li1I

**li1I** is a domain-specific programming language for integer calculations. It supports recursive functions, conditional execution, and expresses arithmetic in Reverse Polish notation.

It was designed by User:TartanLlama in 2017.

The only valid characters in an li1I program are `l`

, `i`

, `1`

, `I`

and whitespace. There is no syntax for comments. Comments are not necessary in a language of such clarity.

Here's a function which computes the factorial of its argument:

li1I l1iI lI1i I li1l i lil1 l1i1 li1l i 11 ll11 l1ii lil1 11 l1ii l1il i 11 llii I i liil l1ii l1ii lI1i IIII liI1 i lIi1 11111111111 l1ii I l1ii l1Ii

## Language

### Program

An li1I program consists of the token `li1I`

followed by any number of functions enclosed in braces. Left brace is spelled `l1iI`

and right brace is spelled `l1Ii`

. Here is an empty program:

li1I l1iI l1Ii

Beautiful.

### Literals and Identifiers

Function identifiers are of the form `I[iI1l]*`

.

Variable identifiers are of the form `i[iI1l]*`

.

The only type supported in li1I is an integer. The author cannot remember what kind of integer it is. The value of an integer is given by the length of a string of `1`

s minus 1. E.g. `1`

has the value 0, `11`

has the value 1, `1111111111`

has the value 9 and so on.

### Functions

A function is indicated with the token `lI1i`

, which is followed by a function identifier, any number of variable identifiers (parameters), then a brace-enclosed block.

In that brace enclosed block, any number of statements are allowed.

### Statements

A statement is an expression followed by the token `l1ii`

.

### Expression

An expression can be:

- The name of a variable, which evaluates to its value.
- A variable declaration, spelled
`liI1 <variable identifier> lIi1 <expression>`

, which evaluates to the value of the initialiser. - A function call, spelled
`<function identifier> li1l <expression>* lil1`

, which evaluates to the result of the function call. - An arithmetic or logical expression (see below).
- A conditional expression (see below).

Arithmetic and logical expressions in li1I are written in Reverse Polish notation.

The following arithmetic operations and their spelling in `li1I` are:

- Addition:
`llli`

- Subtraction:
`llii`

- Multiplication:
`liil`

- Integer division:
`llil`

- Exponentiation:
`liii`

The following logical operations and their spelling in `li1I` are:

- Greater than:
`ll1i`

- Less than:
`ll1I`

- Equality:
`ll11`

- Inequality:
`l111`

A conditional expression is of the form:

l1i1 li1l <arithmetic or logical expression> lil1 l1iI <then statements>* l1Ii l1il l1iI <else statements>* l1Ii

Is a then with no else supported? Who knows.

## Implementation

An implementation which targets LLVM can be found on GitHub.