1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00

Compare commits

..

2 commits

Author SHA1 Message Date
Natapat Samutpong ad57b2f63a change argument handling 2022-03-25 12:56:54 +07:00
Natapat Samutpong 222cd44bb3 build script 2022-03-25 12:51:37 +07:00
4 changed files with 71 additions and 9 deletions

61
build.sh Executable file
View file

@ -0,0 +1,61 @@
#!/bin/sh
# Exit if subprocess return non-zero exit code
set -e
# Log function
log () {
echo -e "\033[0;32m[LOG]\033[0m $1"
}
err () {
echo -e "\033[0;31m[ERR]\033[0m $1"
}
# This will always be true unless there is
# missing executable that we need to use
install_pass=true
# Check if $1 is installed
check_installed () {
if ! command -v $1 -h &> /dev/null
then
err "$1 is not installed"
if [ install_pass ]; then
install_pass=false
fi
fi
}
check_installed cargo
check_installed git
check_installed deno # deno is required for running transpiled program
# If all of the above is installed
if [ ! install_pass ]; then
exit 1
fi
log "Dependencies is installed. Cloning..."
rm -rf ~/.cache/hazure/build/
git clone https://github.com/azur1s/hazure.git ~/.cache/hazure/build/
cd ~/.cache/hazure/build/
if [[ $1 == *"d"* ]]; then
log "Building in debug..."
cargo build
rm ~/bin/hazure -f
mv ~/.cache/hazure/build/target/debug/hazure ~/bin/hazure
else
log "Building..."
cargo build --release
rm ~/bin/hazure -f
mv ~/.cache/hazure/build/target/release/hazure ~/bin/hazure
fi
log "Build done. Cleaning up..."
rm -rf ~/.cache/hazure/build/
log "Done."
hazure -h

View file

@ -3,7 +3,7 @@ use clap::{ Parser, Subcommand };
const VERSION: &str = env!("CARGO_PKG_VERSION"); const VERSION: &str = env!("CARGO_PKG_VERSION");
/// Hades compiler. /// Hazure compiler
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[clap( #[clap(
version = VERSION, version = VERSION,
@ -17,16 +17,16 @@ pub struct Args {
pub enum Options { pub enum Options {
#[clap(about = "Compile an input file.")] #[clap(about = "Compile an input file.")]
Compile { Compile {
/// The input file to compile. /// The input file to compile
#[clap(parse(from_os_str))] #[clap(parse(from_os_str))]
input: PathBuf, input: PathBuf,
/// Print parsed AST and exit (for debugging). /// Print parsed AST and exit (for debugging)
#[clap(short, long)] #[clap(short, long)]
ast: bool, ast: bool,
/// Log process. /// Log process
#[clap(short, long)] #[clap(short, long)]
log: bool, log: bool,
/// Output file path. /// Output file path
#[clap(short, long, parse(from_os_str))] #[clap(short, long, parse(from_os_str))]
output: Option<PathBuf>, output: Option<PathBuf>,
}, },

View file

@ -5,9 +5,10 @@ end;
fun main: void = do fun main: void = do
let result: int = add2(34, 35); let result: int = add2(34, 35);
@write(result); @write(result);
@write("\n");
if result == 69 then if result == 69 then
@write("big cool") @write("big cool");
else else
@write("not cool") @write("not cool");
end; end;
end; end;

View file

@ -5,7 +5,7 @@ fun iter_ (vec: vec_int) (current: int): void = do
do do
-- iter logic -- iter logic
-- TODO: function as argument -- TODO: function as argument
@get(vec, current) |> @write(_); @get(vec current) |> @write(_);
@write("\n"); @write("\n");
iter_(vec, current + 1); iter_(vec, current + 1);