Initial commit

This commit is contained in:
stackclass
2025-08-25 04:51:11 +00:00
commit c9de5ba225
11 changed files with 265 additions and 0 deletions

35
src/main.rs Normal file
View File

@@ -0,0 +1,35 @@
use std::env;
use std::fs;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 3 {
eprintln!("Usage: {} tokenize <filename>", args[0]);
return;
}
let command = &args[1];
let filename = &args[2];
match command.as_str() {
"tokenize" => {
// You can use print statements as follows for debugging, they'll be visible when running tests.
eprintln!("Logs from your program will appear here!");
let file_contents = fs::read_to_string(filename).unwrap_or_else(|_| {
eprintln!("Failed to read file {filename}");
String::new()
});
// Uncomment this block to pass the first stage
// if !file_contents.is_empty() {
// panic!("Scanner not implemented");
// } else {
// println!("EOF null"); // Placeholder, replace this line when implementing the scanner
// }
}
_ => {
eprintln!("Unknown command: {command}");
}
}
}