toml::parse
The toml::parse module provides functions used to parse a TOML document into a toml::table. You can parse a document with stream or file.
Index
Types
// Undocumented types: type expected_pos = struct { pos: lex::location, expected: human_tokens, }; type human_tokens = enum u32 { STRING = 1 << 0, COMMENT = 1 << 1, LBRACE = 1 << 2, RBRACE = 1 << 3, LBRACKET = 1 << 4, LBRACKET2 = 1 << 5, RBRACKET = 1 << 6, RBRACKET2 = 1 << 7, NEWLINE = 1 << 8, DOT = 1 << 9, EQ = 1 << 10, COMMA = 1 << 11, INTEGER = 1 << 12, FLOAT = 1 << 13, BOOLEAN = 1 << 14, DATETIME = 1 << 15, KEY = 1 << 16, EOF = 1 << 17, VALUE = 1 << 18, TABLE = 1 << 19, ARRAY_OF_TABLES = 1 << 20, ARRAY = 1 << 21, INLINE_TABLE = 1 << 22, };
Errors
type error = !(...lex::error | unexpected_eof | invalid_syntax | overwritten_value | unexpected_token); type invalid_syntax = !expected_pos; type overwritten_value = !lex::location; type unexpected_eof = !expected_pos; type unexpected_token = !struct { pos: lex::location, got: human_tokens, expected: human_tokens, };
Functions
fn file(path: str) (*toml::table | error); fn stream(in: *bufio::scanner, path: str) (*toml::table | error); fn strerror(err: error) str; fn string(in: str, path: str) (*toml::table | error);
Types
type expected_pos[link]
Show undocumented member
type expected_pos = struct { pos: lex::location, expected: human_tokens, };
type human_tokens[link]
Show undocumented member
type human_tokens = enum u32 { STRING = 1 << 0, COMMENT = 1 << 1, LBRACE = 1 << 2, RBRACE = 1 << 3, LBRACKET = 1 << 4, LBRACKET2 = 1 << 5, RBRACKET = 1 << 6, RBRACKET2 = 1 << 7, NEWLINE = 1 << 8, DOT = 1 << 9, EQ = 1 << 10, COMMA = 1 << 11, INTEGER = 1 << 12, FLOAT = 1 << 13, BOOLEAN = 1 << 14, DATETIME = 1 << 15, KEY = 1 << 16, EOF = 1 << 17, VALUE = 1 << 18, TABLE = 1 << 19, ARRAY_OF_TABLES = 1 << 20, ARRAY = 1 << 21, INLINE_TABLE = 1 << 22, };
Errors
type error[link]
type error = !(...lex::error | unexpected_eof | invalid_syntax | overwritten_value | unexpected_token);
An error encountered while parsing the TOML document.
type invalid_syntax[link]
type invalid_syntax = !expected_pos;
Invalid syntax somewhere around the contained location.
type overwritten_value[link]
type overwritten_value = !lex::location;
The expression at the stored location would've caused a value to be overwritten.
type unexpected_eof[link]
type unexpected_eof = !expected_pos;
The lexer encountered the end of the document before it expected to.
type unexpected_token[link]
type unexpected_token = !struct { pos: lex::location, got: human_tokens, expected: human_tokens, };
An unexpected token was encountered.
Functions
fn file[link]
fn file(path: str) (*toml::table | error);
Opens the file at the given path and parses it. See also stream.
fn stream[link]
fn stream(in: *bufio::scanner, path: str) (*toml::table | error);
Parses a TOML document. The path is borrowed and used for error messages. The read-only root table of the parsed document is returned.
fn strerror[link]
fn strerror(err: error) str;
Converts an error into a user-friendly string. The result may be statically allocated.
fn string[link]
fn string(in: str, path: str) (*toml::table | error);
Parses the string. See also stream.