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
Classicmode areStrings of ASCII alphabetic characters Classicmode ignores whitespaces where unambiguousDeBruijnmode ignores all whitespaces (since indices > 15 are very unlikely)- the indices in the
DeBruijnnotation mode start with 1 and are hexadecimal digits
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()));