diff options
| author | Arnaud Bailly <arnaud.bailly@iohk.io> | 2024-09-24 16:22:31 +0200 |
|---|---|---|
| committer | Arnaud Bailly <arnaud.bailly@iohk.io> | 2024-09-24 16:22:31 +0200 |
| commit | 5e5c4f2c47ec867d698c001cfe8d097be5744a57 (patch) | |
| tree | be3ce2417f38d4498101da2c2451e625f6969c21 /rust/src/ast.rs | |
| parent | 7c69b9f571360bbbda8a9a96ea6205375e4af573 (diff) | |
| download | lambda-nantes-5e5c4f2c47ec867d698c001cfe8d097be5744a57.tar.gz | |
Parse abstractions
Got tricked with or()'s function eagerness: Even when the left hand
side succeeds, the argument was evaluated which consumed a token in
the parser which prevented proper parsing.
Diffstat (limited to 'rust/src/ast.rs')
| -rw-r--r-- | rust/src/ast.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/rust/src/ast.rs b/rust/src/ast.rs index 0493f59..722e9e0 100644 --- a/rust/src/ast.rs +++ b/rust/src/ast.rs @@ -1,11 +1,12 @@ use std::fmt::{self, Display}; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] pub enum Value { Num(i32), Bool(bool), Sym(String), App(Box<Value>, Box<Value>), + Lam(String, Box<Value>), } impl Display for Value { @@ -15,6 +16,7 @@ impl Display for Value { Value::Bool(b) => write!(f, "{}", b), Value::Sym(s) => write!(f, "{}", s), Value::App(l, r) => write!(f, "({} {})", l, r), + Value::Lam(var, body) => write!(f, "(lam {} {})", var, body), } } } |
