From bc4f5e20800cbcd9c9be670874fd892fbc8527d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jasper=20Gr=C3=A4flich?= <graeflich@uni-potsdam.de> Date: Mon, 9 Oct 2023 16:13:46 +0200 Subject: [PATCH] In-progress: Switch to proper AST --- use-based-refs/interpreter/src/lib.rs | 10 ++++++++++ use-based-refs/interpreter/src/parser.rs | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/use-based-refs/interpreter/src/lib.rs b/use-based-refs/interpreter/src/lib.rs index 18a4b44..dca1bd8 100644 --- a/use-based-refs/interpreter/src/lib.rs +++ b/use-based-refs/interpreter/src/lib.rs @@ -6,6 +6,16 @@ mod parser; pub use eval::eval; +/// A Node of the λ_UR AST, simplified from the UrParser. +// TODO: Switch to this vor eval +pub enum Node { + Num(u32), + Unit, + Seq(Vec<Node>), + Let{ident: String, expr: Box<Expr>}, + Lookup(String), +} + // TODO: Put this elsewhere? #[derive(Debug, PartialEq, Eq, Clone)] pub enum Value { diff --git a/use-based-refs/interpreter/src/parser.rs b/use-based-refs/interpreter/src/parser.rs index aa2f62f..a0422c8 100644 --- a/use-based-refs/interpreter/src/parser.rs +++ b/use-based-refs/interpreter/src/parser.rs @@ -12,3 +12,11 @@ pub fn tokenize(input: &str) -> Result<Pair<'_, Rule>, String> { Err(e) => Err(format!("{e}")), } } + + +// TODO: Fill +pub fn ast(input: &str) -> Node { + match tokenize(input).as_rule() { + + } +} -- GitLab