|| This crate implements a prefs file parser.
Pref files have the following grammar. Note that there are slight
differences between the grammar for a default prefs files and a user prefs
<pref-file> = <pref>*
<pref> = <pref-spec> "(" <pref-name> "," <pref-value> <pref-attrs> ")" ";"
<pref-spec> = "user_pref" | "pref" | "sticky_pref" // in default pref files
<pref-spec> = "user_pref" // in user pref files
<pref-name> = <string-literal>
<pref-value> = <string-literal> | "true" | "false" | <int-value>
<int-value> = <sign>? <int-literal>
<sign> = "+" | "-"
<int-literal> = [0-9]+ (and cannot be followed by [A-Za-z_])
A single or double-quoted string, with the following escape sequences
allowed: \", \', \\, \n, \r, \xNN, \uNNNN, where \xNN gives a raw byte
value that is copied directly into an 8-bit string value, and \uNNNN
gives a UTF-16 code unit that is converted to UTF-8 before being copied
into an 8-bit string value. \x00 and \u0000 are disallowed because they
would cause C++ code handling such strings to misbehave.
<pref-attrs> = ("," <pref-attr>)* // in default pref files
= <empty> // in user pref files
<pref-attr> = "sticky" | "locked" // default pref files only
Comments can take three forms:
- `# Python-style comments`
- `// C++ style comments`
- `/* C style comments (non-nested) */`
Non-end-of-line whitespace chars are `\t`, `\v`, `\f`, and space.
End-of-line sequences can take three forms, each of which is considered as
a single EOL:
- `\r` (without subsequent `\n`)
The valid range for `<int-value>` is -2,147,483,648..2,147,483,647. Values
outside that range will result in a parse error.
A `\0` char is interpreted as the end of the file. The use of this character
in a prefs file is not recommended. Within string literals `\x00` or
`\u0000` can be used instead.
The parser performs error recovery. On a syntax error, it will scan forward
to the next `;` token and then continue parsing. If the syntax error occurs
in the middle of a token, it will first finish obtaining the current token
in an appropriate fashion.