conlang: RIP THE EXPRKIND BANDAGE OFF

cl-ast: No more bare ExprKind: every Expr has a Span
cl-interpret: Give errors a span
cl-repl: Print eval errors in load_file, instead of returning them. These changes are relevant.
This commit is contained in:
2025-03-11 00:36:42 -05:00
parent c0ad544486
commit 7e311cb0ef
14 changed files with 213 additions and 163 deletions

View File

@@ -1,7 +1,7 @@
//! Values in the dynamically typed AST interpreter.
//!
//! The most permanent fix is a temporary one.
use cl_ast::{format::FmtAdapter, ExprKind, Sym};
use cl_ast::{format::FmtAdapter, Expr, Sym};
use super::{
builtin::Builtin,
@@ -42,7 +42,7 @@ pub enum ConValue {
/// An entire namespace
Module(Box<HashMap<Sym, Option<ConValue>>>),
/// A quoted expression
Quote(Box<ExprKind>),
Quote(Box<Expr>),
/// A callable thing
Function(Rc<Function>),
/// A built-in function
@@ -152,9 +152,9 @@ from! {
char => ConValue::Char,
Sym => ConValue::String,
&str => ConValue::String,
Expr => ConValue::Quote,
String => ConValue::String,
Rc<str> => ConValue::String,
ExprKind => ConValue::Quote,
Function => ConValue::Function,
Vec<ConValue> => ConValue::Tuple,
&'static Builtin => ConValue::Builtin,
@@ -262,7 +262,7 @@ impl std::fmt::Display for ConValue {
ConValue::Bool(v) => v.fmt(f),
ConValue::Char(v) => v.fmt(f),
ConValue::String(v) => v.fmt(f),
ConValue::Ref(v) => write!(f, "&{v}"),
ConValue::Ref(v) => write!(f, "&{}", v.borrow()),
ConValue::Array(array) => {
'['.fmt(f)?;
for (idx, element) in array.iter().enumerate() {