~/cstml/documents/space The language.

A declarative, statically typed, stack programing language. Inspired by the FMC, FMCt, and Forth.

Language Syntax

The syntax of space is simple:

```TERM     ::= *
| VARIABLE ; TERM
| @LOCATION [TERM] ; TERM
| @LOCATION <VARIABLE : TYPE> ; TERM

VARIABLE ::= <lower case letter>

LOCATION ::= @ <upper case letter>+ <lower case letter>*

TYPE     ::= <upper case letter>+ <lower case letter>*
```

The language also accommodates nested comments, in the same style as Haskell:

```-- Line comments are lines preppended with --
{- Multi-line nested comments {- as can be seen here -} are of this
form.  -}
```

Example Terms

```x;*         -- is simply calling variable x
x;y;*       -- is calling variable x and then y
[x;*];*     -- pushses a call to variable x to the default/"Home" stack
[x;*];<y>;* -- pushes a call to variable x to the default stack and then binds this command to variable y
```

eval(x) = eval(eval(x))

Types Syntax

There are two levels of types: values and types.

Any type is a set of Values or Constructors.

```()    :: ()
1     :: Z

^()   :: {}       -> ({1})@
^1    :: {}       -> ({Z})@
^1;^2 :: {}       -> ({Z;Z})@
+     :: ({Z;Z})@ -> {}

[*];<x>;eval ::
```

Notation

```T ::= {}
| TYPEVAR      ; T
| Z            ; T
| Ch           ; T
| 5.{T}        ; T
| [T -> T]     ; T
| (T)@LOCATION ; T
```

Examples

• `x`
• `Z`
• `({} -> Z)@`
• `{} -> ({} -> Z)@`
```Z  :: {} => gamma@[{} => Z]
1  :: {} => gamma@[{} => Z]
```

Date: 21/04/2022

Created: 2022-05-19 Thu 06:21

Validate