ini = { SOI ~ bom? ~ (blank | pair | comment)* ~ section* } // lines blank = _{ "" ~ NEWLINE } pair = { key ~ "=" ~ value ~ eol } comment = ${ indicator ~ comment_value ~ eol } comment_value = ${ char* } // sections section = { header ~ eol ~ body } body = { (blank | pair | comment)* } // tokens // a name must end with a closing bracket followed by optional whitespace and EOL header = ${ "[" ~ header_text ~ "]" } header_text = @{ (!header_end ~ char)+ } header_end = !{ "]" ~ eol } // a key may not begin with an opening bracket and may not contain an equal sign key = @{ (!("=" | "[") ~ char) ~ (!key_end ~ char)* } key_end = @{ (WHITESPACE* ~ "=") } // Trim key's trailing whitespace value = @{ (!value_end ~ char)* } value_end = @{ WHITESPACE+ ~ eol } // Trim value's trailing whitespace // atomic primitives bom = _{ "\u{feff}" } indicator = { "#" | ";" } char = { !eol ~ ANY } eol = _{ NEWLINE | EOI } WHITESPACE = _{ " " | "\t" }