mul/src/parse.rs

20 lines
577 B
Rust

//! Transform text into syntax.
use lalrpop_util::{lalrpop_mod, lexer::Token, ParseError};
use crate::syntax::{InteractiveEntry, Program};
lalrpop_mod!(parser, "/parse/parser.rs");
type Result<'input, T> = std::result::Result<T, ParseError<usize, Token<'input>, &'static str>>;
/// Parse a series of items.
pub fn parse_program(input: &str) -> Result<Program> {
parser::ProgramParser::new().parse(input)
}
/// Parse a fragment of code.
pub fn parse_interactive_entry(input: &str) -> Result<InteractiveEntry> {
parser::InteractiveEntryParser::new().parse(input)
}