panmath/parsers/
mod.rs

1//! Common interface for parsers that can create abstract syntax trees.
2
3use crate::ast::AST;
4pub mod ascii;
5pub mod token;
6
7pub use ascii::AsciiParser;
8
9/// Code that can parse ASTs from a given input type.
10pub trait ASTParser<I> {
11    /// The error that parsing can raise.
12    type ParseError;
13
14    /// Attempts to parse the given input, returning an AST on success.
15    fn parse(&self, input: &I) -> Result<AST, Self::ParseError>;
16}