raw_literal = { (!needs_escape ~ ANY)+ }
needs_escape = { "$" | "%" | "\\" | "{" | "}" }
escape_sequence = _{ "\\" ~ needs_escape }
literal = { (raw_literal | escape_sequence)+ }
identifier = {ASCII_ALPHANUMERIC+}
variable = {"$" ~ (identifier | "{" ~ identifier ~ "}")}
base_color = _{ ^"black" | ^"white" | ^"red" | ^"green" | ^"yellow" | ^"blue" | ^"magenta" | ^"cyan" }
color = { "light_"? ~ base_color }
fg_color = { color }
bg_color = { "bg_" ~ color }
modifier = { ^"bold" | ^"underline" }
attribute = _{ fg_color | bg_color | modifier }
separator = _{ "," ~ " "* }
style = { " "* ~ attribute ~ (separator ~ attribute)* ~ " "* }
styled = { "%[" ~ style ~ "]{" ~ format_string ~ "}" }
format_string = _{ (literal | variable | styled)+ }
format_string_entire = _{ SOI ~ format_string ~ EOI }