Crate eon_syntax

Crate eon_syntax 

Source
Expand description

§Eon: the human-friendly configuration format

Eon is a human-friendly configuration format that is designed to be easy to read and write.

Example Eon document:

// Comment
string: "Hello Eon!"
list: [1, 2, 3]
object: {
    boolean: true
    regex: '\d{3}-\d{3}-\d{4}'
}
map: {
    1: "map keys don't need to be strings"
    2: "they can be any Eon value"
}
special_floats: [+inf, -inf, +nan]

Read more at https://github.com/emilk/eon.

This crate provides a parser and formatter for Eon. It is used to implement the eonfmt CLI tool, but also used by the eon crate to parse and format Eon documents.

You can use it to read and write Eon documents, with comments. This can be useful for e.g. reading “docstrings” from an .eon file, or for automate the editing an .eon file while preserving comments and formatting.

Structs§

FormatOptions
How to format an Eon document.
Span
The byte range of something in the source code.
TokenKeyValue
The tokens for a key-value pair in a TokenMap.
TokenList
A list, like [ a, b, c, … ].
TokenMap
An object, like { key: value, … }.
TokenTree
A tree of tokens, representing the structure of the Eon source code, including comments.
TokenVariant
A sum-type (enum) variant

Enums§

Error
An error that can occur during parsing of an Eon file.
TokenValue
The different types of tokens (number, list, …).

Functions§

escape_and_quote
Format a string into Eon, adding quotes and escaping as needed.
is_valid_identifier
Returns true if the string does matches [a-zA-Z_][a-zA-Z0-9_]*
reformat
Parses an Eon file and re-indents and formats it in a pretty way.
unescape_and_unquote
Remove the quotes and unescape the string.

Type Aliases§

Result
A type alias for a result that uses the Error type defined above.