compare.sh 1.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

# Example usage: ./compare.sh mezzo
# This script processes mezzo.mly using two versions of Menhir:
# 1- the last committed version;
# 2- the current (uncommitted) version.
# It then compares the output.

# The variable OPT can be used to pass extra options to Menhir.
# Use as follows:
# OPT=--lalr ./compare.sh ocaml

BENCH=../bench/good
MENHIR=_stage1/menhir.native
BASE="-v -lg 1 -la 1"

if [ $# -eq 0 ]
then
  echo "$0: at least one argument expected"
  exit 1
fi

23
24
25
26
27
28
29
30
31
32
33
# Try the current version.
echo "Compiling (current uncommitted version)..."
make &> compile.new || { cat compile.new && exit 1 ; }
sleep 1
for FILE in "$@"
do
  echo "Running ($FILE.mly)..."
  { time $MENHIR $BASE $OPT $BENCH/$FILE.mly ; } &>$FILE.new
done

# Try the last committed version.
34
35
git stash
echo "Compiling (last committed version)..."
36
37
38
39
40
41
42
make &> compile.old || { cat compile.old && exit 1 ; }
sleep 1
for FILE in "$@"
do
 echo "Running ($FILE.mly)..."
 { time $MENHIR $BASE $OPT $BENCH/$FILE.mly ; } &>$FILE.old
done
43
44
45
46
47
48
49
50
git stash pop

# Diff.
for FILE in "$@"
do
  echo "Diffing ($FILE.mly)..."
  diff $FILE.old $FILE.new
done