14 unstable releases (3 breaking)
0.4.0 | Apr 26, 2024 |
---|---|
0.3.9 | Apr 24, 2024 |
0.2.1 | Apr 18, 2024 |
0.1.0 | Apr 16, 2024 |
#564 in Encoding
693 downloads per month
42KB
1K
SLoC
SYML is a configuration language similar to YAML, but may be more user-friendly
Syntax (Imprecise)
- _ (white space):
\t
- hex:
[0-9A-Fa-f] - nl:
\r
?\n
/ eof - comment:
;
(!nl any-char)* - cnl:
(_ comment?\r
?\n
)+
/ eof - escape:
\
( [\\nrt"' \t]
/x
hex{2}
/u
(hex{4} /{
hex+}
)
/U
hex{8}
) - str_ignore:
\
comment?\r
?\n
_ - simple-val:
([!#$%&()*+./0-9<=>?@A-Z\\^_`a-z|~\p{XID_Start}] /-
!
[!#$%&()*+./0-9<=>?@A-Z\\^_`a-z|~\-'\p{XID_Continue}]*
/'
[^'\r\n]*'
/"
str_ignore* ((escape / [^\r\n\\]) str_ignore*)*"
- inline-value:
[
_ (simple-val (_,
_ simple-val)* _,
?)? _]
/{
_ (simple-val _:
_ inline-value (_,
simple-val _:
_ inline-value)* _,
?)? _}
/ simple-val - list:
-
ivalue\n
(cnl indent(+2)-
ivalue(+2))* - ivalue:
list
/ simple-val _:
(_ simple-val _:
)* (
cnl() (indent list(+0) / indent(+2) ivalue(+2))
/ inline-value
)
/ inline-value - value:
cnl()? ivalue(0) cnl()
Examples
- name: jack
age: 18
- name: jones
age: 21
ids:
- - 1
- 2
- [3, 4] ; inline
like JSON5:
[
{
name: "jack",
age: "18",
},
{
name: "jones",
age: "21",
ids: [
[1, 2],
[3, 4],
]
}
]
How To Use
use cli utils:
cargo install syml --features cli-utils
use lib:
let _value = syml::parser::value(r#"
; comment
- {a: 1, b: 2}
- [3, 4]
- 5
- x: 2
y: 3
"#).unwrap();
Dependencies
~95–375KB