Create dmc bin.

This commit is contained in:
Jesse Brault 2025-01-31 19:12:30 -06:00
parent 18551af61a
commit 80c3aa9f19
5 changed files with 49 additions and 4 deletions

View File

@ -7,6 +7,10 @@ edition = "2021"
name = "dm"
path = "src/bin/dvm/main.rs"
[[bin]]
name = "dmc"
path = "src/bin/dmc/main.rs"
[dependencies]
pest = "2.7.14"
clap = { version = "4.5.23", features = ["derive"] }

View File

@ -215,7 +215,7 @@ fn build_interface(is_extern: bool, is_public: bool, interface_pair: Pair<Rule>)
}
}
fn build_implementation(is_extern: bool,is_public: bool, pair: Pair<Rule>) -> Declaration {
fn build_implementation(is_extern: bool, is_public: bool, pair: Pair<Rule>) -> Declaration {
todo!()
}

10
src/bin/dmc/ast_dump.rs Normal file
View File

@ -0,0 +1,10 @@
use std::path::PathBuf;
use deimos::ast::build_ast;
pub fn dump_ast(path: &PathBuf) {
let src = std::fs::read_to_string(path)
.expect(&format!("Could not read {:?}", path));
let ast = build_ast(&src);
println!("{:?}", ast);
}

34
src/bin/dmc/main.rs Normal file
View File

@ -0,0 +1,34 @@
mod ast_dump;
use std::path::PathBuf;
use ast_dump::dump_ast;
use clap::{Parser, Subcommand};
#[derive(Debug, Parser)]
#[command(name = "dmc")]
#[command(about = "Deimos Compiler", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand)]
enum Commands {
#[command(arg_required_else_help = true)]
AstDump {
paths: Vec<PathBuf>
}
}
fn main() {
let args = Cli::parse();
match args.command {
Commands::AstDump { paths } => {
for path in paths {
dump_ast(&path);
}
}
}
}

View File

@ -15,9 +15,6 @@ fn main() {
// - call the main fn
// fn main() { println "Hello, World!" }
let compilation_unit = build_ast("ns hello::test::bye\npub int Test<T> : Testing<T> {}");
println!("{:?}", compilation_unit);
// std/core/array lib
let mut array_lib = DmLib::new("std/core/array");