Skip to main content

parse

Function parse 

Source
pub fn parse(tokens: &[Token]) -> Result<Expr, Error>
Expand description

Parse a full expression from a token slice.

§Errors

Returns Error::UnexpectedToken if extra tokens trail after the expression, Error::UnexpectedEnd if input is exhausted mid-production, or other parse errors propagated from sub-productions.

§Examples

use lambda_ref_cat::lexer::lex;
use lambda_ref_cat::parser::parse;

let tokens = lex("ref (\\x. x)")?;
let expr = parse(&tokens)?;
assert_eq!(format!("{expr}"), "(ref (\\x. x))");