39 lines
964 B
Rust
39 lines
964 B
Rust
//! Command line interface for the dust programming language.
|
|
use clap::Parser;
|
|
use std::fs::read_to_string;
|
|
use tree_sitter::{Parser as TSParser, Language};
|
|
|
|
/// Command-line arguments to be parsed.
|
|
#[derive(Parser, Debug)]
|
|
#[command(author, version, about, long_about = None)]
|
|
struct Args {
|
|
/// Whale source code to evaluate.
|
|
#[arg(short, long)]
|
|
command: Option<String>,
|
|
|
|
/// Location of the file to run.
|
|
path: Option<String>,
|
|
}
|
|
|
|
fn main() {
|
|
let args = Args::parse();
|
|
|
|
if args.path.is_none() && args.command.is_none() {
|
|
todo!();
|
|
}
|
|
|
|
if let Some(path) = args.path {
|
|
let file_contents = read_to_string(path).unwrap();
|
|
|
|
let mut parser = TSParser::new();
|
|
parser.set_language(tree_sitter_dust::language()).unwrap();
|
|
let tree = parser.parse(&file_contents, None).unwrap();
|
|
let root = tree.root_node();
|
|
|
|
tree_sitter_dust::evaluate(root);
|
|
|
|
println!("{tree:?}");
|
|
}
|
|
}
|
|
|