Branch
Hash :
832d58a3
Author :
Thomas de Grivel
Date :
2022-01-06T07:52:22
spec
Status : development.
KV : SP* K SP* ':' SP* V SP*
M1 : KV (',' KV)* ','? SP*
M2 : SP* '{' M1 '}' SP*
M3 : SP*
M : M2 | M1 | M3
K1 = V1 : ([^<{}:,"\s][^{}:,"\s]*)
K2 = V2 : '"' (Q | [^"\\\s])* '"'
Q : '\"' | '\\' | '\n' | '\r' | '\t' | '\v' | '\0'
K3 = V3 : '"""' \n (.*?) '"""'
K4 = V4 : '<<' D \s (.*?) D
V5 : M2
K : K1 | K2 | K3 | K4
V : V1 | V2 | V3 | V4 | V5
The parser will emit events for KV.
kv --get FILE [...] <<EOF
A, B.B1, C."C1".C2
EOF
Will output concatenated values of files for keys A, B.B1 and C.C1.C2. Keys must be quoted according to K1 or K2.
kv --quote FILE [...]
Will quote files according to (K1 | K2 | K3 | K4) whichever is best.
kv --unquote FILE [...]
Will unquote files according to (K1 | K2 | K3 | K4).
The reference implementation of kv is implemented in ANSI C.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
# kv 1.0
Status : development.
## Synopsis
![kv-1.0.jpg](https://git.kmx.io/kmx.io/kv/_blob/master/doc/kv-1.0.jpg)
## Specification
```
KV : SP* K SP* ':' SP* V SP*
M1 : KV (',' KV)* ','? SP*
M2 : SP* '{' M1 '}' SP*
M3 : SP*
M : M2 | M1 | M3
K1 = V1 : ([^<{}:,"\s][^{}:,"\s]*)
K2 = V2 : '"' (Q | [^"\\\s])* '"'
Q : '\"' | '\\' | '\n' | '\r' | '\t' | '\v' | '\0'
K3 = V3 : '"""' \n (.*?) '"""'
K4 = V4 : '<<' D \s (.*?) D
V5 : M2
K : K1 | K2 | K3 | K4
V : V1 | V2 | V3 | V4 | V5
```
## Parser
The parser will emit events for KV.
## Command line interface
### Usage
```
kv --get FILE [...] <<EOF
A, B.B1, C."C1".C2
EOF
```
Will output concatenated values of files for keys A, B.B1 and C.C1.C2.
Keys must be quoted according to K1 or K2.
```
kv --quote FILE [...]
```
Will quote files according to (K1 | K2 | K3 | K4) whichever is best.
```
kv --unquote FILE [...]
```
Will unquote files according to (K1 | K2 | K3 | K4).
## Reference implementation
The reference implementation of kv is implemented in ANSI C.
## Other implementations
### TODO
- Common Lisp
- Elixir
- Go
- Python
- Ruby
- Rust
- Java
- Javascript