add --contatenate option to cover.sh script

This commit is contained in:
Lesenechal Remi 2020-01-09 07:40:24 +01:00
parent 31a16afcf9
commit fcb1c4ab77

View File

@ -78,6 +78,11 @@ while : ; do
;; ;;
# Help # Help
# #
--concatenate*)
if test -n "$dir_opt"; then
fatal_error "Repeated option --concatenate."; fi
concatenate=yes
;;
--unlexer=*) --unlexer=*)
if test -n "$unlexer"; then if test -n "$unlexer"; then
fatal_error "Repeated option --unlexer."; fi fatal_error "Repeated option --unlexer."; fi
@ -119,7 +124,7 @@ done
# #
usage () { usage () {
cat <<EOF cat <<EOF
Usage: $(basename $0) [-h|--help] Usage: $(basename $0) [-h|--help] [--concatenate]
--par-tokens=<par_tokens>.mly --par-tokens=<par_tokens>.mly
--lex-tokens=<lex_tokens>.mli --lex-tokens=<lex_tokens>.mli
--messages=<parser>.msg --messages=<parser>.msg
@ -136,6 +141,8 @@ generating the latter). The LIGO files will be numbered with their
corresponding state number in the automaton. The executable <binary> corresponding state number in the automaton. The executable <binary>
reads a line on stdin of tokens and produces a line of corresponding reads a line on stdin of tokens and produces a line of corresponding
lexemes. lexemes.
If option --concatenate is used a single file 'all.<extension>' will
be produced, containing the concatenation of all the erroneous expressions
The following options, if given, must be given only once. The following options, if given, must be given only once.
@ -262,7 +269,11 @@ paste -d ':' $states $raw > $map
rm -f $dir/*.$ext rm -f $dir/*.$ext
while read -r line; do while read -r line; do
state=$(echo $line | sed -n 's/\(.*\):.*/\1/p') state=$(echo $line | sed -n 's/\(.*\):.*/\1/p')
if test "$concatenate" = "yes"; then
filename="$dir/all.$ext"
else
filename=$(printf "$dir/%04d.$ext" $state) filename=$(printf "$dir/%04d.$ext" $state)
fi
sentence=$(echo $line | sed -n 's/.*:\(.*\)/\1/p') sentence=$(echo $line | sed -n 's/.*:\(.*\)/\1/p')
echo $sentence | $unlexer >> $filename echo $sentence | $unlexer >> $filename
done < $map done < $map