Commit be01da4d authored by POTTIER Francois's avatar POTTIER Francois

Cleanup and reorganisation in quicktest.

parent 78119b55
PGFLAGS := --infer
GENERATED := parser.ml parser.mli lexer.ml
MODULES := parser lexer calc
EXECUTABLE := calc
OCAMLDEPWRAPPER := ../demos/ocamldep.wrapper
include ../demos/Makefile.shared
include ../demos/Makefile.auto
SHELL := /bin/bash
.PHONY: test clean
test:
./test.sh
clean:
rm -f calc-data/*.{table,code,interpret}.{out,err}
This directory contains quick tests for Menhir and MenhirLib.
They are supposed to help avoid mistakes and guide choices
while developing, but they are not very serious.
The files are as follows:
config.sh Shared variables.
build.sh Builds Menhir and MenhirLib from scratch,
and re-installs MenhirLib using ocamlfind.
calc A modified version of the calc demo.
calc-data Test inputs and reference outputs.
trustme.sh Reconstructs the reference outputs.
test.sh Runs the calc demo with the test inputs
and compares the outputs with the reference
outputs.
gene Another version of the calc demo, bundled
with its own random generator of (long)
test inputs.
#!/bin/sh
#!/bin/bash
# This script rebuilds Menhir and MenhirLib from scratch, so as to make sure
# that we are testing the current development version.
......
calc
lexer.ml
parser.ml
parser.mli
*.cmi
*.cmo
*.cmx
*.o
*.d
*.table.out
*.table.err
*.code.out
......
calc
lexer.ml
parser.ml
parser.mli
*.cmi
*.cmo
*.cmx
*.o
*.d
PGFLAGS := --infer
GENERATED := parser.ml parser.mli lexer.ml
MODULES := parser lexer calc
EXECUTABLE := calc
OCAMLDEPWRAPPER := ../../demos/ocamldep.wrapper
include ../../demos/Makefile.shared
include ../../demos/Makefile.auto
SRC=../src
BUILD=$SRC/_stage1
MENHIR=$BUILD/menhir.native
CALC=calc
DATA=calc-data
Lookahead token is now INT (-1--1)
State 0:
Shifting (INT) to state 4
State 4:
Lookahead token is now PLUS (-1--1)
Reducing production expr -> INT
State 22:
Shifting (PLUS) to state 11
State 11:
Lookahead token is now INT (-1--1)
Reducing production optional_dot ->
State 12:
Shifting (INT) to state 4
State 4:
Lookahead token is now TIMES (-1--1)
Reducing production expr -> INT
State 13:
Shifting (TIMES) to state 6
State 6:
Lookahead token is now INT (-1--1)
Reducing production optional_dot ->
State 8:
Shifting (INT) to state 4
State 4:
Lookahead token is now PLUS (-1--1)
Reducing production expr -> INT
State 9:
Reducing production expr -> expr TIMES optional_dot expr
State 13:
Reducing production expr -> expr PLUS optional_dot expr
State 22:
Shifting (PLUS) to state 11
State 11:
Lookahead token is now INT (-1--1)
Reducing production optional_dot ->
State 12:
Shifting (INT) to state 4
State 4:
Lookahead token is now EOL (-1--1)
Reducing production expr -> INT
State 13:
Reducing production expr -> expr PLUS optional_dot expr
State 22:
Shifting (EOL) to state 23
State 23:
Reducing production main -> expr EOL
State 21:
Accepting
Lookahead token is now INT (0-3)
State 0:
Shifting (INT) to state 3
State 3:
Lookahead token is now PLUS (4-5)
Reducing production expr -> INT
State 16:
Shifting (PLUS) to state 8
State 8:
Lookahead token is now INT (6-7)
Shifting (INT) to state 3
State 3:
Lookahead token is now TIMES (8-9)
Reducing production expr -> INT
State 9:
Shifting (TIMES) to state 5
State 5:
Lookahead token is now INT (10-11)
Shifting (INT) to state 3
State 3:
Lookahead token is now PLUS (12-13)
Reducing production expr -> INT
State 6:
Reducing production expr -> expr TIMES expr
State 9:
Reducing production expr -> expr PLUS expr
State 16:
Shifting (PLUS) to state 8
State 8:
Lookahead token is now INT (14-17)
Shifting (INT) to state 3
State 3:
Lookahead token is now EOL (17-18)
Reducing production expr -> INT
State 9:
Reducing production expr -> expr PLUS expr
State 16:
Shifting (EOL) to state 17
State 17:
Reducing production main -> expr EOL
State 15:
Accepting
#!/bin/sh
#!/bin/bash
# This script checks that the code back-end, the table back-end, and the
# reference interpreter appear to be working correctly. It uses the calc
......@@ -11,33 +11,33 @@
# Build the parser with the code back-end and run it.
echo "Building and running (code)..."
make clean >/dev/null
make MENHIR="$MENHIR --trace" >/dev/null
for f in *.real.in ; do
make -C $CALC clean >/dev/null
make -C $CALC MENHIR="../$MENHIR --trace" >/dev/null
for f in $DATA/*.real.in ; do
b=${f%.in}
./calc < $f > $b.code.out 2> $b.code.err
$CALC/calc < $f > $b.code.out 2> $b.code.err
done
# Build the parser with the table back-end and run it.
echo "Building and running (table)..."
make clean >/dev/null
make MENHIR="$MENHIR --trace --table" >/dev/null
for f in *.real.in ; do
make -C $CALC clean >/dev/null
make -C $CALC MENHIR="../$MENHIR --trace --table" >/dev/null
for f in $DATA/*.real.in ; do
b=${f%.in}
./calc < $f > $b.table.out 2> $b.table.err
$CALC/calc < $f > $b.table.out 2> $b.table.err
done
# Run the reference interpreter.
echo "Running the reference interpreter..."
for f in *.ideal.in ; do
for f in $DATA/*.ideal.in ; do
b=${f%.in}
$MENHIR --trace --interpret parser.mly < $f > $b.interpret.out 2> $b.interpret.err
$MENHIR --trace --interpret $CALC/parser.mly < $f > $b.interpret.out 2> $b.interpret.err
done
echo "Comparing results..."
# Compare the results to the reference.
for f in *.real.in ; do
for f in $DATA/*.real.in ; do
b=${f%.in}
for mode in code table ; do
echo "($b) Checking output of $mode parser..."
......@@ -57,7 +57,7 @@ for f in *.real.in ; do
done
# Check the results of the reference interpreter.
for f in *.ideal.in ; do
for f in $DATA/*.ideal.in ; do
b=${f%.in}
echo "($b) Checking output of reference interpreter..."
if ! diff -q $b.ref.out $b.interpret.out >/dev/null ; then
......
#!/bin/sh
#!/bin/bash
# This script re-generates the reference files used by test.sh for comparison.
# One should call it only when one trusts that Menhir is currently working!
......@@ -10,19 +10,19 @@
# Build the parser with the code back-end and run it.
echo "Building (code)..."
make clean >/dev/null
make MENHIR="$MENHIR --trace" >/dev/null
for f in *.real.in ; do
make -C $CALC clean >/dev/null
make -C $CALC MENHIR="../$MENHIR --trace" >/dev/null
for f in $DATA/*.real.in ; do
b=${f%.in}
echo "($b) Reconstructing reference output and trace..."
./calc < $f > $b.ref.out 2> $b.ref.err
$CALC/calc < $f > $b.ref.out 2> $b.ref.err
done
# Run the reference interpreter.
for f in *.ideal.in ; do
for f in $DATA/*.ideal.in ; do
b=${f%.in}
echo "($b) Reconstructing reference output and trace..."
$MENHIR --trace --interpret parser.mly < $f > $b.ref.out 2> $b.ref.err
$MENHIR --trace --interpret $CALC/parser.mly < $f > $b.ref.out 2> $b.ref.err
done
echo "Done."
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment