token-parser
Parse texts into Rust data structures via a small intermediate format of nested lists and symbols (Unit).
token-parser is a backend for parsers: instead of writing a full parser for each format, you tokenize once into Units, and any type implementing Parsable can be extracted. Implementations are provided for primitives, String, Box<str>, PathBuf, Vec<T>, Box<T>, Rc<T>, Arc<T>, and (via the derive feature) for your own structs.
Example
use ;
let units = ;
let mut parser = new;
let value: String = parser.parse_next.unwrap;
assert_eq!;
For lists:
let words = ;
let mut parser = new;
let value: = parser.parse_next.unwrap;
assert_eq!;
Features
derive— enables#[derive(Parsable)]and#[derive(SymbolParsable)]for tuple, named, and unit structs (re-exported fromtoken-parser-derive).radix-parsing— number parsing with configurable radix via theContexttrait.
Errors
Error carries an ErrorKind (NotEnoughElements, TooManyElements, ListNotAllowed, SymbolNotAllowed, StringParsing, UnknownField, InvalidElement), an optional Span, and optional context describing what was being parsed. ErrorKind is #[non_exhaustive].
License
MIT OR Apache-2.0