mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
115 lines
2.5 KiB
Markdown
115 lines
2.5 KiB
Markdown
# `ket`
|
|
|
|
**ket** is the configuration language of **tek**.
|
|
it's based on [edn](https://en.wikipedia.org/wiki/Clojure#Extensible_Data_Notation)
|
|
but without all the features.
|
|
|
|
## usage
|
|
|
|
### with `tengri_output`
|
|
|
|
this is a `tengri_output` view layout defined using ket:
|
|
|
|
```edn
|
|
(bsp/s (fixed/y 2 :toolbar)
|
|
(fill/x (align/c (bsp/w :pool
|
|
(bsp/s :outputs (bsp/s :inputs (bsp/s :tracks :scenes)))))))
|
|
```
|
|
|
|
### with `tengri_input`
|
|
|
|
this is a `tengri_input` keymap defined using ket:
|
|
|
|
```edn
|
|
(@u undo 1)
|
|
(@shift-u redo 1)
|
|
(@e editor show :pool-clip)
|
|
(@ctrl-a scene add)
|
|
(@ctrl-t track add)
|
|
(@tab pool toggle)
|
|
```
|
|
|
|
## tokens
|
|
|
|
ket has 4 "types", represented by variants of the `Value` enum:
|
|
|
|
* `Num` - numeric literal
|
|
* `Sym` - textual symbol
|
|
* `Key` - textual key
|
|
* `Exp` - parenthesized group of tokens
|
|
|
|
### numeric literal
|
|
|
|
numbers are passed through as is. only non-negative integers are supported.
|
|
|
|
```edn
|
|
0
|
|
123456
|
|
```
|
|
|
|
### keys
|
|
|
|
keys are the names of available operations. they look like this:
|
|
|
|
```edn
|
|
simple-key
|
|
multi-part/key
|
|
```
|
|
|
|
keys are implemented by the underlying subsystem:
|
|
|
|
* in `tengri_output`, keys are names of layout primitives
|
|
* in `tengri_input`, keys are names of commands
|
|
|
|
### symbols
|
|
|
|
symbols that start with `:` represent the names of variables
|
|
provided by the `Context` trait - such as command parameters,
|
|
or entire layout components:
|
|
|
|
```edn
|
|
:symbol-name
|
|
```
|
|
|
|
symbols that start with `@` represent keybindings.
|
|
they are parsed in `tengri_tui` and look like this:
|
|
|
|
```edn
|
|
@ctrl-alt-shift-space
|
|
```
|
|
|
|
### parenthesized groups
|
|
|
|
parenthesized groups represent things like expressions
|
|
or configuration statements, and look like this:
|
|
|
|
```edn
|
|
(some-key :symbol (some/other-key @another-symbol 123) 456)
|
|
```
|
|
|
|
## goals
|
|
|
|
* [ ] const parse
|
|
* [ ] live reload
|
|
* [ ] serialize modified code back to original indentation
|
|
|
|
## implementation notes
|
|
|
|
### `DslExp` trait behavior
|
|
|
|
this is the trait which differentiates "a thing" from
|
|
"a thing that is many things".
|
|
|
|
|source |key|exp |head |tail |
|
|
|---------------|---|-------|---------|---------------|
|
|
|`a` |`a`|e0 |`a` |None |
|
|
|`(a)` |e1 |`a` |`(a)` |None |
|
|
|`a b c` |e2 |e0 |`a` |`b c` |
|
|
|`(a b c)` |e1 |`a b c`|`(a b c)`| |
|
|
|`(a b c) d e` |e1 |e3 |`(a b c)`|`d e` |
|
|
|`a (b c d) e f`|e1 |e0 |`a` |`(b c d) e f` |
|
|
|
|
* e0: Unexpected 'a'
|
|
* e1: Unexpected '('
|
|
* e2: Unexpected 'b'
|
|
* e3: Unexpected 'd'
|