1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
pub use self::ast::*; pub use self::parse::parse_str; use crate::syntax::surf::parse::parse_str_expr; /// Surface syntax tree. /// /// The surface syntax tree is intended to be very close to the surface syntax so it may look a bit /// too surface (like `a|b|c` is parsed as a `[a, b, c]`-like structure instead of a /// `[a, [b, c]]`-like structure. mod ast; /// Code to surface syntax tree, based on [pest](https://pest.rs). /// /// Macro is used for code reusing. mod parse; /// Parse a string into an optional expression and print error to stderr. #[inline] pub fn parse_expr_err_printed(code: &str) -> Result<Expr, ()> { parse_str_expr(code).map_err(|err| eprintln!("{}", err)) } /// Parse a string into an optional declaration list and print error to stderr. #[inline] pub fn parse_str_err_printed(code: &str) -> Result<Vec<Decl>, ()> { parse_str(code).map_err(|err| eprintln!("{}", err)) } #[cfg(test)] mod tests;