-
Notifications
You must be signed in to change notification settings - Fork 2
/
bml.pest
33 lines (24 loc) · 1.04 KB
/
bml.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
// Language: BML v1.0
// Revision: 0.04
// Features: stack-based-indent, tabular-attributes, tabular-colon-data
// Maintainer: Rouven Spreckels <[email protected]>
// License: ISC
root = _{ SOI ~ (node | tail)* ~ EOI }
node = { PUSH(indent*) ~ name ~ data? ~ attr* ~ tail
~ (line | tail)*
~ (elem | tail)* ~ DROP }
line = _{ PEEK_ALL ~ PUSH(indent+) ~ (&":" ~ data ~ NEWLINE) ~ DROP }
elem = _{ PEEK_ALL ~ PUSH(indent+) ~ node ~ DROP }
attr = { indent+ ~ name ~ data? }
name = { (ASCII_ALPHANUMERIC | '-'..'.')+ }
data = { quote_data | space_data | colon_data }
quote_data = _{ "=\"" ~ quote_data_inner ~ "\"" }
quote_data_inner = { (!("\"" | NEWLINE) ~ ANY)* }
space_data = _{ "=" ~ space_data_inner ~ &(indent | NEWLINE) }
space_data_inner = { (!("\"" | indent | NEWLINE) ~ ANY)* }
colon_data = _{ ":" ~ indent? ~ colon_data_inner ~ &NEWLINE }
colon_data_inner = { (!NEWLINE ~ ANY)* }
tail = _{ indent* ~ (comment | NEWLINE) }
comment = _{ "//" ~ indent? ~ comment_inner ~ NEWLINE }
comment_inner = _{ (!NEWLINE ~ ANY)* }
indent = _{ " " | "\t" }