Skip to content

Commit

Permalink
feat: enable shebang (amber-lang#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph0enixKM authored Jul 8, 2024
1 parent ccc5bdb commit be1f142
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern crate chrono;
use chrono::prelude::*;
use itertools::Itertools;
use crate::modules::block::Block;
use crate::rules;
use crate::translate::check_all_blocks;
Expand All @@ -26,7 +27,15 @@ impl AmberCompiler {
cc: Compiler::new("Amber", rules::get_rules()),
path,
}
.load_code(code)
.load_code(AmberCompiler::strip_off_shebang(code))
}

fn strip_off_shebang(code: String) -> String {
if code.starts_with("#!") {
code.split("\n").into_iter().skip(1).collect_vec().join("\n")
} else {
code
}
}

fn env_flag_set(flag: &str) -> bool {
Expand Down

0 comments on commit be1f142

Please sign in to comment.