chore: initialize NexaCore compiler workspace with basic frontend and CLI

Add initial project structure for NexaCore programming language compiler:
- Create Cargo workspace with 4 crates (cli, driver, frontend, runtime)
- Add lexer with indentation-based tokenization and keyword support
- Add parser for modules, functions, structs, and basic expressions
- Implement CLI with build command and placeholder subcommands
- Add driver crate to orchestrate compilation pipeline
- Include .gitignore for Rust build
This commit is contained in:
2026-04-06 16:57:54 +02:00
commit 0da224325a
17 changed files with 1704 additions and 0 deletions

14
crates/nxc-cli/Cargo.toml Normal file
View File

@@ -0,0 +1,14 @@
[package]
name = "nxc-cli"
version.workspace = true
edition.workspace = true
license.workspace = true
authors.workspace = true
[[bin]]
name = "nexacore"
path = "src/main.rs"
[dependencies]
nxc-driver = { path = "../nxc-driver" }

View File

@@ -0,0 +1,65 @@
use std::env;
use std::path::Path;
use std::process::ExitCode;
fn main() -> ExitCode {
match run() {
Ok(()) => ExitCode::SUCCESS,
Err(message) => {
eprintln!("{message}");
ExitCode::FAILURE
}
}
}
fn run() -> Result<(), String> {
let mut args = env::args().skip(1);
let Some(command) = args.next() else {
print_help();
return Ok(());
};
match command.as_str() {
"build" => {
let Some(path) = args.next() else {
return Err("usage: nexacore build <file.nx>".to_string());
};
let result = nxc_driver::compile_file(Path::new(&path))
.map_err(format_compile_error)?;
println!("compiled {path}");
println!("tokens: {}", result.tokens.len());
println!("items: {}", result.module.items.len());
Ok(())
}
"run" => Err("runtime execution is not implemented yet".to_string()),
"new" => Err("project scaffolding is not implemented yet".to_string()),
"test" => Err("test runner is not implemented yet".to_string()),
"fmt" => Err("formatter is not implemented yet".to_string()),
"add" => Err("package manager is not implemented yet".to_string()),
"doc" => Err("docs generator is not implemented yet".to_string()),
_ => Err(format!("unknown command: {command}")),
}
}
fn format_compile_error(error: nxc_driver::CompileError) -> String {
match error {
nxc_driver::CompileError::Io(io) => format!("io error: {io}"),
nxc_driver::CompileError::Parse(parse) => format!(
"parse error at line {}, column {}: {}",
parse.span.line, parse.span.column, parse.message
),
}
}
fn print_help() {
println!("NexaCore CLI");
println!("usage:");
println!(" nexacore build <file.nx>");
println!(" nexacore run <file.nx>");
println!(" nexacore new <name>");
println!(" nexacore test");
println!(" nexacore fmt");
println!(" nexacore add <package>");
println!(" nexacore doc");
}