55 lines
1.5 KiB
Bash
Executable File
55 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
################################################################################################
|
|
# NOTE: `chmod +x run.sh` vorher ausführen, um dieses Skript benutzen zu können.
|
|
################################################################################################
|
|
|
|
################################
|
|
# HILFSMETHODEN
|
|
################################
|
|
|
|
function call_go() {
|
|
go $@;
|
|
}
|
|
|
|
function check_requirements() {
|
|
[ -f "go.sum" ] && rm "go.sum";
|
|
call_go get "$( cat requirements )";
|
|
}
|
|
|
|
function precompile_grammars() {
|
|
local fname;
|
|
local name;
|
|
pushd grammars >> /dev/null;
|
|
while read fname; do
|
|
( [ "$fname" == "" ] || ! [ -f "$fname" ] ) && continue;
|
|
name="$( echo "$fname" | sed -E "s/^(.*)\.g4$/\1/g" )";
|
|
echo -e "\033[92;1mANTLR4\033[0m präkompiliert Grammatik \033[1m${fname}\033[0m";
|
|
java -jar antlr.jar -Dlanguage=Go "$fname" -o "$name";
|
|
done <<< "$( ls *.g4 2> /dev/null )"
|
|
popd >> /dev/null
|
|
}
|
|
|
|
function compile_programme() {
|
|
[ -f "main" ] && rm "main";
|
|
echo -e "\033[92;1mGO\033[0m kompiliert \033[1mmain.go\033[0m";
|
|
call_go build "main.go";
|
|
}
|
|
|
|
function run_programme() {
|
|
echo -e "\033[92;1mGO\033[0m kompiliertes Programm wird ausgeführt";
|
|
./main;
|
|
}
|
|
|
|
################################
|
|
# HAUPTVORGÄNGE
|
|
################################
|
|
|
|
# Kann auskommentiert werden, wenn nötige Module schon installiert:
|
|
check_requirements;
|
|
|
|
# Code als Programm kompilieren und ausführen:
|
|
precompile_grammars;
|
|
compile_programme;
|
|
run_programme;
|