summaryrefslogtreecommitdiff
path: root/rust/src/parser.rs
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud.bailly@iohk.io>2024-09-24 13:41:48 +0200
committerArnaud Bailly <arnaud.bailly@iohk.io>2024-09-24 13:41:48 +0200
commitc0a531b387b7b65279265f114e469341a4bbd9d2 (patch)
treea2cc10637a9bd3b465e30c148448c6c8a80ae12a /rust/src/parser.rs
parent95d2e9f7ae5a1e813b015d64821e774969a6ac51 (diff)
downloadlambda-nantes-c0a531b387b7b65279265f114e469341a4bbd9d2.tar.gz
Tokenize λ
Diffstat (limited to 'rust/src/parser.rs')
-rw-r--r--rust/src/parser.rs11
1 files changed, 10 insertions, 1 deletions
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<Token> {
fn terminate(result: &mut Vec<Token>, 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();
}
}
@@ -154,6 +158,11 @@ mod tests {
}
#[test]
+ fn tokenize_lambda_symbol() {
+ assert_eq!(vec![Lambda, LParen,], tokenize("lam ("));
+ }
+
+ #[test]
fn parse_application_of_two_values() {
assert_eq!(
App(Box::new(Sym("foo".to_string())), Box::new(Num(42))),