~/cstml/documents/space
The language.
Table of Contents
A concatenative, stack programing language. Inspired by the FMC, FMCt, and Forth.
Language Syntax
NB: This page is marked as WIP
The syntax of space is minimal:
TERM ::= WORD | NUMBER | KEYWORD | EVALUATE_OPP | PUSH_OPP | SEND_OPP | PUSH_DICTIONARY | POP_DICTIONARY | THUNK | COMMENT WORD ::= [a-zA-z]+ NUMBER ::= [1-9]+[0-9]* KEYWORD ::= ":"[a-zA-z]+ EVALUATE_OPP ::= "!" PUSH_OPP ::= "^" SEND_OPP ::= "$" THUNK ::= "[" TERM* "]" COMMENT ::= "{" .* "}"
Example Terms
1 {number} 2 3 if [x] {numbers, words, thunks} ^ {push{ ( x x + :foo [y] ^ y ) { simple comment } 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]