nar/syntax/surf/mod.rs
1pub use self::{ast::*, parse::*};
2
3/// Surface syntax tree.
4mod ast;
5/// Parser, based on pest.
6mod parse;
7
8/// Parse a string into an optional declaration list and print error to stderr.
9#[inline]
10pub fn parse_str_err_printed(code: &str) -> Option<Vec<ExprDecl>> {
11 parse_str(code).map_err(|err| eprintln!("{}", err)).ok()
12}
13
14/// Parse a string into an optional standalone expression
15/// and print error to stderr.
16#[inline]
17pub fn parse_expr_err_printed(code: &str) -> Option<Expr> {
18 parse_str_expr(code)
19 .map_err(|err| eprintln!("{}", err))
20 .ok()
21}
22
23#[cfg(test)]
24mod tests;