Merge compiler and emulator progress from last few months into main. #11

Merged
zxq5 merged 55 commits from compiler into main 2026-02-14 11:54:15 +00:00
4 changed files with 30 additions and 60 deletions
Showing only changes of commit e69514e46e - Show all commits
+25
View File
@@ -0,0 +1,25 @@
use super::Syntax;
use std::collections::BTreeSet;
impl Syntax {
pub fn dsc() -> Self {
Syntax {
language: "Damn Simple Code",
case_sensitive: false,
comment: "//",
comment_multiline: ["/*", "*/"],
hyperlinks: BTreeSet::from(["http"]),
keywords: BTreeSet::from([
"include", "fn", "let", "const", "static", "if", "else", "while", "for",
"break", "continue", "loop", "return",
]),
types: BTreeSet::from([
"u32", "u16", "u8", "i32", "i16", "i8", "str", "char", "bool", "void",
]),
special: BTreeSet::from([
",", ";", ".", ":", "=", "+", "-", "*", "/", "%", "&", "|", "^", "~",
"!", "?", "<", ">", "<<", ">>", "==", "!=", "<=", ">=", "&&", "||",
]),
}
}
}
+1
View File
@@ -1,5 +1,6 @@
#![allow(dead_code)]
pub mod dsa;
pub mod dsc;
use std::collections::BTreeSet;
use std::hash::{Hash, Hasher};
+4 -7
View File
@@ -393,8 +393,9 @@ impl Editor {
fn render_editor(&mut self, _state: &mut State, ui: &mut Ui, _ctx: &Context) {
let available_width = ui.available_width();
let syntax = match self.extension() {
"dsa" => Some(Syntax::new("dsa")),
_ => None,
"dsa" => Syntax::dsa(),
"dsc" => Syntax::dsc(),
_ => Syntax::default(),
};
let ed = CodeEditor::default()
@@ -402,16 +403,12 @@ impl Editor {
.with_fontsize(12.0)
.with_rows(0)
.with_theme(ColorTheme::default())
.with_syntax(Syntax::dsa())
.with_syntax(syntax)
.with_numlines(true)
.desired_width(available_width - 500.0);
let mut editor = ed.clone();
if let Some(syntax) = syntax {
editor = ed.with_syntax(syntax);
}
editor.show(ui, &mut self.text);
}
-53
View File
@@ -1,53 +0,0 @@
use std::{
sync::{Arc, Mutex},
thread,
};
use dsa_rs::emulator::{
system::{emulator::run_emulator, memory::MainStore, processor::Processor},
ui::{
control_unit::ControlPanel, interface::EmulatorUI, memory_inspector::MemoryInspector,
stack_inspector::StackInspector,
},
};
fn main() -> Result<(), eframe::Error> {
// Initialize Channels
let (cmd_sender, cmd_receiver) = std::sync::mpsc::channel();
let (state_sender, state_receiver) = std::sync::mpsc::channel();
let mainstore = MainStore::new();
let processor = Processor::new(Box::new(mainstore), vec![]);
thread::spawn(move || {
run_emulator(&cmd_receiver, &state_sender, processor);
});
// Create UI
let mut ui = EmulatorUI::new(cmd_sender.clone(), state_receiver);
// Create UI modules
let control_unit = ControlPanel::new(cmd_sender.clone());
ui.add_component(Box::new(control_unit));
let mem_inspector = MemoryInspector::new(cmd_sender.clone());
ui.add_component(Box::new(mem_inspector));
let stack_inspector = StackInspector::new();
ui.add_component(Box::new(stack_inspector));
// Run UI
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([800.0, 600.0]),
..Default::default()
};
eframe::run_native(
"DSA Simulator (Damn Simple Architecture 🔥)",
options,
Box::new(move |cc| {
cc.egui_ctx.set_visuals(egui::Visuals::default());
Ok(Box::new(ui))
}),
)
}