From bd13458eabe5d419f9c1c1f0bf48295f82bcb3a0 Mon Sep 17 00:00:00 2001 From: RushLana Date: Fri, 16 May 2025 21:07:07 +0200 Subject: [PATCH] Redifine specs --- README.md | 60 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index abf9cd6..8d9c38e 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,50 @@ -# q-lang +# Q-LANG Idea by [@thea@eldritch.cafe](https://eldritch.cafe/@thea). You can code only using the letter `q`. -`q-pilator` (WIP) is the interpreter/compiler - ## Project structure -The project is entirely made of `q` directories and files, each `q` file contain a number of `q` that determine instructions. -instruction are executed in order `q -> qq -> ..` +- `q-pilator` (WIP) is the interpreter/compiler +- `q-pidon` (WIP) is the code generator -## Glossary +## Language spec -| symbol | interpretation | -| ------ | -------------- | -| `q` | read registry | -| `qq` | declare registry | -| `qqq` | call function | -| `qqqq` | declare function | -| `qqqqq` | operator | +Q-lang is a single threaded language, code is written on using `q-dir` and `q-file` sequentially (`q -> qq -> qqq`). -### Type declaration +A `q-dir` contain at least a `q-file` named `q` and can contain an arbitrairy number of `q-dir` and `q-file` -when encountering thoose symbol `qpilator` will check a directory with the same name + `q` to find the value +A `q-file`can contain either an data or instruction. -| symbol | interpretation | range | method | -| ------- | -------------- | ----- | ---- | -| `q` | bool | true - false | single file -| `qq` | uint | 0 .. 255 | single file -| `qqq` | int | -127 .. 128 | single file -| `qqqq` | string | [a-zA-Z] | one file per char* | +Instruction is always implied. -*qqqq -string : `empty = a, ..., 25q = z, 26q = A, ..., 51q = Z` \ No newline at end of file +### Glossary + +- $f$ is a file +- $dir$ a directory +- $...$ meaning repeating + +A scope refference the curent execution calling a function make the scope local to this function meaning once the call end memory is cleared. + +#### Instruction + +| number of $q$ | INSTRUCT | ARGs | Structure | Details +| --- | --- | --- | --- | --- | +| 0 | STDOUT | DATA | +| 1 | WRITE VAR | name - scope - DATA | $f,f,dir$ +| 2 | READ VAR | name | $f$ | +| 3 | FUNCTION | name | $dir$ | function are always using the smalest scope possible +| 4 | CALL | name - DATA | $f, dir$ | + +#### DATA + +Data type are always prefixed by a `q-file` containing type info (number of $q$). + +| number of $q$ | Type | Structure | Details +| --- | --- | --- | --- | +| 0 | boolean | $f$ | bool +| 1 | unsigned int | $f$ | u32 +| 2 | signed int | $f,f$ | i16 +| 3 | char | $f$ | [ASCII](https://www.ascii-code.com/) +| 4 | array | $dir \rightarrow (f,data...)$ | u16 +| 5 | exec | $dir \rightarrow$ `INSTRUCTs` | `exec` return the data contain in the first cell of the local registry | \ No newline at end of file