50 lines
No EOL
1.6 KiB
Markdown
50 lines
No EOL
1.6 KiB
Markdown
# Q-LANG
|
|
|
|
Idea by [@thea@eldritch.cafe](https://eldritch.cafe/@thea).
|
|
You can code only using the letter `q`.
|
|
|
|
## Project structure
|
|
|
|
- `q-pilator` (WIP) is the interpreter/compiler
|
|
- `q-pidon` (WIP) is the code generator
|
|
|
|
## Language spec
|
|
|
|
Q-lang is a single threaded language, code is written on using `q-dir` and `q-file` sequentially (`q -> qq -> qqq`).
|
|
|
|
A `q-dir` contain at least a `q-file` named `q` and can contain an arbitrairy number of `q-dir` and `q-file`
|
|
|
|
A `q-file`can contain either an data or instruction.
|
|
|
|
Instruction is always implied.
|
|
|
|
### 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 | |