aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs
index 9a025b9..f09e0f0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,16 +1,14 @@
-
-use std::io;
use std::env;
+use std::io;
use std::io::Write;
use std::path::Path;
-mod sexpr;
mod cexpr;
+mod sexpr;
use cexpr::CExpr;
fn repl(_verbose: bool) {
-
let stdin = io::stdin();
let mut stdout = io::stdout();
@@ -40,12 +38,13 @@ fn usage() {
println!("usage:\tcasual [-h] [-v] [--no-repl] [<files>]");
println!("");
println!("Files will be loaded in order, then drop to REPL (unless \"--no-repl\" is passed).");
- println!("Verbose flag (\"-v\") will result in lexed tokens and parsed AST \
- being dumped to stdout (when on REPL).");
+ println!(
+ "Verbose flag (\"-v\") will result in lexed tokens and parsed AST \
+ being dumped to stdout (when on REPL)."
+ );
}
fn main() {
-
let mut verbose: bool = false;
let mut no_repl: bool = false;
@@ -53,15 +52,22 @@ fn main() {
for arg in env::args().skip(1) {
match &*arg {
- "-v" | "--verbose" => { verbose = true; },
- "--no-repl" => { no_repl = true; },
- "-h" | "--help" => { usage(); return; },
+ "-v" | "--verbose" => {
+ verbose = true;
+ }
+ "--no-repl" => {
+ no_repl = true;
+ }
+ "-h" | "--help" => {
+ usage();
+ return;
+ }
_ if arg.starts_with("-") => {
println!("Unknown option: {}", arg);
println!("");
usage();
return;
- },
+ }
_ => {
file_list.push(arg.clone());
}
@@ -79,8 +85,8 @@ fn main() {
Err(e) => {
println!("Error loading file: {}\n {}", fname, e);
return;
- },
- Ok(_) => ()
+ }
+ Ok(_) => (),
}
}
@@ -88,4 +94,3 @@ fn main() {
repl(verbose);
}
}
-