kmx.io/kv/README.md

Branch

Thomas de Grivel 832d58a31 2022-01-06T07:52:22
spec

kv 1.0

Status : development.

Synopsis

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


Source

# 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
Download