<commit_before>#!/bin/bash

# This program and the accompanying materials are made available under the
# terms of the MIT license (X11 license) which accompanies this distribution.

# author: <NAME>

################################################################################################################ Parse arguments:
while getopts s:d:i:t: opt
do
	case $opt in
		s)	system="$OPTARG";;
		d)	diagram="$OPTARG";;
		i)	input="$OPTARG";;
		t)	trace="$OPTARG";;
		?)
			echo "Usage: -s Scheme system (racket, larceny, petite))"
			echo "       -d Activity diagram"
			echo "       -i Activity diagram input"
			echo "       -t Execution trace"
			exit 2
	esac
done
shift $(( OPTIND - 1 ))

if [ -z "$system" ]
then
	echo " !!! ERROR: No Scheme system given !!!" >&2
	exit 2
fi
if [ -z "$diagram" ]
then
	echo " !!! ERROR: No activity diagram to interpret given !!!" >&2
	exit 2
fi
if [ -z "$trace" ]
then
	echo " !!! ERROR: No tracing log given !!!" >&2
	exit 2
fi

if [ -z "$input" ]
then
	input=":"
fi

############################################################################### Configure temporary resources & execution script:
old_pwd=`pwd`

my_exit(){
	cd $old_pwd
	rm script.scm 
	rm tmp-trace.trace
	exit 0
}
trap 'my_exit' 1 2 3 9 15

echo "#!r6rs" > script.scm
echo "(import (rnrs) (ttc-2015-fuml-activity-diagrams user-interface))" >> script.scm
echo "(define diagram (cadr (command-line)))" >> script.scm
echo "(define input (caddr (command-line)))" >> script.scm
echo "(define trace (cadddr (command-line)))" >> script.scm
echo '(set! input (if (string=? input ":") #f input))' >> script.scm
echo "(run-activity-diagram diagram input trace)" >> script.scm

####################################################################################################### Execute activity diagram:
case "$system" in
larceny)
	larceny --r6rs --path "../../racr/larceny-bin:../atomic-petrinets/larceny-bin:larceny-bin" \
		--program script.scm -- $diagram $input tmp-trace.trace;;
racket)
	plt-r6rs ++path "../../racr/racket-bin" ++path "../atomic-petrinets/racket-bin" ++path "racket-bin" \
		script.scm $diagram $input tmp-trace.trace;;
petite)
	petite --libdirs "../..:.." \
		--program script.scm $diagram $input tmp-trace.trace;;
*)
	echo " !!! ERROR: Unknown Scheme system [$system] !!!"
	touch tmp-trace.trace
	my_exit;;
esac

############################################################################################################# Save/compare trace:
if [ -e "$trace" ]
then
	diff_result=`diff --text trace.trace "$trace"`
	if [ "$diff_result" != "" ]
	then
		echo " !!! RESULT ERROR !!!"
	fi
else
	cp -p tmp-trace.trace "$trace"
fi

my_exit
<commit_msg>Examples (ttc-2015-fuml-activity-diagrams): Fixed run.bash script.<commit_after>#!/bin/bash

# This program and the accompanying materials are made available under the
# terms of the MIT license (X11 license) which accompanies this distribution.

# author: <NAME>

################################################################################################################ Parse arguments:
while getopts s:d:i: opt
do
	case $opt in
		s)	system="$OPTARG";;
		d)	diagram="$OPTARG";;
		i)	input="$OPTARG";;
		?)
			echo "Usage: -s Scheme system (racket, larceny, petite))"
			echo "       -d Activity diagram"
			echo "       -i Activity diagram input"	
			exit 2
	esac
done
shift $(( OPTIND - 1 ))

if [ -z "$system" ]
then
	echo " !!! ERROR: No Scheme system given !!!" >&2
	exit 2
fi
if [ -z "$diagram" ]
then
	echo " !!! ERROR: No activity diagram to interpret given !!!" >&2
	exit 2
fi
if [ -z "$input" ]
then
	input=":false:"
fi

############################################################################### Configure temporary resources & execution script:
old_pwd=`pwd`

my_exit(){
	cd $old_pwd
	rm script.scm	
	exit 0
}
trap 'my_exit' 1 2 3 9 15

echo "#!r6rs" > script.scm
echo "(import (rnrs) (ttc-2015-fuml-activity-diagrams user-interface))" >> script.scm
echo "(define diagram (cadr (command-line)))" >> script.scm
echo "(define input (caddr (command-line)))" >> script.scm
echo '(set! input (if (string=? input ":false:") #f input))' >> script.scm
echo "(run-activity-diagram diagram input)" >> script.scm

####################################################################################################### Execute activity diagram:
case "$system" in
larceny)
	larceny --r6rs --path "../../racr/larceny-bin:../atomic-petrinets/larceny-bin:larceny-bin" \
		--program script.scm -- $diagram $input;;
racket)
	plt-r6rs ++path "../../racr/racket-bin" ++path "../atomic-petrinets/racket-bin" ++path "racket-bin" \
		script.scm $diagram $input;;
petite)
	petite --libdirs "../..:.." \
		--program script.scm $diagram $input;;
*)
	echo " !!! ERROR: Unknown Scheme system [$system] !!!"	
	my_exit;;
esac

my_exit

{'fraction_non_alphanumeric': 0.2930280957336108, 'fraction_numerical': 0.01040582726326743, 'mean_word_length': 4.322259136212624, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '248023', 'n_tokens_mistral': 1661, 'n_tokens_neox': 1555, 'n_words': 458}