lines = { SOI ~ (line ~ NEWLINE)* ~ (line ~ NEWLINE?)? ~ EOI }
line = ${ (block | variable | text)* }
text = ${ (!(NEWLINE | "$" | "[" | "]" | "(" | ")") ~ ANY)+ }
block = ${ "[" ~ line ~ "]" ~ style? }
style = { "(" ~ bang? ~ WHITESPACE* ~ (style_options ~ WHITESPACE* ~ "," ~ WHITESPACE*)* ~ (style_options ~ WHITESPACE* ~ ","? ~ WHITESPACE*)? ~ ")" }
style_options = _{ (style_named | style_color) }
style_color = { bg? ~ (term_color | number_color | hex_color) }
term_color = { ASCII_ALPHA+ }
number_color = { ASCII_DIGIT{1, 2} }
hex_color = @{ "#" ~ ASCII_HEX_DIGIT{6} }
bg = { "^" }
bang = { "!" }
variable = _{ "$" ~ (variable_braced | variable_names) }
variable_braced = _{ "{" ~ variable_names ~ "}" }
variable_names = _{
(var_pending | var_done | var_subject | var_priority | var_create_date | var_finish_date | var_finished | var_treshold_date | var_due_date | var_contexts | var_projects | var_hashtags | var_any)
}
style_named = _{ style_specific_priority | style_priority | style_custom_category | style_projects | style_contexts | style_hashtags | style_category | style_skip_projects | style_skip_contexts | style_skip_hashtags }
style_specific_priority = { ^"priority:" ~ ASCII_ALPHA }
style_priority = { ^"priority" }
style_custom_category = { ^"custom_category" }
style_projects = { ^"projects" }
style_contexts = { ^"contexts" }
style_hashtags = { ^"hashtags" }
style_category = { ^"category" }
style_skip_projects = { ^"skip_projects" }
style_skip_contexts = { ^"skip_contexts" }
style_skip_hashtags = { ^"skip_hashtags" }
var_pending = { ^"Pending" }
var_done = { ^"Done" }
var_subject = { ^"Subject" }
var_priority = { ^"Priority" }
var_create_date = { ^"CreateDate" | ^"create_date" }
var_finish_date = { ^"FinishDate" }
var_finished = { ^"Finished" }
var_treshold_date = { ^"TresholdDate" }
var_due_date = { ^"DueDate" }
var_contexts = { ^"Contexts" }
var_projects = { ^"Projects" }
var_hashtags = { ^"Hashtags" }
var_any = { (!(WHITESPACE | "{" | "}" | "]") ~ ANY)+ }
WHITESPACE = _{ " " | "\t" }
NEWLINE = _{ "\r\n" | "\n" }