summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-07-27 17:17:56 -0400
committernodist <kevin.comas.git@gmail.com>2026-07-27 17:17:56 -0400
commitbb912b081ed339e4a5419bd3d2ffd7465f2f72d3 (patch)
tree7f34b3af1a72672de1d12c8e23dda419c398dce3
parent003119b9f285e5610f56186bce845441409265ae (diff)
bottom up redesign
-rw-r--r--docs/application/buffer.md25
-rw-r--r--docs/application/error.md27
-rw-r--r--docs/application/group.md13
-rw-r--r--docs/application/identifier.md17
-rw-r--r--docs/application/index.md72
-rw-r--r--docs/application/interface.md56
-rw-r--r--docs/application/io.md39
-rw-r--r--docs/application/map.md20
-rw-r--r--docs/application/memory.md39
-rw-r--r--docs/application/mutex.md24
-rw-r--r--docs/application/namespace.md169
-rw-r--r--docs/application/native.md11
-rw-r--r--docs/application/queue.md18
-rw-r--r--docs/application/shared.md38
-rw-r--r--docs/application/testing.md52
-rw-r--r--docs/application/thread.md415
-rw-r--r--docs/application/type.md101
-rw-r--r--docs/application/union.md12
-rw-r--r--docs/definitions.md47
-rw-r--r--docs/index.md51
-rw-r--r--docs/language/index.md225
-rw-r--r--docs/language/operators.md99
-rw-r--r--docs/language/ownership.md44
-rw-r--r--docs/lifecycle/check.md16
-rw-r--r--docs/lifecycle/eval.md11
-rw-r--r--docs/lifecycle/exec.md5
-rw-r--r--docs/lifecycle/import.md5
-rw-r--r--docs/lifecycle/ir.md25
-rw-r--r--docs/lifecycle/jit.md80
-rw-r--r--docs/lifecycle/notify.md5
-rw-r--r--docs/lifecycle/parse.md37
-rw-r--r--docs/lifecycle/register.md16
-rw-r--r--docs/lifecycle/scope.md25
-rw-r--r--docs/type_system/alias.md7
-rw-r--r--docs/type_system/bit.md134
-rw-r--r--docs/type_system/buffer.md74
-rw-r--r--docs/type_system/const.md9
-rw-r--r--docs/type_system/empty.md27
-rw-r--r--docs/type_system/error.md23
-rw-r--r--docs/type_system/function.md158
-rw-r--r--docs/type_system/generic.md33
-rw-r--r--docs/type_system/group.md46
-rw-r--r--docs/type_system/index.md119
-rw-r--r--docs/type_system/ir.md22
-rw-r--r--docs/type_system/list.md22
-rw-r--r--docs/type_system/lock.md17
-rw-r--r--docs/type_system/map.md36
-rw-r--r--docs/type_system/name.md16
-rw-r--r--docs/type_system/namespace.md57
-rw-r--r--docs/type_system/native.md23
-rw-r--r--docs/type_system/op.md21
-rw-r--r--docs/type_system/overload.md27
-rw-r--r--docs/type_system/queue.md37
-rw-r--r--docs/type_system/ref.md9
-rw-r--r--docs/type_system/select.md32
-rw-r--r--docs/type_system/shared.md43
-rw-r--r--docs/type_system/symbol.md16
-rw-r--r--docs/type_system/task.md20
-rw-r--r--docs/type_system/union.md72
-rw-r--r--docs/type_system/unique.md21
-rw-r--r--docs/type_system/value.md16
-rw-r--r--docs/type_system/var.md24
-rw-r--r--mkdocs.yml70
63 files changed, 55 insertions, 3015 deletions
diff --git a/docs/application/buffer.md b/docs/application/buffer.md
deleted file mode 100644
index 40c58e4..0000000
--- a/docs/application/buffer.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Buffer
-
----
-
-## Object Definitions
-
-```c
-typedef struct _kpl_buffer {
- KPL_DYNAMIC_OBJ_HEADER();
- int32_t byte_length;
- kpl_interface *interface;
- int16_t io_register_index;
- uint8_t bytes[];
-} kpl_buffer;
-
-typedef struct {
- // TODO RING BUFFERS BY POWERS OF TWO
-} kpl_buffer_registered_pool;
-```
-
-## Io uring buffer sparse register
-
-### Set `io_register_index` to -1 if not used
-
-## Unicode Methods
diff --git a/docs/application/error.md b/docs/application/error.md
deleted file mode 100644
index 2e1e703..0000000
--- a/docs/application/error.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Error
-
----
-
-## Object Definitions
-
-```c
-typedef union : uin16_t {
- ERROR_C = 1 << 0,
- ERROR_TOKEN = 1 << 1,
- ERROR_TYPE = 1 << 2
-} kpl_error_flags;
-
-typedef struct _kpl_error {
- uint16_t line, flags;
- uin32_t class_options;
- struct _kpl_error *stack;
- union {
- struct {
- char *file, char *function;
- } c;
- kpl_token token;
- kpl_type *type;
- } source;
- kpl_class class;
-} kpl_error;
-```
diff --git a/docs/application/group.md b/docs/application/group.md
deleted file mode 100644
index 7ed6382..0000000
--- a/docs/application/group.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Group
-
----
-
-## Object Definitions
-
-```c
-typedef struct _kpl_group {
- KPL_DYNAMIC_OBJ_HEADER();
- int32_t item_length;
- kpl_class items[];
-} kpl_group;
-```
diff --git a/docs/application/identifier.md b/docs/application/identifier.md
deleted file mode 100644
index ed4f3e7..0000000
--- a/docs/application/identifier.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Identifier
-
----
-
-Store vars, types and symbols as compressed strings
-
-## Object Definitions
-
-```c
-#define KPL_IDENTIFIER_PARTS 5
-
-// TODO 50 charaters of [A-Za-z0-9_] in 40 bytes
-
-typedef struct {
- uint64_t parts[KPL_IDENTIFIER_PARTS];
-} kpl_identifier;
-```
diff --git a/docs/application/index.md b/docs/application/index.md
deleted file mode 100644
index 804e952..0000000
--- a/docs/application/index.md
+++ /dev/null
@@ -1,72 +0,0 @@
-# Runtime
-
----
-
-## Requirements
-
-* Linux X64 with io_uring (6+)
-* GNU Make
-* GCC with -std=gnu99 -fhardened (14+)
-
-## Sections
-
-* ##### [Interface](./interface.md)
-* ##### [Thread](./thread.md)
-* ##### [Mutex](./mutex.md)
-* ##### [Memory](./memory.md)
-* ##### [Io](./io.md)
-* ##### [Shared](./shared.md)
-* ##### [Identifier](./identifier.md)
-* ##### [Type](./type.md)
-* ##### [Group](./group.md)
-* ##### [Buffer](./buffer.md)
-* ##### [Map](./map.md)
-* ##### [Queue](./queue.md)
-* ##### [Union](./union.md)
-* ##### [Native](./native.md)
-* ##### [Namespace](./namespace.md)
-* ##### [Error](./error.md)
-* ##### [Testing](./testing.md)
-
-# Invocation
-
-## Startup
-
-1. Configuration
- * `thread_count` - defaults to number of available processors
-2. Initialize allocators
-3. Initialize tasks
-4. Initialize types
- * Built In Alias
-5. Initialize IO
- * Size of registered sparse buffers
-6. Initialize Jit
-7. Initialize Op Matching
-8. Initialize Ir Matching
-
-## Main
-
-### Module
-
-### String/REPL
-
-## Life cycle
-
-1. ##### [Register](../lifecycle/register.md)
-2. ##### [Parse](../lifecycle/parse.md)
-3. ##### [Scope](../lifecycle/scope.md)
-4. ##### [Import](../lifecycle/import.md)
-5. ##### [Check](../lifecycle/check.md)
-6. ##### [Eval](../lifecycle/eval.md)
-7. ##### [Ir](../lifecycle/ir.md)
-8. ##### [Jit](../lifecycle/jit.md)
-9. ##### [Exec](../lifecycle/exec.md)
-10. ##### [Notify](../lifecycle/notify.md)
-
-## Shutdown
-
-1. Clean up Jit
-2. Clean up IO
-3. Clean up types
-4. Clean up tasks
-5. Clean up allocators
diff --git a/docs/application/interface.md b/docs/application/interface.md
deleted file mode 100644
index de9eebe..0000000
--- a/docs/application/interface.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# Interface
-
----
-
-General definitions used throughout the code
-
-## Object Definitions
-
-```c
-typedef union {
- bool b;
- uint8_t u8;
- uint16_t u16;
- uint32_t u32;
- uint64_t u64;
- int8_t i8;
- int16_t i16;
- int32_t i32;
- int64_t i64;
- float f32;
- double f64;
- void *ptr;
-} kpl_any;
-
-typedef void kpl_interface_free(kpl_any a);
-
-typedef struct {
- // TODO
-} kpl_interface;
-
-typedef struct {
- kpl_any *any;
- kpl_interface *interface;
-} kpl_class;
-
-typedef enum : uint8_t {
- KPL_STATUS_ERROR,
- KPL_STATUS_NULL,
- KPL_STATUS_VALUE
-} kpl_result_status;
-
-typedef struct {
- any value;
- kpl_result_status status;
-} kpl_result;
-
-kpl_result kpl_result_error(error *er);
-
-kpl_result kpl_result_null(void);
-
-kpl_result kpl_result_value(any value);
-```
-
-## `kpl_interface`
-
-See [Operators](../language/operators.md)
diff --git a/docs/application/io.md b/docs/application/io.md
deleted file mode 100644
index a292718..0000000
--- a/docs/application/io.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# Io (io_uring)
-
----
-
-# Design
-
-## Io Ring
-
-## Fixed Buffers
-
-## Fixed Files
-
-## Buffer Rings
-
-# Io Tasks
-
-Tasks for each IO operation are stored in the `user_data` field
-
-## Ring Submission `struct io_uring_sqe`
-
-## Ring Completion `struct io_uring_cqe`
-
-# Usage
-
-## File
-
-### Open
-
-### Statx
-
-### Read
-
-### Write
-
-## Directory
-
-## Timers
-
-## Network
diff --git a/docs/application/map.md b/docs/application/map.md
deleted file mode 100644
index 18fa7a8..0000000
--- a/docs/application/map.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# Map
-
----
-
-## Object Definitions
-
-```c
-typedef struct _kpl_map_bucket {
- struct _kpl_map_bucket *prev, *next;
- kpl_any key, value;
-} kpl_map_bucket;
-
-typedef struct _kpl_map {
- KPL_DYNAMIC_OBJ_HEADER();
- int32_t available_buckets;
- kpl_interface *key_interface, *value_interface;
- kpl_map_bucket *head, *tail;
- kpl_map_bucket *buckets[];
-} kpl_map;
-```
diff --git a/docs/application/memory.md b/docs/application/memory.md
deleted file mode 100644
index e180b24..0000000
--- a/docs/application/memory.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# Memory
-
----
-
-An allocator per Object definition with ring buffer pooling based
-
-# Single Allocation
-
-Once created never freed until shutdown
-
-# Pooling Allocations
-
-## Ring Buffer
-
-## Fixed Sized Objects
-
-## Dynamic Sized Objects
-
-Dynamically sized objects must be aligned to a power of two
-
-Requires a ring buffer for each power of two
-
-## Object Definitions
-
-```c
-#define KPL_DYANMIC_OBJ_MIN_BITS 7
-
-#define KPL_DYNAMIC_OBJ_MAX_BITS 30
-
-#define KPL_DYNAMIC_OBJ_MIN_SIZE (1 << KPL_DYANMIC_OBJ_MIN_BITS)
-
-#define KPL_DYNAMIC_OBJ_MAX_SIZE (1 << KPL_DYNAMIC_OBJ_MAX_BITS)
-
-#define KPL_DYNAMIC_OBJ_HEADER() int32_t obj_size;
-
-typedef struct {
- KPL_DYNAMIC_OBJ_HEADER();
-} kpl_dynamic_obj;
-```
diff --git a/docs/application/mutex.md b/docs/application/mutex.md
deleted file mode 100644
index e1b15c7..0000000
--- a/docs/application/mutex.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Mutex
-
----
-
-## Object Definitions
-
-```c
-typedef struct {
- kpl_task_queue queue;
- _Atomic int32_t lock;
-} kpl_mutex;
-```
-
-## Usage
-
-1. Before adding to the `queue` do `value = lock++`
-2. Add to the queue
-3. If `value` is `0` the thread does an async schedule of the mutex task, otherwise the thread moves on
-
-### Mutex Task
-
-1. Get task from `queue` and run task
- * Use spinlock with `pasue`, the `lock` will be set before the task is added to the `queue`
-2. After task completion, do `value = --lock`, stop if `value` is `0`, otherwise repeat
diff --git a/docs/application/namespace.md b/docs/application/namespace.md
deleted file mode 100644
index d276fd0..0000000
--- a/docs/application/namespace.md
+++ /dev/null
@@ -1,169 +0,0 @@
-# Namespace
-
----
-
-## Object Definitions
-
-```c
-#define KPL_TREE_HEADER(STRUCT) uint32_t tree_weight, module_id; STRUCT *tree_left, *tree_right; kpl_buffer *name
-
-typedef struct _kpl_namespace_tree_obj {
- KPL_TREE_HEADER(struct _kpl_namespace_tree_obj);
-} kpl_namespace_tree_obj;
-
-typedef struct _kpl_namespace_native {
- KPL_TREE_HEADER(struct _kpl_namespace_native);
- kpl_type *export_var_tree;
-} kpl_namespace_native;
-
-static kpl_namespace_native *namespace_native_tree;
-
-typedef struct _kpl_namespace_module {
- KPL_TREE_HEADER(struct _kpl_namespace_module);
- kpl_buffer *body;
- kpl_type *ast, *export_var_tree;
- kpl_mutex export_mutex;
-} kpl_namespace_module;
-
-static kpl_namespace_module *namespace_module_tree;
-
-kpl_mutex namespace_module_tree_mutex;
-
-static kpl_namespace_module namespace_string;
-
-static kpl_namespace_module *module_array[KPL_MODULE_SIZE]; // module_id refers to index
-```
-
-Each `NAMESPACE_IDENTIFIER` maps to `kpl_namespace_native*` or `kpl_namespace_module*` depending on flags
-
-## Lookup and Storage
-
-The native and namespace objects are stored as a tree
-
-The exports are stored under a tree for both the native and namespace objects
-
-# Registering
-
-## Native
-
-TODO C code for exposing native code
-
-## Module/String/REPL
-
-### Main
-
-Begin life cycle and [Register](../lifecycle/register.md)
-
-### Scan ``import`
-
-Add a [Register](../lifecycle/register.md) task to `namespace_module_mutex`
-
-# Updating
-
-## Native
-
-### Native code should not be updated at runtime, doing so is undefined behavior
-
-## Module
-
-### ``export`
-
-Add exports directly to the namespaces `export_var_tree`, thread safe
-
-## String/REPL
-
-### Cannot export for String/REPL
-
-# Using
-
-## Native
-
-### ``use`
-
-Since the native modules are loaded statically the `native_module_tree` becomes read only at runtime, access is thread safe
-
-## Module/String/REPL
-
-### Import ``import`
-
-1. Add find namespace task to the `namespace_module_mutex`, the namespace not existing is an error
-2. Add a get export task to the namespaces `export_mutex`
-3. The `export_mutex` will not start processing it's queue until the namespace notifies that it's and unlocks its `export_mutex`
-4. The importer will get a copy of the read only `export_var_tree`
-
-# AVL Tree Storage and Lookup
-
-## AVL Tree Example
-
-```c
-typedef struct _avl {
- int val, count;
- struct _avl *left, *right;
-} avl;
-
-
-int get_count(const avl *node) {
- return node ? node->count : 0;
-}
-
-int get_balance(const avl *node) {
- if (!node)
- return 0;
- return get_count(node->left) - get_count(node->right);
-}
-
-void right_rotate(avl **right) {
- avl *left = (*right)->left, *left_right = left->right;
- left->right = *right;
- (*right)->left = left_right;
- (*right)->count = MAX(get_count((*right)->left), get_count((*right)->right)) + 1;
- left->count = MAX(get_count(left->left), get_count(left->right)) + 1;
- *right = left;
-}
-
-void left_rotate(avl **left) {
- avl *right = (*left)->right, *right_left = right->left;
- right->left = *left;
- (*left)->right = right_left;
- (*left)->count = MAX(get_count((*left)->left), get_count((*left)->right)) + 1;
- right->count = MAX(get_count(right->left), get_count(right->right)) + 1;
- *left = right;
-}
-
-void insert(avl **parent, avl *node) {
- if (!*parent) {
- *parent = node;
- return;
- }
- if (node->val < (*parent)->val)
- insert(&(*parent)->left, node);
- else
- insert(&(*parent)->right, node);
- (*parent)->count = MAX(get_count((*parent)->left), get_count((*parent)->right)) + 1;
- int balance = get_balance(*parent);
- if (balance > 1 && get_balance((*parent)->left) >= 0)
- right_rotate(parent);
- if (balance > 1 && get_balance((*parent)->left) > 0) {
- left_rotate(&(*parent)->left);
- right_rotate(parent);
- }
- if (balance < -1 && get_balance((*parent)->right) <= 0)
- left_rotate(parent);
- if (balance < -1 && get_balance((*parent)->right) > 0) {
- right_rotate(&(*parent)->right);
- left_rotate(parent);
- }
-}
-
-struct TreeNode* sortedListToBST(struct ListNode* head) {
- avl *root = NULL;
- while (head) {
- avl *node = calloc(1, sizeof(avl));
- node->val = head->val;
- node->count = 1;
- head = head->next;
- insert(&root, node);
- }
- return (struct TreeNode*) root;
-}
-```
diff --git a/docs/application/native.md b/docs/application/native.md
deleted file mode 100644
index c5108aa..0000000
--- a/docs/application/native.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Native
-
----
-
-## Object Definitions
-
-```c
-typedef struct _kpl_native {
- kpl_class class;
-} kpl_native;
-```
diff --git a/docs/application/queue.md b/docs/application/queue.md
deleted file mode 100644
index a770ac7..0000000
--- a/docs/application/queue.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Queue
-
----
-
-## Object Definitions
-
-```c
-typedef struct _kpl_queue_item {
- struct _kpl_queue_item *prev, *next;
- kpl_any any;
-} kpl_queue_item;
-
-typedef struct _kpl_queue {
- int32_t item_length;
- kpl_interface *interface;
- kpl_pool_any *head, *tail;
-} kpl_queue;
-```
diff --git a/docs/application/shared.md b/docs/application/shared.md
deleted file mode 100644
index 0528645..0000000
--- a/docs/application/shared.md
+++ /dev/null
@@ -1,38 +0,0 @@
-# Shared
-
----
-
-## Object Definitions
-
-```c
-typedef struct _kpl_shared {
- bool mark;
- kpl_class data;
- kpl_mutex mutex;
-} kpl_shared;
-
-_Atomic uint32_t shared_threads_makred;
-
-static kpl_shared *shared_mark_head, *shared_head;
-
-static kpl_mutex shared_head_mutex;
-```
-
-# Garbage Collection
-
-## Initiation Task
-
-1. Move `shared_head` to `shared_mark_head`
-2. Set `shared_threads_makred` to 0
-3. Add a mark task to each of the threads
-
-## Mark Task(s)
-
-1. Run gc interface on each task in the threads queue
-2. Increase `shared_threads_makred`
-3. If `shared_threads_makred` is equal to `avaiable_threads` schedule sweep task
-
-## Sweep Task
-
-1. Go through `shared_mark_head` freeing anything that is not marked
-2. Add anything left on `shared_mark_head` to `shared_head`
diff --git a/docs/application/testing.md b/docs/application/testing.md
deleted file mode 100644
index 710915c..0000000
--- a/docs/application/testing.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# Testing
-
----
-
-## Macros
-
-```c
-TEST(NAME) {
- // TEST BODY
-}
-
-ASSERT(CONDITION, FAIL_STRING)
-
-FAIL(FAIL_STRING)
-```
-
-## Object Definitions
-
-```c
-typedef struct {
- const char *name;
- kpl_error *error;
-} kpl_test;
-
-// TODO STORE ERRORS FOR PRINT AT END
-
-#define _TEST_FN(NAME) static void kpl_test_fn_##NAME(__attribute__(unused)) kpl_test *_test)
-
-#define TEST(NAME) \
- _TEST_FN(NAME); \
- static void __attribute__((constructor)) _kpl_test_constructor_##NAME(void) { \
- kpl_test _test = { .name = #NAME; .error = NULL }; \
- kpl_test_fn_##NAME(&test); \
- if (_test.error) { \
- /* TODO STORE ERROR */ \
- } \
- /* TODO PRINT STATUS */ \
- } \
- _TEST_FN(NAME)
-
-// TODO ASSERT
-
-// TODO FAIL
-```
-
-## `make test`
-
-Bundle all tests into a single executable
-
-## `TEST_FILES="$NAMES..." make test`
-
-Only build specified file(s)
diff --git a/docs/application/thread.md b/docs/application/thread.md
deleted file mode 100644
index 91fa168..0000000
--- a/docs/application/thread.md
+++ /dev/null
@@ -1,415 +0,0 @@
-# Threads
-
----
-
-## Object Definitions
-
-```c
-typedef struct _kpl_task kpl_task;
-
-typedef void kpl_task_fn(kpl_task *t);
-
-#define KPL_TASK_STATE_SIZE 24
-
-typedef struct _task {
- task *_Atomic next, *join, *parent;
- kpl_class state[KPL_TASK_STATE_SIZE];
- kpl_result result;
- task_fn *fn;
- uint32_t io_flags;
- int32_t io_res, thread_id;
- int16_t state_length;
- _Atomic bool join_ready;
-} task;
-
-#define KPL_MAIN_THREAD 0
-
-typedef struct {
- kpl_task *_Atomic head, *_Atomic tail;
- struct {
- kpl_task *_Atomic next;
- } dummy;
-} kpl_task_queue;
-
-typedef struct {
- kpl_task_queue queue;
- _Atomic ssize_t priority;
- sem_t counter;
- pthread_t thread;
-} kpl_thread;
-```
-
-## Initialization
-
-On the start of each thread, set the cpu affinity to its thread id
-
-## Task State
-
-```text
-0 -> length
-native : arguments
-process : arguments, locals
-closure : arguments, locals, closure function
-iterator : arguments, locals, iterator function index, iterator functions
-regex : captures, function state, regex function
-```
-
-## Per Process Task Queue
-
-## Asynchronous Task Queue
-
-# Queuing
-
-## Sync
-
-Queue task on selected thread
-
-## Async
-
-Queue task on thread with lowest `priority`
-
-# Running
-
-## Joining
-
-# Thread Pool Management
-
-Run task to check thread pool sizes and create tasks to spread out a large pool across other threads
-
-# Example
-
-```c
-// gcc -std=gnu99 -Wall -Wextra -O2 -fhardened -fno-omit-frame-pointer -o thread_queue thread_queue.c
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <sched.h>
-#include <assert.h>
-
-#define I 50
-
-#define FIB 25
-
-typedef struct _task task;
-
-typedef void task_fn(task *t);
-
-#define TASK_STATE_SIZE 55
-
-typedef struct _task {
- task *_Atomic next, *join;
- void *state[TASK_STATE_SIZE];
- void *return_value;
- task_fn *fn;
- int32_t thread_id;
- _Atomic bool join_ready;
-} task;
-
-#define TASK_SLAB_SIZE 50
-
-typedef struct _task_slab {
- size_t array_index;
- struct _task_slab *next;
- task array[TASK_SLAB_SIZE];
-} task_slab;
-
-#define QUEUE_ASYNC -1
-
-#define MAIN_THREAD 0
-
-typedef struct {
- task *_Atomic head, *_Atomic tail;
- struct {
- task *_Atomic next;
- } dummy;
-} atomic_queue;
-
-typedef struct {
- atomic_queue queue;
- _Atomic ssize_t priority;
- task_slab *slab;
- task *pool;
- sem_t counter;
- pthread_t thread;
-} thread;
-
-int32_t avaiable_threads = {};
-
-#define MAX_THREADS 64
-
-thread threads[MAX_THREADS];
-
-_Atomic ssize_t total_priority = {};
-
-void priority_increment(int32_t thread_id) {
- threads[thread_id].priority++;
- total_priority++;
-}
-
-void priority_decrement(int32_t thread_id) {
- threads[thread_id].priority--;
- total_priority--;
-}
-
-void task_slab_init(int32_t thread_id) {
- task_slab *slab = calloc(1, sizeof(task_slab));
- slab->next = threads[thread_id].slab;
- threads[thread_id].slab = slab;
-}
-
-task *task_slab_get(int32_t thread_id) {
- if (threads[thread_id].slab->array_index < TASK_SLAB_SIZE)
- return &threads[thread_id].slab->array[threads[thread_id].slab->array_index++];
- task_slab_init(thread_id);
- return task_slab_get(thread_id);
-}
-
-void task_slab_free(int32_t thread_id) {
- task_slab *slab = threads[thread_id].slab;
- while (slab) {
- task_slab *tmp = slab;
- slab = slab->next;
- free(tmp);
- }
-}
-
-void task_queue_init(int32_t thread_id) {
- threads[thread_id].queue.head = (task*) &threads[thread_id].queue.dummy;
- threads[thread_id].queue.tail = (task*) &threads[thread_id].queue.dummy;
- threads[thread_id].queue.dummy.next = NULL;
- threads[thread_id].priority = 1;
- threads[thread_id].pool = NULL;
-}
-
-void task_queue_add(int32_t thread_id, task *t) {
- t->next = NULL;
- task *head = __atomic_exchange_n(&threads[thread_id].queue.head, t, __ATOMIC_SEQ_CST);
- head->next = t;
- if (t != (task*) &threads[thread_id].queue.dummy)
- priority_increment(thread_id);
-}
-
-task *task_queue_next(int32_t thread_id) {
- task *t = NULL;
- for (;;) {
- task *tail = threads[thread_id].queue.tail, *next = tail->next;
- if (tail == (task*) &threads[thread_id].queue.dummy) {
- if (!next)
- break;
- threads[thread_id].queue.tail = next;
- tail = next;
- next = tail->next;
- }
- if (next) {
- threads[thread_id].queue.tail = next;
- t = tail;
- break;
- }
- task *head = threads[thread_id].queue.head;
- if (tail != head)
- continue;
- task_queue_add(thread_id, (task*) &threads[thread_id].queue.dummy);
- next = tail->next;
- if (next) {
- threads[thread_id].queue.tail = next;
- t = tail;
- break;
- }
- }
- if (t) {
- t->next = NULL;
- priority_decrement(thread_id);
- }
- return t;
-}
-
-task *task_init(task_fn *fn, int32_t thread_id) {
- task *t = NULL;
- if (threads[thread_id].pool) {
- t = threads[thread_id].pool;
- threads[thread_id].pool = threads[thread_id].pool->join;
- }
- if (!t)
- t = task_slab_get(thread_id);
- __atomic_clear(&t->join_ready, __ATOMIC_SEQ_CST);
- t->thread_id = QUEUE_ASYNC;
- for (ssize_t state_id = 0; state_id < TASK_STATE_SIZE; state_id++)
- t->state[state_id] = NULL;
- t->return_value = NULL;
- t->next = NULL;
- t->join = NULL;
- t->fn = fn;
- return t;
-}
-
-void task_free(task *t) {
- t->join = threads[t->thread_id].pool;
- threads[t->thread_id].pool = t;
-}
-
-void task_queue_async(task *t) {
- int32_t queue_thread_id = 0;
- ssize_t queue_priority = threads[0].priority;
- for (int32_t thread_id = 1; thread_id < avaiable_threads; thread_id++) {
- if (threads[thread_id].priority < queue_priority) {
- queue_priority = threads[thread_id].priority;
- queue_thread_id = thread_id;
- }
- }
- task_queue_add(queue_thread_id, t);
- sem_post(&threads[queue_thread_id].counter);
-}
-
-void task_done(task *t) {
- if (!__atomic_test_and_set(&t->join_ready, __ATOMIC_SEQ_CST) || !t->join)
- return;
- task *join = t->join;
- t->join = NULL;
- __atomic_clear(&t->join_ready, __ATOMIC_SEQ_CST);
- if (join->thread_id == t->thread_id)
- task_queue_add(t->thread_id, join);
- else
- task_queue_async(join);
-}
-
-void task_join(task *restrict t, task *restrict join, task_fn *fn) {
- join->fn = fn;
- t->join = join;
- task_done(t);
-}
-
-void *task_loop(void *arg) {
- const int32_t thread_id = (int32_t) (intptr_t) arg;
- cpu_set_t cpus;
- CPU_ZERO(&cpus);
- CPU_SET(thread_id, &cpus);
- if (pthread_setaffinity_np(pthread_self(), sizeof(cpus), &cpus))
- exit(thread_id + 1);
- for (;;) {
- task *t = task_queue_next(thread_id);
- if (t) {
- t->thread_id = thread_id;
- t->fn(t);
- continue;
- }
- priority_decrement(thread_id);
- if (!total_priority) {
- for (int32_t thread_id = 0; thread_id < avaiable_threads; thread_id++)
- sem_post(&threads[thread_id].counter);
- break;
- }
- sem_wait(&threads[thread_id].counter);
- if (!total_priority)
- break;
- priority_increment(thread_id);
- }
- return NULL;
-}
-
-void task_run() {
- for (int32_t thread_id = 1; thread_id < avaiable_threads; thread_id++)
- pthread_create(&threads[thread_id].thread, NULL, task_loop, (void*) (intptr_t) thread_id);
- task_loop(MAIN_THREAD);
- for (int32_t thread_id = 1; thread_id < avaiable_threads; thread_id++)
- pthread_join(threads[thread_id].thread, NULL);
-}
-
-void task_constructor(void) {
- cpu_set_t cpus;
- CPU_ZERO(&cpus);
- sched_getaffinity(0, sizeof(cpus), &cpus);
- total_priority = avaiable_threads = CPU_COUNT(&cpus);
- for (int32_t thread_id = 0; thread_id < avaiable_threads; thread_id++) {
- task_queue_init(thread_id);
- task_slab_init(thread_id);
- sem_init(&threads[thread_id].counter, 0, 1);
- }
-}
-
-void task_destructor(void) {
- for (int32_t thread_id = 0; thread_id < avaiable_threads; thread_id++) {
- sem_destroy(&threads[thread_id].counter);
- task_slab_free(thread_id);
- }
-}
-
-void fib_c(task *t) {
- task *child_a = t->state[2], *child_b = t->state[3];
- t->return_value = (void*) ((intptr_t) child_a->return_value + (intptr_t) child_b->return_value);
- task_free(child_a);
- task_free(child_b);
- task_done(t);
-}
-
-void fib_a(task *t);
-
-void fib_b(task *t) {
- intptr_t arg = (intptr_t) t->state[1];
- task *child_b = t->state[3] = task_init(fib_a, t->thread_id);
- child_b->state[1] = (void*) (arg - 2);
- task_queue_add(t->thread_id, child_b);
- task_join(child_b, t, fib_c);
-}
-
-void fib_a(task *t) {
- intptr_t arg = (intptr_t) t->state[1];
- if (arg <= 0) {
- t->return_value = (void*) 0;
- task_done(t);
- return;
- }
- if (arg < 2) {
- t->return_value = (void*) 1;
- task_done(t);
- return;
- }
- task *child_a = t->state[2] = task_init(fib_a, t->thread_id);
- child_a->state[1] = (void*) (arg - 1);
- task_queue_add(t->thread_id, child_a);
- task_join(child_a, t, fib_b);
-}
-
-_Atomic size_t counter = 0;
-
-void start_b(task *t) {
- counter++;
- task *f = t->state[(intptr_t) t->state[0]];
- intptr_t i = (intptr_t) f->state[0], arg = (intptr_t) f->state[1], ret = (intptr_t) f->return_value;
- printf("i: %ld, fib(%ld) = %ld, thread: %d\n", i, arg, ret, f->thread_id);
- task_free(f);
- t->state[0]++;
- if ((intptr_t) t->state[0] == I + 1) {
- printf("Complete\n");
- task_done(t);
- task_free(t);
- return;
- }
- task_join(t->state[(intptr_t) t->state[0]], t, start_b);
-}
-
-void start_a(task *t) {
- t->state[0] = (void*) 1;
- for (intptr_t i = 1; i <= I; i++) {
- task *f = task_init(fib_a, t->thread_id);
- f->state[0] = (void*) i;
- f->state[1] = (void*) FIB;
- t->state[i] = f;
- task_queue_async(f);
- }
- task_join(t->state[(intptr_t) t->state[0]], t, start_b);
-}
-
-int main(void) {
- task_constructor();
- task *t = task_init(start_a, MAIN_THREAD);
- task_queue_add(MAIN_THREAD, t);
- task_run();
- task_destructor();
- assert(counter == I);
- return 0;
-}
-```
diff --git a/docs/application/type.md b/docs/application/type.md
deleted file mode 100644
index b16b70f..0000000
--- a/docs/application/type.md
+++ /dev/null
@@ -1,101 +0,0 @@
-# Type
-
----
-
-## Object Definitions
-
-```c
-typedef enum : uint8_t {
- // ...
-} kpl_type_template;
-
-typedef enum : uint8_t {
- KPL_TYPE_QUALIFIER_CONST = 1 << 0,
- KPL_TYPE_QUALIFIER_EMPTY = 1 << 1,
- KPL_TYPE_QUALIFIER_REF = 1 << 2,
- KPL_TYPE_QUALIFIER_SHARED = 1 << 3,
- KPL_TYPE_QUALIFIER_RETURN = 1 << 4
-} kpl_type_qualifiers;
-
-typedef struct {
- kpl_type_template template;
- uint8_t qualifiers;
- uint16_t modifiers;
-} kpl_type_header;
-
-typedef struct {
- uint16_t length, line;
- int32_t position, module_id;
-} kpl_token;
-
-typedef enum {
- KPL_NATIVE_STORAGE_NONE,
- KPL_NATIVE_STORAGE_GENERAL_REGISTER,
- KPL_NATIVE_STORAGE_XMM_REGISTER,
- KPL_NATIVE_STORAGE_STACK
-} kpl_native_storage;
-
-typedef struct {
- uint8_t storage : 2, id : 6;
-} kpl_native_id;
-
-typedef union {
- // 64 Bytes Max
-} kpl_type_body;
-
-typedef struct _kpl_type {
- kpl_type_header header;
- union {
- kpl_token token;
- struct {
- kpl_native_id native_id;
- int8_t process_state_id; // -1 not used
- uint16_t tree_weight;
- struct _kpl_type *list;
- } var;
- } meta;
- _Atomic ssize_t ref_count;
- struct _kpl_type *prev, *next;
- kpl_type_body body;
-} kpl_type;
-```
-
-# Type Matching
-
-For type checking, evaluation and Ir generation
-
-Match based on the templates, from end of each statement to its start
-
-## Op Matching
-
-Each Step is represented as a tree with sequential steps as sub trees
-
-1. Op Name
-2. Op Return Type
-3. Op Left
-4. Op Right
-5. Match Mode (Check, Eval, Ir)
-
-```c
-typedef enum : uint8_t {
- KPL_OP_MATCH_CHECK,
- KPL_OP_MATCH_EVAL,
- KPL_OP_MATCH_IR
-} kpl_op_match_mode;
-
-typedef struct _kpl_op_match {
- int32_t tree_weight;
- union {
- kpl_op_match_mode mode;
- kpl_op_name op_name;
- kpl_type_header header;
- } value;
- union {
- struct _kpl_op_match *children;
- union {
- // TODO FUNCTION POINTERS FOR EACH MODE
- } fn;
- } next;
- struct _kpl_op_match *tree_left, *tree_right;
-} kpl_op_match;
-```
diff --git a/docs/application/union.md b/docs/application/union.md
deleted file mode 100644
index 984253c..0000000
--- a/docs/application/union.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Union
-
----
-
-## Object Definitions
-
-```c
-typedef struct _kpl_union {
- uint32_t tag;
- kpl_class class;
-} kpl_union;
-```
diff --git a/docs/definitions.md b/docs/definitions.md
new file mode 100644
index 0000000..0b1140e
--- /dev/null
+++ b/docs/definitions.md
@@ -0,0 +1,47 @@
+# Definitions
+
+Kevin's nomenclature for Kevin's language
+
+---
+
+## Syntax Definitions
+
+### Var `[a-z][0-9A-Za-z_]{0,49}`
+
+### Type `[A-Z][0-9A-Za-z_]{0,49}`
+
+### Qualifier `%[a-z]\+`
+
+### Symbol `\.[0-9A-Za-z_]{1,50}`
+
+### Character `'\\?.'
+
+### String `".*?"`
+
+### Operator ``[a-z].*?\|[~!$&*-+=|:;,./]`
+
+### Statement
+
+### Separator `\n\|;`
+
+### List `()`
+
+### Definition `[]`
+
+### Action `[@#^?]`
+
+### Body `{}`
+
+## Runtime Definitions
+
+### Task
+
+A collection of runtime state
+
+### Procedure
+
+A collection of code for a task
+
+### Process
+
+A collection of procedures for a task
diff --git a/docs/index.md b/docs/index.md
index 72a679c..fda9b2c 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -1,50 +1,7 @@
-# Kevins Programming Language (KPL) Specification
+# Kevins Programming Language (KPL)
-### Version 0.0.0
+Typed Jitted Asynchronous
----
-
-## Overview
-
-KPL is a statically typed and just in time compiled scripting language. The goal is to be something lower level then JavaScript/Python/Ruby/Lua but on a higher level then Go.
-
-This specification not only describes the language syntax but it's implementation because syntax reflects the implementation and vice versa.
-
-#### Language Design Goals
-
-* Single invocation, just run the code
-
-* No operator precedence
-
-* No default variables
-
-* Type inference
+Language Specification Version 0.0.0
-* Automatically use threads
-
-* All code can be run asynchronously, no built in asynchronous callback functions
-
-```text
-// Do Soemthing
-readFile("filename", callback(data))
-// Continue while readFile is running
-// --- langauge equivalent
-// Do Soemthing
-([name; callback]
- `use "file" [open; read]
- callback `sync String $ read `sync open `sync name
-) `async ("filename"; callback)
-// Continue while readFile is running
-```
-
-* C interoperability
-
-* Minimal dependencies, most X64 Linux distros shouldn't need to install anything to compile and run the source
-
-* Lightweight, can run a VPS with 1 CPU Core and 1 Gigabyte of RAM
-
-## Contents
-
-1. ##### [Language](./language/index.md)
-2. ##### [Type System](./type_system/index.md)
-3. ##### [Application](./application/index.md)
+---
diff --git a/docs/language/index.md b/docs/language/index.md
deleted file mode 100644
index 1f50a17..0000000
--- a/docs/language/index.md
+++ /dev/null
@@ -1,225 +0,0 @@
-# Code
-
----
-
-Code is encoded as UTF-8, allowed glyphs are:
-
-```text
-abcdefghijklmnopqrstuvwxyz
-ABCDEFGHIJKLMNOPQRSTUVWXYZ
-0123456789
-`~!@#$%^&*()-_=+{}[]\|;:'"<>,.?/
-\s\t\n
-```
-
-# Comments
-
-```text
-// This is a comment until the end of the line
-
-/* Comment block */
-```
-
-# Atoms
-
-## Number Literals
-
-```text
-12 // Decimal
-```
-
-##### Integer
-
-```text
-0x12 // Hex
-0b10 // Binary
-0o75 // Octal
-```
-
-##### Float
-
-```text
-1.2
-1e6
-```
-
-Underscores `_` can separate digits in a number
-
-```text
-100_000
-1.100_000
-1_ // Invalid
-```
-
-## String and Char Literals
-
-```text
-"Asdf\n"
-'A'
-```
-
-### String literals have a `2 ^ 16 - 2` token byte limit
-
-### Char literals have a `6` token byte limit
-
-Any UTF-8 glyph is allowed between `""` or `''`
-
-```text
-Ω // Invalid code
-"Ω" // Valid code
-'Ω' // Valid code
-```
-
-## Variable Names
-
-Start with a lowercase letter
-
-Variables starting with `_` are treated as unused
-
-### Variables names have a 50 character limit
-
-## Type Names
-
-Start with an uppercase letter created with either \`alias or \`unique
-
-### Type names have a 50 character limit
-
-## Type Qualifiers
-
-Start with `%`
-
-# Operators
-
-Represented as an symbol or a keyword starting with \`
-
-```text
-1 + 2
-1 `add 2
-```
-
-## Operator Conventions
-
-```text
-`operator FIRST
-
-FIRST `operator SECOND
-
-FIRST `operator (REST; ...)
-
-`operator (FIRST; REST; ...)
-```
-
-# Symbols
-
-Start with a `.`
-
-```test
-.symbol
-```
-
-### Symbols have a 50 character limit
-
-# Lists
-
-A list of statements between `()` separated by `;` or `\n`
-
-```text
-(1; 2; 3)
-```
-
-# Definitions
-
-A list of definitions between `[]` separated by `;` or `\n`
-
-```text
-Type[arg]
-```
-
-## Destructuring
-
-Take values out of a collection
-
-```text
-target [VAR_NAME.TARGET_NAME]
-target [VAR_NAME] // Resolves to VAR_NAME.VAR_NAME
-target [VAR_NAME_AT_INDEX]
-```
-
-### Destructuring Example with Indexes
-
-```text
-v : Tuple $ (1; 2; 3)
-v [a; b; c]
-`log a // I64.a $ 1
-`log b // I64.b $ 2
-`log c // I64.c $ 3
-```
-
-# Actions
-
-A list of statements between `{}` separated by `;` or `\n` associated with a conditional
-
-Arguments are specified with a `[]` at the beginning of the `{}`
-
-## Conditionals
-
-### Loop `@`
-
-```text
-@ condition { statements }
-
-@ condition {[args] statements }
-
-@ (value; condition; increment) {[value] statements }
-
-@.name condition { statements }
-
-@.name condition {[args] statements }
-```
-
-#### ``break` `break .name`
-
-Stops a loop
-
-```text
-@.a 1 .. 5 {[x]
- @.b 1 .. 5 {[y]
- ? x = y { `break .a }
- }
-}
-```
-
-#### ``continue` `continue .name`
-
-Move loop to next iteration
-
-### If `?`
-
-```text
-? condition { statements }
-
-? condition { true statements } { false statements }
-
-? {
- condition { statements }
- { default statements }
-}
-
-? condition {[arg] statements }
-```
-
-### Match `#`
-
-```text
-# match {
- target { statements }
- target {[arg] statements }
- { default statements }
-}
-```
-
-### Mutation `^`
-
-```test
-^ mutation {[arg] statements }
-```
diff --git a/docs/language/operators.md b/docs/language/operators.md
deleted file mode 100644
index 2b843ec..0000000
--- a/docs/language/operators.md
+++ /dev/null
@@ -1,99 +0,0 @@
-# General Operators
-
----
-
-## Assign `:`
-
-## Shadow `::`
-
-## Cast `$`
-
-```c
-typedef kpl_result kpl_interface_cast(kpl_type to, const kpl_any from);
-```
-
-## ``log`
-
-Configurable logger, destination can be changed
-
-```c
-typedef void kpl_interface_log(kpl_type type, const kpl_any any, const FILE *file, int32_t idnt, uint32_t options);
-```
-
-## ``debugger`
-
-## ``thread_id`
-
-```text
-Thread_id `unique I32
-```
-
-## ``thread_count`
-
-## ``format`
-
-```text
-Result[String] : Value[String]`format Any
-```
-
-### Formatting
-
-#### Replace
-
-Use `%` to indicate an item from `Any`, use `\%` for a literal `%`
-
-#### Colors
-
-Use `#NAME#` to change the text color, use `#` to reset the text color, use `\#` for a literal `#`
-
-```text
-BOLD
-FAINT
-ITALIC
-UNDERLINE - UL
-
-BACKGROUND - BG
-LIGHT
-
-BLACK
-RED
-GREEN
-YELLOW
-BLUE
-MAGENTA
-CYAN
-GREY
-WHITE
-```
-
-`#NAME#NAME#` use single `#` to apply multiple colors at once
-
-```c
-typedef kpl_result kpl_interface_format(const kpl_buffer *format, [const kpl_any]..., NULL);
-```
-
-## ``panic`
-
-Stops execution and prints `Any` to `stdout`
-
-```text
-`panic any
-```
-
-## ``type`
-
-## ``sync_type`
-
-## ``async_type`
-
-## ``copy`
-
-```c
-typedef kpl_result kpl_interface_copy(const kpl_any any);
-```
-
-## ``hash`
-
-```c
-typedef uint64_t kpl_interface_hash(const kpl_any any);
-```
diff --git a/docs/language/ownership.md b/docs/language/ownership.md
deleted file mode 100644
index 26eebe1..0000000
--- a/docs/language/ownership.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# Ownership
-
----
-
-# Copying
-
-## Assignment
-
-# Moving
-
-## Assignment is not allowed for movable types that are not shared
-
-## To And From Functions
-
-# Passing
-
-## References
-
-References are automatically taken if the function signature specifies ref
-
-```text
-int_array : Array[I64] $ ()
-float_array : Array[F64] $ ()
-@ 0 .. 2 {[x]
- ([%ref x; y] x `push y + 1) `sync (int_array, x)
- ([%ref x; y] x `push y + 1) `sync (float_array, F64 $ x)
-}
-`log int_array // Array[I64] $ (1; 2; 3)
-`log float_array // Array[F64] $ (1.0; 2.0; 3.0)
-```
-
-#### Functions that take references cannot be called with ``async`
-
-# Shared Types
-
-# Locking
-
-Prevent modification until a mutation occurs
-
-## References
-
-# Mutating
-
-Unlock a lock or shared target and prevents modification to everything except the lock target
diff --git a/docs/lifecycle/check.md b/docs/lifecycle/check.md
deleted file mode 100644
index cdaea80..0000000
--- a/docs/lifecycle/check.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Check
-
----
-
-Type checking
-
-# Ops
-
-# Actions
-
-## Branches
-
-# Functions
-
-## Return Type
-
diff --git a/docs/lifecycle/eval.md b/docs/lifecycle/eval.md
deleted file mode 100644
index b96482d..0000000
--- a/docs/lifecycle/eval.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Eval
-
----
-
-Reduce AST size by evaluating expressions
-
-## Constant Expressions
-
-## Known Variables
-
-## Type Operations
diff --git a/docs/lifecycle/exec.md b/docs/lifecycle/exec.md
deleted file mode 100644
index bd2012c..0000000
--- a/docs/lifecycle/exec.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Exec
-
----
-
-## Exports
diff --git a/docs/lifecycle/import.md b/docs/lifecycle/import.md
deleted file mode 100644
index 669e67b..0000000
--- a/docs/lifecycle/import.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Import
-
----
-
-Find each import node and wait for the import to complete life cycle, then get a copy of its `export_tree`
diff --git a/docs/lifecycle/ir.md b/docs/lifecycle/ir.md
deleted file mode 100644
index 376189c..0000000
--- a/docs/lifecycle/ir.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Ir
-
----
-
-Convert an AST into a list of 6 address instructions
-
-# Ops
-
-## Boolean
-
-# Actions
-
-## If
-
-## Loop
-
-## Match
-
-## Mutate
-
-# Process
-
-## Tasks
-
-# Native Functions
diff --git a/docs/lifecycle/jit.md b/docs/lifecycle/jit.md
deleted file mode 100644
index 3ef73e0..0000000
--- a/docs/lifecycle/jit.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# Jit
-
----
-
-Convert Ir Into X64 (X86_64)
-
-## Limitations
-
-### No Segmentation Registers
-
-### No X87 Support
-
-### No access to the upper 8 bits of the lower 16 bits of registers AX, BX, CX, DX
-
-## Required Implicit Registers
-
-Instructions that implicitly modify a register now require the register as an argument
-
-# Operation
-
-Each instruction is written with varardic c functions with `TYPE`, `DATA` syntax
-
-## TYPE
-
-### General Registers Width
-
-### General Register Addresses Width
-
-### General Register Scale
-
-### General Register Id
-
-### General Register Memory Offset
-
-### XMM Registers
-
-### MM Registers
-
-### Immediate Value
-
-### Relative Address
-
-### Label
-
-## DATA
-
-## Object Definitions
-
-```c
-kpl_x64_lable(label)
-
-kpl_x64_inst(INSTRUCTION, [TYPE, VALUE]..., END)
-
-kpl_x64_inst_pfx(PREFIX, INSTRUCTION, [TYPE, VALUE]..., END)
-```
-
-# Ir Matching
-
-Use tree with sub trees to match Ir operations to JIT functions
-
-1. Match Name
-2. Match Args until None or End
-3. Run JIT Fn
-
-## Object Definitions
-
-```c
-typedef struct _kpl_ir_match {
- int32_t tree_weight;
- union {
- kpl_ir_name ir_name;
- kpl_type_header type_header;
- } match;
- union {
- struct _kpl_ir_match *children;
- void *jit_fn; // TODO
- } next;
- struct _kpl_ir_match *tree_left *tree_right;
-} kpl_ir_match;
-```
diff --git a/docs/lifecycle/notify.md b/docs/lifecycle/notify.md
deleted file mode 100644
index 4c53254..0000000
--- a/docs/lifecycle/notify.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Notify
-
----
-
-## Release Export Mutex
diff --git a/docs/lifecycle/parse.md b/docs/lifecycle/parse.md
deleted file mode 100644
index 6d702a8..0000000
--- a/docs/lifecycle/parse.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# Parse
-
----
-
-Build initial AST
-
-# Value
-
-## Integer `\d+`
-
-## Float `\d+\.\d+`
-
-## String `".*?"`
-
-## Char `'\\?.'
-
-# Name `[_a-z][a-zA-z0-9_]{0,49}`
-
-# Type `[A-Z][a-zA-z0-9_]{0,49}`
-
-On type completion look up if type is a builtin
-
-# Symbol `\.[a-zA-z0-9_]{0,50}`
-
-# Op
-
-## Op ``[a-z_]+|OPERATORS`
-
-## Action `[?@#^]`
-
-# List
-
-## List `()`
-
-## Define `[]`
-
-## Action `{}`
diff --git a/docs/lifecycle/register.md b/docs/lifecycle/register.md
deleted file mode 100644
index bffb3a8..0000000
--- a/docs/lifecycle/register.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Register
-
----
-
-## Module
-
-1. Add findsert task to `namespace_module_mutex`
- * If found, stop
-2. Create the namespace, lock its `export_mutex` and add to namespace tree
-3. Create task on the new namespaces to read the file into a string
-4. On completion of the read task start a parse task
-
-## String
-
-1. Add task to set new `kpl_buffer` to `namespace_string` `module_string`
-2. The set task will start a parse task
diff --git a/docs/lifecycle/scope.md b/docs/lifecycle/scope.md
deleted file mode 100644
index 3310888..0000000
--- a/docs/lifecycle/scope.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Scope
-
----
-
-## Initialize Functions
-
-## Type Variables
-
-## Link Functions Parents
-
-## Link Function Scopes
-
-## Create Vars
-
-## Initialize Actions
-
-## Split Process Into Tasks by `await`
-
-## Register Imports
-
-On finding an import node add a register task for the imported string
-
-## Initialize Generics
-
-## Resolve Unique And Alias Types
diff --git a/docs/type_system/alias.md b/docs/type_system/alias.md
deleted file mode 100644
index c98722b..0000000
--- a/docs/type_system/alias.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Alias
-
----
-
-A type based on a complete template that is interchangeable with what it is based on
-
-## \`alias
diff --git a/docs/type_system/bit.md b/docs/type_system/bit.md
deleted file mode 100644
index b5ffed3..0000000
--- a/docs/type_system/bit.md
+++ /dev/null
@@ -1,134 +0,0 @@
-# Bit
-
----
-
-A sequence of bits that can fit into a general register
-
-```text
-SIZE_FLAGS : BIT_ANY | BIT8 | BIT16 | BIT32 | BIT64
-
-REPRESENTATION_FLAGS : NUMBER | INT | INT_UNSIGNED | INT_SIGNED | FLOAT |
- UTF8 | UTF16 | UTF32 |
- BOOL |
- TYPE
-
-Bit[[SIZE_FLAGS | REPRESENTATION_FLAGS]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_interface *interface;
-} kpl_type_body_bit;
-```
-
-# Casting
-
-# Alias
-
-```text
-Number `alias Bit[[BIT_ANY | NUMBER]]
-
-Int `alias Bit[[BIT_ANY | INT]]
-
-Int_unsiged `alias Bit[[BIT_ANY | INT_UNSIGNED]]
-
-U8 `alias Bit[[BIT8 | INT_UNSIGNED]]
-U16 `alias Bit[[BIT16 | INT_UNSIGNED]]
-U32 `alias Bit[[BIT32 | INT_UNSIGNED]]
-U64 `alias Bit[[BIT64 | INT_UNSIGED]]
-
-Int_signed `alias Bit[[BIT_ANY | INT_SIGNED]]
-
-I8 `alias Bit[[BIT8 | INT_SIGNED]]
-I16 `alias Bit[[BIT16 | INT_SIGNED]]
-I32 `alias Bit[[BIT32 | INT_SIGNED]]
-I64 `alias Bit[[BIT64 | INT_SIGNED]]
-
-Float `alias Bit[[BIT_ANY | FLOAT]]
-
-F32 `alias Bit[[BIT32 | FLOAT]]
-F64 `alias Bit[[BIT64 | FLOAT]]
-
-Char `alias Bit[[BIT32 | UTF8]]
-
-Bool `alias Bit[[BIT8 | BOOL]]
-
-Type `alias Bit[[BIT64 | TYPE]]
-```
-
-# Operators
-
-## Arithmetic
-
-### Add `+`
-
-### Sub `-`
-
-### Mul `*`
-
-### Div `/`
-
-### ``mod`
-
-### ``exp`
-
-### ``ln`
-
-## Boolean
-
-### ``true`
-
-### ``false`
-
-### Not `!`
-
-### Equal `=`
-
-### Not Equal `!=`
-
-### And `&`
-
-### Or `|`
-
-### Greater `>`
-
-### Greater Equal `>=`
-
-### Less `<`
-
-### Less Equal `<=`
-
-## Bitwise
-
-### ``bit_not`
-
-### ``bit_and`
-
-### ``bit_or`
-
-### ``bit_xor`
-
-### ``bit_ls`
-
-### ``bit_rs`
-
-## Other
-
-### Compare `<=>`
-
-```c
-typedef ssize_t kpl_interface_compare(const kpl_any any_a, const kpl_any any_b);
-```
-
-# Char
-
-```text
-c : 'Σ'
-`log c // Char $ 'Σ'
-```
-
-# Type
-
-KPL Types as values
diff --git a/docs/type_system/buffer.md b/docs/type_system/buffer.md
deleted file mode 100644
index d38dd88..0000000
--- a/docs/type_system/buffer.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# Buffer
-
----
-
-An sequence of bytes with unknown size and a byte representation
-
-```text
-Buffer[[TYPE | UTF8 | UTF16 | UTF32] TYPE]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_interface *interface;
-} kpl_type_body_buffer;
-```
-
-# Alias
-
-```text
-String `alias Buffer[[UTF8] Void]
-
-Array[Generic.T] `alias Buffer[[TYPE] Generic.T]
-```
-
-# Operators
-
-## Symbol Access
-
-## ``get`
-
-## ``set`
-
-## ``length`
-
-## ``push`
-
-## ``pop`
-
-## ``reverse`
-
-## ``join`
-
-## ``split`
-
-## ``array`
-
-```text
-array : SIZE `array ([U64.index] index)
-```
-
-## ``map`
-
-## ``each`
-
-In place map
-
-## ``filter`
-
-## ``reduce`
-
-## Concatenate `,`
-
-# Iterating
-
-# Mutating
-
-# Strings
-
-```text
-s : "asdf"
-`log s String $ "asdf"
-```
diff --git a/docs/type_system/const.md b/docs/type_system/const.md
deleted file mode 100644
index 3966009..0000000
--- a/docs/type_system/const.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Const
-
----
-
-Cannot be changed or mutated
-
-```text
-%const
-```
diff --git a/docs/type_system/empty.md b/docs/type_system/empty.md
deleted file mode 100644
index 9466493..0000000
--- a/docs/type_system/empty.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Empty
-
----
-
-Container type can be null
-
-```text
-%empty
-```
-
-## Use with `Result` Union
-
-```text
-make_array : ([Bool.yes]
- ? yes {
- `value Array $ (1; 2; 3)
- `null
- }
-)
-v : make_array(...) // %empty Array[I64] $ .null OR %empty Array[I64] $ (.value : (1; 2; 3))
-# v {
- .value {[x] `log x } // Array[I64] $ (1; 2; 3)
- .null { ... }
-}
-// same as above
-? v {[x] `log x } // Array[I64] $ (1; 2; 3)
-```
diff --git a/docs/type_system/error.md b/docs/type_system/error.md
deleted file mode 100644
index 7931e0e..0000000
--- a/docs/type_system/error.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Error
-
----
-
-An error for reporting, the data used to create it cannot be accessed
-
-```text
-Error[[]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_interface *interface;
-} kpl_type_body_error;
-```
-
-## Example
-
-```text
-e : Error $ "This is an error"
-```
diff --git a/docs/type_system/function.md b/docs/type_system/function.md
deleted file mode 100644
index 1099a55..0000000
--- a/docs/type_system/function.md
+++ /dev/null
@@ -1,158 +0,0 @@
-# Function
-
----
-
-```text
-STATELESS : NATIVE | NATIVE_INLINE | PROCESS | GENERATOR | REGEX_GENERATOR
-
-STATEFUL : TASK | ITERATOR | CLOSURE | BOUND | REGEX
-
-Function[[MODE | STATELESS | STATEFUL]; counters; JIT; IR; Body; Parent_Fn; RETURN_TYPE; Collection[NAME_LIST; TYPE.SYMBOL]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- int8_t process_state_id_counter, general_register_id_counter, xmm_register_id_counter, locals_counter;
- void *jit;
- kpl_type *ir, *body, *parent_function, *return_type, *var_list;
-} kpl_type_body_function;
-```
-
-# Alias
-
-```text
-Fn[Generic.T; Collection[VAR_TREE_LIST; TYPE.SYMBOL]] `alias Function[...]
-```
-
-# Inline Definition
-
-```text
-([I64.x; I64.y] x + y) // Fn[Any; I64.x; I64.y]
-([I64; I64.x; I64.y] x + y) // Fn[I64; I64.x; I64.y]
-```
-
-# Casting To Functions
-
-```text
-body : (x + y)
-add_i64 : Fn[I64; I64.x; I64.y] $ body
-add_f64 : Fn[F64.x; F64.y] $ body // return type is inferred
-```
-
-### Copy By Cast
-
-Casting a list to a function requires a copy of the list made for type checking and evaluation, use inline definitions if the list is meant to be a single function
-
-# Function Classes
-
-## Native
-
-Native C code that can be called async
-
-## Native Inline
-
-Native C code that cannot be called async, has to be inline
-
-## Task
-
-A queue-able function in a process or iterator
-
-## Process
-
-A list of tasks with state
-
-## Generator
-
-A function for creating an iterator
-
-## Regex Generator
-
-A function for creating Regular Expression matcher
-
-## Iterator
-
-A task creator with state, cannot take arguments, can be called until done
-
-## Closure
-
-A task creator with state that can take arguments
-
-## Bound
-
-A function with some arguments already set
-
-## Regex
-
-Invoked regular expression matcher
-
-# Returning
-
-## Return Type Inference
-
-If a return type is not specified it is inferred a type checking time
-
-## \`return
-
-The return operation type is Void with the `%return` qualifier
-
-```text
-%return Void
-```
-This qualifier is used when type checking branches that should return value, indicating this branch is valid
-
-## Transient Union Return Chaining
-
-# Iterating
-
-## \`yield
-
-Yielding wraps the value in the transient union `Iteration`
-
-Return `Void` to stop iteration
-
-```text
-fn : ([I64.n] @ 1 < n {[x] `yield 2 * x; n +: 1 } )
-it : fn `sync 10
-// invoking
-@ it {[v] `log v } // 2 4 6 8 10 12 14 16 18 20
-// same as above
-@ {
- # `sync it {
- .value {[v] `log v }
- .done { `break }
- }
-}
-```
-
-## Range `..`
-
-# Calling
-
-## \`async
-
-Asynchronous call
-
-```text
-task : `async fn
-value : `await task
-```
-
-## \`sync
-
-Synchronous call
-
-If the callee is a process, an inline await with async is used
-
-```text
-fn `sync args // can be turned into `await fn `async args
-```
-
-# Binding
-
-## \`bind
-
-# Type Inference
-
-The argument types of anonymous functions passed as an argument can be inferred
diff --git a/docs/type_system/generic.md b/docs/type_system/generic.md
deleted file mode 100644
index e028788..0000000
--- a/docs/type_system/generic.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# Generic
-
----
-
-```text
-Generic[[TYPE | SYMBOL] TARGET; Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *target, *var_tree, *var_list;
- kpl_identifier identifier;
-} kpl_type_body_generic;
-```
-
-# Example
-
-```text
-ints : Set[I64] $ ()
-/*
-ints -> Name[[DATA] Var[[LOCAL] Generic[[TYPE] REF_SET; Var[[GENERIC] REF_I64; T]; ints]; ints]
-REF_SET -> Name[[ALIAS] Map[Generic[[SYMBOL] T]; Void]; Set]
-REF_I64 -> Name[[Alias] Bit[[BIT64 | INT_SIGNED]]; I64]
-*/
-floats : Array[F64] $ ()
-/*
-floats -> Name[[DATA] Var[[LOCAL] Generic[[TYPE] REF_ARRAY; Var[[GENERIC] REF_F64; T]; floats]; floats]
-REF_ARRAY -> Name[[ALIAS] Buffer[[TYPE] Generic[[SYMBOL]; T]; Array]
-REF_F64 -> Name[[Alias] Bit[BIT64 | FLOAT]; F64]
-*/
-```
diff --git a/docs/type_system/group.md b/docs/type_system/group.md
deleted file mode 100644
index 48781af..0000000
--- a/docs/type_system/group.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# Group
-
----
-
-A sequence of different types accessed by index or a symbol mapped to an index
-
-```text
-Group[[TUPLE | TABLE] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *var_tree, *var_list;
-} kpl_type_body_group;
-```
-
-# Alias
-
-```text
-Tuple `definition Group[[TUPLE] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
-
-Table `definition Group[[TABLE] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
-```
-
-# Operators
-
-## Symbol Access
-
-## ``get`
-
-## ``set`
-
-```text
-Result[Void] : target `set (KEY; VALUE)
-
-items : Tuple $ (1; 2; 3)
-items `set (0; 4)
-// ^ items.0 {[i] i : 4 }
-`log items // Tuple[I64; I64; I64] $ (4; 2; 3)
-```
-
-# Destructuring
-
-# Mutating
diff --git a/docs/type_system/index.md b/docs/type_system/index.md
deleted file mode 100644
index 65c21d8..0000000
--- a/docs/type_system/index.md
+++ /dev/null
@@ -1,119 +0,0 @@
-# Types
-
-* #### [Alias](./alias.md)
-
-* #### [Unique](./unique.md)
-
----
-
-# Representation
-
-```text
-TEMPLATE[[MODIFIERS] DEFINES...;...]
-```
-
-## Modifiers
-
-A modifier is an internal setting (a bit mask or single value), cannot be set by a user
-
-Each template below has its own modifiers
-
-## Defines
-
-User specified
-
-# Templates
-
-A template is an incomplete type
-
-```text
-Template[[] Field; ...]
-```
-
-If a field in a template is not filed, one of these are required:
-
-## Any
-
-Denotes a field in a template that has not resolved
-
-A template by name only expands to all inner fields as `Any`
-
-## Generic.SYMBOL
-
-A field that is substituted with a `Generic` type
-
-## Collection[STORAGE; TYPE]
-
-A list of types with shape of TYPE, only can have one collection per type
-
-The collection is stored internally as STORAGE
-
-If using a collection the Collection[TYPE] must be the last type on the templates type list
-
-## Void
-
-Denotes that a field that does not resolve to anything
-
-## Meta Templates
-
-* #### [Var](./var.md)
-
-* #### [Generic](./generic.md)
-
-## Value Templates
-
-* #### [Select](./select.md)
-
-* #### [Bit](./bit.md)
-
-## Container Templates
-
-* #### [Group](./group.md)
-
-* #### [Buffer](./buffer.md)
-
-* #### [Map](./map.md)
-
-* #### [Queue](./queue.md)
-
-* #### [Union](./union.md)
-
-* #### [Native](./native.md)
-
-* #### [Error](./error.md)
-
-## Qualifier Templates
-
-* #### [Const](./const.md)
-
-* #### [Empty](./empty.md)
-
-* #### [Ref](./ref.md)
-
-* #### [Shared](./shared.md)
-
-## Function Templates
-
-* #### [Function](./function.md)
-
-* #### [Task](./task.md)
-
-* #### [Overload](./overload.md)
-
-## AST Templates
-
-* #### [Value](./value.md)
-
-* #### [Name](./name.md)
-
-* #### [Symbol](./symbol.md)
-
-* #### [Op](./op.md)
-
-* #### [List](./list.md)
-
-* #### [Lock](./lock.md)
-
-* #### [Namespace](./namespace.md)
-
-* #### [Ir](./ir.md)
diff --git a/docs/type_system/ir.md b/docs/type_system/ir.md
deleted file mode 100644
index 9ebfd79..0000000
--- a/docs/type_system/ir.md
+++ /dev/null
@@ -1,22 +0,0 @@
-# Ir
-
----
-
-```text
-Ir[[IR_NAME] Address[6]]
-```
-
-`IR_NAME` is a single value
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- ssize_t label;
- kpl_type *address[6];
-} kpl_type_body_ir;
-
-typedef enum : uint16_t {
-
-} kpl_ir_name;
-```
diff --git a/docs/type_system/list.md b/docs/type_system/list.md
deleted file mode 100644
index 958bcfb..0000000
--- a/docs/type_system/list.md
+++ /dev/null
@@ -1,22 +0,0 @@
-# List
-
----
-
-```text
-List[[STATEMENT | DEFINE | ACTION | LOOP | IF | MATCH | MUTATION] TARGET; DEFINED; NAMED; LIST; FUNCTION; VAR_TREE; Collection[LIST; TYPE]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *target, *defined, *named, *list, *function; *var_tree, *statement_list;
-} kpl_type_body_list;
-```
-
-## Lists As Variables
-
-```test
-list : (1; 2; 3)
-`log list // List $ (1; 2; 3)
-```
diff --git a/docs/type_system/lock.md b/docs/type_system/lock.md
deleted file mode 100644
index 151c1aa..0000000
--- a/docs/type_system/lock.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Lock
-
----
-
-```text
-Lock[[] TARGET]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *target;
-} kpl_type_body_lock;
-```
-
-Prevent access to `TARGET` until a mutation occurs
diff --git a/docs/type_system/map.md b/docs/type_system/map.md
deleted file mode 100644
index adf227d..0000000
--- a/docs/type_system/map.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# Map
-
----
-
-```text
-Map[[] KEY_TYPE; VALUE_TYPE]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *key, *value;
- kpl_interface *interface;
-} kpl_type_body_map;
-```
-
-# Alias
-
-```text
-Set[Generic.T] `alias Map[Generic.T; Void]
-```
-
-# Operators
-
-## ``get`
-
-## ``set`
-
-## ``has`
-
-## Concatenate `,`
-
-# Iterating
-
-# Mutating
diff --git a/docs/type_system/name.md b/docs/type_system/name.md
deleted file mode 100644
index eadda07..0000000
--- a/docs/type_system/name.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Name
-
----
-
-```text
-Name[[DATA | ALIAS | UNIQUE] TYPE; IDENTIFIER]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *type;
- kpl_interface identifier;
-} kpl_type_body_name;
-```
diff --git a/docs/type_system/namespace.md b/docs/type_system/namespace.md
deleted file mode 100644
index d3a43db..0000000
--- a/docs/type_system/namespace.md
+++ /dev/null
@@ -1,57 +0,0 @@
-# Namespace
-
----
-
-```text
-Namespace[[NATIVE | MODULE | MAIN] NAMESPACE_POINTER]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- union {
- kpl_namespace_native *native;
- kpl_namespace_module *module;
- } namespace;
-} kpl_type_body_namespace;
-```
-
-## Exports
-
-### \`export
-
-#### Type must be Fn[STATELESS], Overload, Const, Shared or Namespace to export
-
-#### Re-exporting
-
-## Imports
-
-### \`import
-
-```text
-namespace : `import Value[String]
-```
-
-All imports are relative to the importer
-
-### \`use
-
-```text
-namespace : `use Value[String]
-```
-
-## Namespace destructuring
-
-```text
-namespace : `use Value[String]
-namespace[scope_name.namespace_name]
-namespcae[name] // resolves to namespace[name.name]
-`use Value[String] [name]
-```
-
-## Main
-
-### \`is_main
-
-Run this function if the module is not imported
diff --git a/docs/type_system/native.md b/docs/type_system/native.md
deleted file mode 100644
index db34181..0000000
--- a/docs/type_system/native.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Native
-
----
-
-A representation of a native object
-
-```text
-Native[[] INTERFACE_TABLE_POINTER]
-```
-
-## Type Body Object Definitions
-
-```c
-typdef struct {
- kpl_interface *interface;
-} kpl_type_body_native;
-```
-
-## Alias
-
-```text
-File `alias Native[...]
-```
diff --git a/docs/type_system/op.md b/docs/type_system/op.md
deleted file mode 100644
index 868c41b..0000000
--- a/docs/type_system/op.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# Op
-
----
-
-```text
-Op[[OP_NAME] RETURN_TYPE; LEFT_TYPE; RIGHT_TYPE]
-```
-
-`OP_NAME` a single value
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *return_type, *statement_left, *statement_right;
-} kpl_type_body_op;
-
-typedef enum : uint16_t {
-
-} kpl_op_name;
-```
diff --git a/docs/type_system/overload.md b/docs/type_system/overload.md
deleted file mode 100644
index 467d898..0000000
--- a/docs/type_system/overload.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Overload
-
----
-
-List of complete functions, selected by signature
-
-```text
-Overload[[] Collection[VAR_LIST; Function[]]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *var_list;
-} kpl_type_body_overload;
-```
-
-## Example
-
-```text
-add : Overload[Fn[I64; I64.x; I64.y]; Fn[F64; F64.x; F64.y]; ...]
-
-`log add `sync (1; 2) // Valid calls first
-`log add `sync (1.1; 2.2) // Valid calls second
-`log add `sync (1; 2.2) // Invalid no signature match
-```
diff --git a/docs/type_system/queue.md b/docs/type_system/queue.md
deleted file mode 100644
index 800aa43..0000000
--- a/docs/type_system/queue.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# Queue
-
----
-
-```text
-Queue[[] TYPE]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_interface *interface;
-} kpl_type_body_queue;
-```
-
-# Operators
-
-## ``length`
-
-## ``get_head`
-
-## ``push_head`
-
-## ``pop_head`
-
-## ``get_tail`
-
-## ``push_tail`
-
-## ``pop_tail`
-
-## Concatenate `,`
-
-# Iterating
-
-# Mutating
diff --git a/docs/type_system/ref.md b/docs/type_system/ref.md
deleted file mode 100644
index 7eea6aa..0000000
--- a/docs/type_system/ref.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Ref
-
----
-
-```text
-%ref
-```
-
-A reference, cannot be assigned
diff --git a/docs/type_system/select.md b/docs/type_system/select.md
deleted file mode 100644
index 31ad83c..0000000
--- a/docs/type_system/select.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# Select
-
----
-
-A symbol associated with a type
-
-```text
-Select[[ENUM | MASK] Type; Collection[VAR_TREE_LIST; .symbol : %const Value]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *type, *var_tree, *var_list;
-} kpl_type_body_select;
-```
-
-# Alias
-
-```text
-Enum `definition Select[[ENUM]; TYPE; Collection[VAR_TREE_LIST; .symbol : %const Value]]
-
-Mask `definition Select[[MASK]; Void; Collection[VAR_TREE_LIST; .symbol]]
-```
-
-## Definition Example
-
-```text
-e : Enum[I64; .a; .b; .c]
-`log E // Select[[ENUM] I64; .a : 0; .b : 1; .c : 2]
-```
diff --git a/docs/type_system/shared.md b/docs/type_system/shared.md
deleted file mode 100644
index dcb31d5..0000000
--- a/docs/type_system/shared.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Shared
-
----
-
-Hold multiple references to the same object
-
-```text
-%shared
-```
-
-# Garbage Collection
-
-A tracing mark and sweep garbage collector is used
-
-# Mutating
-
-```text
-x : %shared Array $ (1; 2; 3)
-^ x {[y]
- y `push 4
-}
-`log x // %shared Array[I64] $ (1; 2; 3; 4)
-```
-
-# Operators
-
-## ``get`
-
-## ``set`
-
-### Example sharing data between two shared objects
-
-```text
-x : %shared 1
-y : %shared 0
-
-z : ^ x {[x] x }
-^ y {[y] y : z }
-// same as above
-y `set `get x
-```
-
-
diff --git a/docs/type_system/symbol.md b/docs/type_system/symbol.md
deleted file mode 100644
index da8faa7..0000000
--- a/docs/type_system/symbol.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Symbol
-
----
-
-```text
-Symbol[[] TYPE; TARGET; IDENTIFIER]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *type, *target;
- kpl_identifier identifier;
-} kpl_type_body_symbol;
-```
diff --git a/docs/type_system/task.md b/docs/type_system/task.md
deleted file mode 100644
index 56d232c..0000000
--- a/docs/type_system/task.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# Task
-
----
-
-A segment of code assigned to a process, task code can be recursive
-
-```text
-Task[[] TYPE]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *type;
- kpl_interface *interface;
-} kpl_type_body_task;
-```
-
-## \`await
diff --git a/docs/type_system/union.md b/docs/type_system/union.md
deleted file mode 100644
index bf9f857..0000000
--- a/docs/type_system/union.md
+++ /dev/null
@@ -1,72 +0,0 @@
-# Union
-
----
-
-```text
-Union[TAG | TRANSIENT] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *var_tree, *var_list;
-} kpl_type_body_union;
-```
-
-# Alias
-
-```text
-Tag `definition Union[[TAG] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
-
-Transient `definition Union[[TRANSIENT] Collection[VAR_TREE_LIST; TYPE.SYMBOL]]
-```
-
-## Tag Example
-
-```text
-u : Tag[I64.a; I64.b; I64.c] $ (.c : 5)
-
-# u {
- .c {[c] c ... }
- { ... } // default
-}
-```
-
-# Operators
-
-## ``take`
-
-# Transient Unions
-
-Return multiple types from a function
-
-Can only be retuned from functions and operations. The inner value must be moved out
-
-## Alias
-
-```text
-Result[Generic.T] `alias Transient[Generic.T.value; Void.null; Error.error]
-
-Iteration[Generic.T] `alias Transient[Generic.T.value; Void.null; Void.done; Error.error]
-```
-
-## Default Operation
-
-When a transient union is assigned the first type specified is moved out.
-
-If no match is used and if the type is not the first specified a result with an error is returned
-
-```text
-z : x / y // Result[...]
-z // is value if y is not zero
-```
-## Operators
-
-### \`value
-
-### \`error
-
-### \`null
-
-Can take a TYPE as a parameter
diff --git a/docs/type_system/unique.md b/docs/type_system/unique.md
deleted file mode 100644
index 30d0812..0000000
--- a/docs/type_system/unique.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# Unique
-
----
-
-A type based on a complete template or an alias that is not interchangeable with what it is based on
-
-## \`unique
-
-# Example
-
-```text
-Inches `unique U64
-
-Centimeters `unique U64
-
-i : Inches $ 1
-
-c : Centimeters $ 1
-
-i = c // Type Error
-```
diff --git a/docs/type_system/value.md b/docs/type_system/value.md
deleted file mode 100644
index 5f50794..0000000
--- a/docs/type_system/value.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Value
-
----
-
-```text
-Value[[] TYPE; KPL_CLASS]
-```
-
-## Type Body Object Definitions
-
-```c
-typedef struct {
- kpl_type *type;
- kpl_class *class;
-} kpl_type_body_value;
-```
diff --git a/docs/type_system/var.md b/docs/type_system/var.md
deleted file mode 100644
index 4d88c5b..0000000
--- a/docs/type_system/var.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Var
-
----
-
-```text
-Var[[GENERIC | ARG | LOCAL | LOOP | IF | MATCH | MUTATE] TYPE; LEFT_VAR; RIGHT_VAR; IDENTIFIER]
-```
-
-## Type Body Object Definition
-
-```c
-typedef struct {
- kpl_type *type, *tree_left, *tree_right;
- kpl_identifier identifier;
-} kpl_type_body_var;
-```
-
-## Function Vars
-
-Each var in a function belongs to a scope within that function
-
-```text
-var -> list -> function
-```
diff --git a/mkdocs.yml b/mkdocs.yml
index 515fc20..c9b6f27 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -1,71 +1,9 @@
site_name: KPL Specification
site_dir: 'public'
repo_url: https://git.kpl.dev/kpl-specification/
-repo_name: Markdown Source
+repo_name: Source
copyright: Copyright &copy; nodist
+theme: readthedocs
nav:
- - Main: 'index.md'
- - Language:
- - Syntax: 'language/index.md'
- - Operators: 'language/operators.md'
- - Ownership: 'language/ownership.md'
- - Type System:
- - Types: 'type_system/index.md'
- - Alias: 'type_system/alias.md'
- - Unique: 'type_system/unique.md'
- - Var: 'type_system/var.md'
- - Generic: 'type_system/generic.md'
- - Select: 'type_system/select.md'
- - Bit: 'type_system/bit.md'
- - Group: 'type_system/group.md'
- - Buffer: 'type_system/buffer.md'
- - Map: 'type_system/map.md'
- - Queue: 'type_system/queue.md'
- - Union: 'type_system/union.md'
- - Native: 'type_system/native.md'
- - Error: 'type_system/error.md'
- - Const: 'type_system/const.md'
- - Empty: 'type_system/empty.md'
- - Ref: 'type_system/ref.md'
- - Shared: 'type_system/shared.md'
- - Function: 'type_system/function.md'
- - Task: 'type_system/task.md'
- - Overload: 'type_system/overload.md'
- - Value: 'type_system/value.md'
- - Name: 'type_system/name.md'
- - Symbol: 'type_system/symbol.md'
- - Op: 'type_system/op.md'
- - List: 'type_system/list.md'
- - Lock: 'type_system/lock.md'
- - Namespace: 'type_system/namespace.md'
- - Ir: 'type_system/ir.md'
- - Application:
- - Runtime: 'application/index.md'
- - Interface: 'application/interface.md'
- - Thread: 'application/thread.md'
- - Mutex: 'application/mutex.md'
- - Memory: 'application/memory.md'
- - Io: 'application/io.md'
- - Shared: 'application/shared.md'
- - Identifier: 'application/identifier.md'
- - Type: 'application/type.md'
- - Group: 'application/group.md'
- - Buffer: 'application/buffer.md'
- - Map: 'application/map.md'
- - Queue: 'application/queue.md'
- - Union: 'application/union.md'
- - Native: 'application/native.md'
- - Namespace: 'application/namespace.md'
- - Error: 'application/error.md'
- - Testing: 'application/testing.md'
- - Life Cycle:
- - Register: 'lifecycle/register.md'
- - Parse: 'lifecycle/parse.md'
- - Scope: 'lifecycle/scope.md'
- - Import: 'lifecycle/import.md'
- - Check: 'lifecycle/check.md'
- - Eval: 'lifecycle/eval.md'
- - Ir: 'lifecycle/ir.md'
- - Jit: 'lifecycle/jit.md'
- - Exec: 'lifecycle/exec.md'
- - Notify: 'lifecycle/notify.md'
+ - Overview: index.md
+ - Definitions: definitions.md