esexpr_text/
lib.rs

1//! `ESExpr` text format parser.
2#![no_std]
3
4extern crate alloc;
5extern crate core;
6
7use alloc::vec::Vec;
8
9use esexpr::ESExpr;
10
11/// Underlying nom parser.
12pub mod parser;
13
14/// Parse a string into an `ESExpr`.
15///
16/// # Errors
17/// Returns `Err` when parsing fails.
18pub fn parse<'input>(s: &'input str) -> Result<ESExpr<'static>, nom::Err<nom::error::Error<&'input str>>> {
19	let (_, expr) = parser::expr_file(s)?;
20	Ok(expr)
21}
22
23/// Parse a string into multiple `ESExpr`s.
24///
25/// # Errors
26/// Returns `Err` when parsing fails.
27pub fn parse_multi<'input>(s: &'input str) -> Result<Vec<ESExpr<'static>>, nom::Err<nom::error::Error<&'input str>>> {
28	let (_, expr) = parser::multi_expr_file(s)?;
29	Ok(expr)
30}