-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranslate.sh
40 lines (32 loc) · 997 Bytes
/
translate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
if [ $# != 4 ]; then
echo "[ERROR] Please provide the correct number of arguments."
exit 1
fi
template=$1
source=$2
source_name="${source%.*}"
target=$3
target_name="${target%.*}"
output=$4
if [ $template != "morphism" ] && [ $template != "relation" ] && [ $template != "embedding" ]; then
echo "[ERROR] The first argument should be morphism, relation or embedding."
exit 1
fi
if [ ${source##*.} != "dk" ]; then
echo "[ERROR] The source file provided is not a Dedukti file."
exit 1
fi
if [ ${target##*.} != "dk" ]; then
echo "[ERROR] The target file provided is not a Dedukti file."
exit 1
fi
if [ ${output##*.} != "dk" ]; then
echo "[ERROR] The output file provided is not a Dedukti file."
exit 1
fi
dune build
dune exec -- translation --template $template --source $source_name --target $target_name > $output
sed -i 's/module_to_erase.//g' $output
sed -i 's/module_todo.//g' $output
sed -i "1s/^/#REQUIRE ${target_name}.\n\n/" $output