Skip to content

Commit

Permalink
Error when no source files are input
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaAhmad00 committed Nov 2, 2023
1 parent 6a431e4 commit 3de8722
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod code_generation;
mod compilation;
mod lexical_analysis;
mod syntax_analysis;
mod utils;

use clap::Parser;
use crate::utils::compilation;

#[derive(Parser, Debug)]
#[clap(about, long_about = None)]
Expand Down Expand Up @@ -34,11 +34,17 @@ fn main() {
+ args.exe_filename.is_some() as usize;

if exclusive_args_count > 1 {
panic!("Cannot specify more than one option from [-l, -c, -s, -o] at one time");
eprintln!("Error: cannot specify more than one option from [-l, -c, -s, -o] at one time");
return;
} else if exclusive_args_count == 0 {
args.exe_filename = Some("a.out".to_string());
}

if args.input_source_files.is_empty() {
eprintln!("Error: at least one source file has to be provided");
return;
}

let compilation = compilation::Compilation::new();
for filename in &args.input_source_files {
let source = std::fs::read_to_string(&filename).unwrap();
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod test_utils;
pub mod compilation;

0 comments on commit 3de8722

Please sign in to comment.