From c0a531b387b7b65279265f114e469341a4bbd9d2 Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Tue, 24 Sep 2024 13:41:48 +0200 Subject: Tokenize λ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/src/parser.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rust/src/parser.rs b/rust/src/parser.rs index 459219c..2c2dced 100644 --- a/rust/src/parser.rs +++ b/rust/src/parser.rs @@ -62,7 +62,11 @@ fn tokenize(arg: &str) -> Vec { fn terminate(result: &mut Vec, word: &mut String) { if !word.is_empty() { let w = word.clone(); - result.push(Token::Word(w)); + if w == "lam" { + result.push(Token::Lambda); + } else { + result.push(Token::Word(w)); + } word.clear(); } } @@ -153,6 +157,11 @@ mod tests { ); } + #[test] + fn tokenize_lambda_symbol() { + assert_eq!(vec![Lambda, LParen,], tokenize("lam (")); + } + #[test] fn parse_application_of_two_values() { assert_eq!( -- cgit v1.2.3