Function lambda_calculus::parser::parse
[−]
[src]
pub fn parse(input: &str, notation: Notation) -> Result<Term, Error>
Parses the input &str
as a lambda Term
.
- lambdas can be represented either with the greek letter (λ) or a backslash (\ - less aesthetic, but only one byte in size)
- the identifiers in
Classic
mode areString
s of ASCII alphabetic characters Classic
mode ignores whitespaces where unambiguous- the indices in the
DeBruijn
notation mode start with 1 and are hexadecimal digits DeBruijn
mode ignores all whitespaces (since indices > 15 are very unlikely)
Example
use lambda_calculus::parser::*; use lambda_calculus::combinators::{s, y}; assert_eq!(parse(&"λf.(λx.f (x x)) (λx.f (x x))", Classic), Ok(y())); assert_eq!(parse(&"λf.(λx.f(x x))(λx.f(x x))", Classic), Ok(y())); assert_eq!(parse( &"λλλ31(21)", DeBruijn), Ok(s())); assert_eq!(parse(&r#"\\\3 1 (2 1)"#, DeBruijn), Ok(s()));