Skip to content

Commit

Permalink
Added help messages
Browse files Browse the repository at this point in the history
  • Loading branch information
leslie255 committed Oct 27, 2022
1 parent 6e225a1 commit 4ae6f70
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
18 changes: 17 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,23 @@ impl Compiler {

#[allow(unused_variables)]
fn print_help(src_path: String) {
todo!()
let mut args = env::args();
let exe_name = args.next().unwrap_or("sharkc".to_string());
let mut tabs = String::new();
for _ in 0..exe_name.len() / 8 {
tabs.push('\t');
}
println!("SHARKC 0.1");
println!("Usage:");
println!(" sharkc -h\t\tPrint this message");
println!(" sharkc <source.shark>\tSource file");
println!(" -f macho64/elf64\tOutput format");
println!(" -o <output.asm>\tOutput file");
println!("Debug options:");
println!(" -t / --token\tprint tokens");
println!(" -a / --ast\tprint AST");
println!(" -i / --ir\tprint SHIR");
println!(" -m / --mir\tprint MIR");
}

fn compile(src_path: String, output_path: String, file_format: FileFormat) {
Expand Down
27 changes: 11 additions & 16 deletions test/test.shark
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
#import cstd.hhh

square: (x: usize) -> usize = {

#asm
mov rax, rdi
mul rdi
#end

return _;
}
#import math.hhh

main: -> u32 = {
a: = 16;
x: = 0;
if a == 16 {
"lol\n";
} else {
"lmao\n";
i: = 0;
loop {
inc(&i);
if i <= 2 {
continue;
}
printf("%lu\n", i);
if i == 10 {
break;
}
}
return 0;
}

0 comments on commit 4ae6f70

Please sign in to comment.