Create dmc bin.
This commit is contained in:
parent
18551af61a
commit
80c3aa9f19
@ -7,6 +7,10 @@ edition = "2021"
|
|||||||
name = "dm"
|
name = "dm"
|
||||||
path = "src/bin/dvm/main.rs"
|
path = "src/bin/dvm/main.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "dmc"
|
||||||
|
path = "src/bin/dmc/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pest = "2.7.14"
|
pest = "2.7.14"
|
||||||
clap = { version = "4.5.23", features = ["derive"] }
|
clap = { version = "4.5.23", features = ["derive"] }
|
||||||
|
@ -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!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/bin/dmc/ast_dump.rs
Normal file
10
src/bin/dmc/ast_dump.rs
Normal 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
34
src/bin/dmc/main.rs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,9 +15,6 @@ fn main() {
|
|||||||
// - call the main fn
|
// - call the main fn
|
||||||
// fn main() { println "Hello, World!" }
|
// 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
|
// std/core/array lib
|
||||||
let mut array_lib = DmLib::new("std/core/array");
|
let mut array_lib = DmLib::new("std/core/array");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user