#!/bin/bash

prefix=$1
utils=$prefix"plt/collects/syntax-color/lexer-contract.rkt"
lex=$prefix"plt/collects/syntax-color/module-lexer.rkt"


if [ $2 == "no-contracts" ] ; then
echo "no contracts"  >> RESULTS.TXT
echo "no contracts" 
sed -i 's/(define-for-syntax with-options.*/(define-for-syntax with-options #f)/' $utils;
sed -i 's/(define-syntax with-contracts.*/(define-for-syntax with-contracts #f)/' $utils;
fi

if [ $2 == "with-contracts" ] ; then
echo "with contracts" >> RESULTS.TXT
echo "with contracts" 
sed -i 's/(define-for-syntax with-options.*/(define-for-syntax with-options #f)/' $utils;
sed -i 's/(define-for-syntax with-contracts.*/(define-for-syntax with-contracts #t)/' $utils;
fi

if [ $2 == "with-options" ] ; then
echo "with options" >> RESULTS.TXT
echo "with options"
sed -i 's/(define-for-syntax with-options.*/(define-for-syntax with-options #t)/' $utils;
sed -i 's/(define-for-syntax with-contracts.*/(define-for-syntax with-contracts #f)/' $utils;
fi

echo "trusted lexer" >> RESULTS.TXT
echo "trusted lexer"
sed -i  -E -e '/^;mode/{' -e n -e 's/^;//' -e '}' -e '/^;mode/{' -e n -e's/^;*(.)/\1/' -e '}' $lex;
$1"plt/bin/raco" setup -D 
./lex_benchmarks $prefix "time1.rkt"

echo "untrusted lexer" >> RESULTS.TXT
echo "untrusted lexer"
sed -i -E  -e '/^;mode/{' -e n -e's/^;*(.)/;\1/' -e '}' $lex;
"../plt/bin/raco" setup -D 
./lex_benchmarks "../" "time1.rkt"


