feat: Initialize compiler GUI project

Sets up the basic structure for the compiler GUI application using
eframe.
This includes the main application loop, a default UI layout with a
source code editor and an output log panel, and the foundational AST
(Abstract Syntax Tree) definitions for types, nodes, and an evaluation
mechanism.
This commit is contained in:
Michael Schimmel
2026-02-16 23:47:17 +01:00
commit 3fdfd01982
8 changed files with 4601 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
use std::sync::Arc;
use std::collections::HashMap;
use std::fmt;
/// Shared identity for nodes (Location, etc.)
#[derive(Debug, Clone)]
pub struct NodeIdentity {
pub line: u32,
pub col: u32,
}
pub type Identity = Arc<NodeIdentity>;
/// Interned string identifier
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Keyword(pub u32);
/// Core data value in Myc Script (similar to TDataValue)
#[derive(Clone)]
pub enum Value {
Nil,
Bool(bool),
Int(i64),
Float(f64),
Text(Arc<str>),
Keyword(Keyword),
List(Arc<Vec<Value>>),
Record(Arc<HashMap<Keyword, Value>>),
Function(Arc<dyn Fn(Vec<Value>) -> Value + Send + Sync>),
}
impl Value {
pub fn is_truthy(&self) -> bool {
match self {
Value::Nil => false,
Value::Bool(b) => *b,
_ => true,
}
}
}
impl fmt::Display for Value {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Value::Nil => write!(f, "nil"),
Value::Bool(b) => write!(f, "{}", b),
Value::Int(i) => write!(f, "{}", i),
Value::Float(fl) => write!(f, "{}", fl),
Value::Text(t) => write!(f, "\"{}\"", t),
Value::Keyword(k) => write!(f, ":kw#{}", k.0),
Value::List(l) => write!(f, "<list[{}]>", l.len()),
Value::Record(r) => write!(f, "<record[{}]>", r.len()),
Value::Function(_) => write!(f, "<fn>"),
}
}
}
impl fmt::Debug for Value {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}