-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf.pest
124 lines (92 loc) · 4.09 KB
/
conf.pest
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
WHITESPACE = _{ " " | "\t" | NEWLINE }
val = @{ "\"" ~ char+ ~ "\"" }
// value = { inner }
cha = { ASCII_ALPHANUMERIC | ANY | "." | "_" | "/" }
// string = @{ "'" ~ ("''" | (!"'" ~ ANY))* ~ "'" }
// string = @{ ("'" ~ ("''" | (!"'" ~ ANY))* ~ "'") | ("\"" ~ ("\"\"" | (!"\"" ~ ANY))* ~ "\"") }
//
//
var = { "$" ~ cha+ }
string = ${ "\"" ~ inner ~ "\"" }
inner = @{ (!("\"" | "\\") ~ ANY)* ~ (escape ~ inner)? }
// inner = @{ (!("\"" | "\\" | "\u{0000}" | "\u{001F}") ~ ANY)* ~ (escape ~ inner)? }
char = {
!("\"" | "\\") ~ ANY
| "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
| "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})
}
object = {
"{" ~ "}"
| NEWLINE* ~ o_pair ~ NEWLINE* ~ ("," ~ NEWLINE* ~ o_pair ~ NEWLINE*)* ~ NEWLINE*
| NEWLINE* ~ "{" ~ NEWLINE* ~ o_pair ~ NEWLINE* ~ ("," ~ NEWLINE* ~ o_pair ~ NEWLINE*)* ~ NEWLINE* ~ "}"
}
key = @{ identifier | string | literal }
value = _{
inline_table
| array
| multi_line_string
| string
| multi_line_literal
| literal
| date_time
| local_date_time
| full_date
| partial_time
| float
| integer
| boolean
}
config = {"config" ~ "{" ~ object ~ "}"}
identifier = { (ASCII_ALPHANUMERIC | "_" | "-")+ }
literal = @{ "'" ~ (!"'" ~ ANY)* ~ "'" }
multi_line_literal = @{ "'''" ~ (!"'''" ~ ANY)* ~ "'''" }
inline_table = { "{" ~ pair ~ ("," ~ pair)* ~ ","? ~ "}" | "{" ~ "}" }
multi_line_string = @{ "\"\"\"" ~ inner ~ "\"\"\"" }
escape = @{ "\\" ~ ("b" | "t" | "n" | "f" | "r" | "\"" | "\\" | unicode | NEWLINE)? }
unicode = @{ "u" ~ ASCII_HEX_DIGIT{4} | "U" ~ ASCII_HEX_DIGIT{8} }
pair = { key ~ "=" ~ string }
engine = { "engine" ~ "=" ~ string }
o_pair = { key ~ ":" ~ string }
array = {
"[" ~ "]"
| "[" ~ string ~ ("," ~ string)* ~ "]"
}
boolean = { "true" | "false" }
COMMENT = _{ "#" ~ (!NEWLINE ~ ANY)* }
table = { "[" ~ key ~ ("." ~ key)* ~ "]" ~ pair* }
array_table = { "[[" ~ key ~ ("." ~ key)* ~ "]]" ~ pair* }
name = { "name" ~ "=" ~ string }
param = { "param" ~ "{" ~ (NEWLINE)* ~ (NEWLINE* ~ (path) ~ NEWLINE* | (NEWLINE* ~ object ~ NEWLINE*)) ~ "}" ~ NEWLINE* }
path = { "path" ~ "=" ~ string }
cmd = { ("cmd" ~ "=" ~ string) }
arg = { "arg" ~ "=" ~ array }
import = { (NEWLINE)* ~ "import " ~ key ~ (NEWLINE)* }
wallpaper = { ("wallpaper" ~ "{" ~ (NEWLINE)* ~ engine? ~ (path | array) ~ engine? ~ (NEWLINE)* ~ "}") }
out = { "output" ~ "=" ~ val }
script = { "script" ~ "{" ~ (NEWLINE)* ~ (path ~ (NEWLINE)* | param ~ (NEWLINE)* | arg ~ (NEWLINE)*)+ ~ (NEWLINE)* ~ "}" }
exec = { "exec" ~ "{" ~ (NEWLINE)* ~ (path ~ (NEWLINE)* | cmd ~ (NEWLINE)* | param ~ (NEWLINE)* | arg ~ (NEWLINE)*)+ ~ (NEWLINE)* ~ "}" }
template = { "template" ~ "{" ~ (NEWLINE)* ~ (path ~ (NEWLINE)* | param ~ (NEWLINE)* | out ~ (NEWLINE)* | arg ~ (NEWLINE)* | color ~ NEWLINE*)+ ~ (NEWLINE)* ~ "}" }
color = { "color" ~ "{" ~ (NEWLINE)* ~ (object | path) ~ (NEWLINE)* ~ "}" ~ (NEWLINE)* }
profile = { "profile" ~ "{" ~ (NEWLINE)* ~ (name) ~ NEWLINE* ~ (script ~ NEWLINE* | wallpaper ~ (NEWLINE)* | color ~ NEWLINE* | exec ~ NEWLINE* | template ~ NEWLINE* | variable ~ NEWLINE*)+ ~ (NEWLINE)* ~ "}" }
date_time = ${ full_date ~ "T" ~ full_time }
local_date_time = ${ full_date ~ "T" ~ partial_time }
partial_time = ${ time_hour ~ ":" ~ time_minute ~ ":" ~ time_second ~ time_secfrac? }
full_date = ${ date_fullyear ~ "-" ~ date_month ~ "-" ~ date_mday }
full_time = ${ partial_time ~ time_offset }
date_fullyear = @{ ASCII_DIGIT{4} }
date_month = @{ ASCII_DIGIT{2} }
date_mday = @{ ASCII_DIGIT{2} }
time_hour = @{ ASCII_DIGIT{2} }
time_minute = @{ ASCII_DIGIT{2} }
time_second = @{ ASCII_DIGIT{2} }
time_secfrac = @{ "." ~ ASCII_DIGIT+ }
time_offset = ${ "Z" | ("+" | "-") ~ time_hour ~ ":" ~ time_minute }
integer = @{ ("+" | "-")? ~ int }
float = @{ ("+" | "-")? ~ int ~ ("." ~ digits ~ exp? | exp)? }
int = @{ "0" | (ASCII_NONZERO_DIGIT ~ digits?) }
digits = @{ (ASCII_DIGIT | ("_" ~ ASCII_DIGIT))+ }
exp = @{ ("E" | "e") ~ ("+" | "-")? ~ int }
variable = { ("$" ~ key ~ "=" ~ string) }
file = {
SOI ~ (NEWLINE)* ~ (import | variable | profile)* ~ (NEWLINE)* ~ EOI
}