mirror of
https://github.com/circify/circ.git
synced 2026-04-21 03:00:54 -04:00
It is very naive. It assumes that any top-level array should be represented as a RAM, and that all internal structure should be unfolded.
41 lines
982 B
Bash
Executable File
41 lines
982 B
Bash
Executable File
#!/usr/bin/env zsh
|
|
set -ex
|
|
|
|
function usage {
|
|
echo "Usage: $0 COMPILER_COMMAND TEMPLATE PATTERN REPLACEMENTS..."
|
|
exit 2
|
|
}
|
|
|
|
compiler_command=($(eval echo $1))
|
|
template_file=$2
|
|
pattern=$3
|
|
replacements=(${@:4})
|
|
|
|
[[ ! -z $compiler_command ]] || (echo "Empty compiler command" && usage)
|
|
if [[ ! -a $template_file ]]
|
|
then
|
|
for arg in $compiler_command
|
|
do
|
|
if [[ $arg =~ .*.zok ]]
|
|
then
|
|
echo "template $arg"
|
|
template_file=$arg
|
|
fi
|
|
done
|
|
fi
|
|
[[ -a $template_file ]] || (echo "No file at $template_file" && usage)
|
|
[[ ! -z $pattern ]] || (echo "Empty pattern" && usage)
|
|
[[ ! -z $replacements ]] || (echo "Empty replacements" && usage)
|
|
|
|
echo $replacements
|
|
|
|
for replacement in $replacements
|
|
do
|
|
t=$(mktemp compiler_asymptotics_XXXXXXXX.zok)
|
|
cat $template_file | sed "s/$pattern/$replacement/g" > $t
|
|
instantiated_command=$(echo $compiler_command | sed "s/$template_file/$t/")
|
|
echo $instantiated_command
|
|
rm $t
|
|
done
|
|
|