Commit a3ab7448 authored by POTTIER Francois's avatar POTTIER Francois

Allow multiple test inputs.

parent 2fbb260f
......@@ -7,9 +7,9 @@ parser.mli
*.cmx
*.o
*.d
table.out
table.err
code.out
code.err
*.table.out
*.table.err
*.code.out
*.code.err
interpret.out
interpret.err
122 + 2 * 3 + 128
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
(122 + 2) * 3 + 128
Lookahead token is now LPAREN (0-1)
State 0:
Shifting (LPAREN) to state 2
State 2:
Lookahead token is now INT (1-4)
Shifting (INT) to state 3
State 3:
Lookahead token is now PLUS (5-6)
Reducing production expr -> INT
State 4:
Shifting (PLUS) to state 8
State 8:
Lookahead token is now INT (7-8)
Shifting (INT) to state 3
State 3:
Lookahead token is now RPAREN (8-9)
Reducing production expr -> INT
State 9:
Reducing production expr -> expr PLUS expr
State 4:
Shifting (RPAREN) to state 7
State 7:
Lookahead token is now TIMES (10-11)
Reducing production expr -> LPAREN expr RPAREN
State 16:
Shifting (TIMES) to state 5
State 5:
Lookahead token is now INT (12-13)
Shifting (INT) to state 3
State 3:
Lookahead token is now PLUS (14-15)
Reducing production expr -> INT
State 6:
Reducing production expr -> expr TIMES expr
State 16:
Shifting (PLUS) to state 8
State 8:
Lookahead token is now INT (16-19)
Shifting (INT) to state 3
State 3:
Lookahead token is now EOL (19-20)
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
(122 + 2) * 3 + (128 * -2) - 2 - 2
Lookahead token is now LPAREN (0-1)
State 0:
Shifting (LPAREN) to state 2
State 2:
Lookahead token is now INT (1-4)
Shifting (INT) to state 3
State 3:
Lookahead token is now PLUS (5-6)
Reducing production expr -> INT
State 4:
Shifting (PLUS) to state 8
State 8:
Lookahead token is now INT (7-8)
Shifting (INT) to state 3
State 3:
Lookahead token is now RPAREN (8-9)
Reducing production expr -> INT
State 9:
Reducing production expr -> expr PLUS expr
State 4:
Shifting (RPAREN) to state 7
State 7:
Lookahead token is now TIMES (10-11)
Reducing production expr -> LPAREN expr RPAREN
State 16:
Shifting (TIMES) to state 5
State 5:
Lookahead token is now INT (12-13)
Shifting (INT) to state 3
State 3:
Lookahead token is now PLUS (14-15)
Reducing production expr -> INT
State 6:
Reducing production expr -> expr TIMES expr
State 16:
Shifting (PLUS) to state 8
State 8:
Lookahead token is now LPAREN (16-17)
Shifting (LPAREN) to state 2
State 2:
Lookahead token is now INT (17-20)
Shifting (INT) to state 3
State 3:
Lookahead token is now TIMES (21-22)
Reducing production expr -> INT
State 4:
Shifting (TIMES) to state 5
State 5:
Lookahead token is now MINUS (23-24)
Shifting (MINUS) to state 1
State 1:
Lookahead token is now INT (24-25)
Shifting (INT) to state 3
State 3:
Lookahead token is now RPAREN (25-26)
Reducing production expr -> INT
State 14:
Reducing production expr -> MINUS expr
State 6:
Reducing production expr -> expr TIMES expr
State 4:
Shifting (RPAREN) to state 7
State 7:
Lookahead token is now MINUS (27-28)
Reducing production expr -> LPAREN expr RPAREN
State 9:
Reducing production expr -> expr PLUS expr
State 16:
Shifting (MINUS) to state 12
State 12:
Lookahead token is now INT (29-30)
Shifting (INT) to state 3
State 3:
Lookahead token is now MINUS (31-32)
Reducing production expr -> INT
State 13:
Reducing production expr -> expr MINUS expr
State 16:
Shifting (MINUS) to state 12
State 12:
Lookahead token is now INT (33-34)
Shifting (INT) to state 3
State 3:
Lookahead token is now EOL (34-35)
Reducing production expr -> INT
State 13:
Reducing production expr -> expr MINUS expr
State 16:
Shifting (EOL) to state 17
State 17:
Reducing production main -> expr EOL
State 15:
Accepting
......@@ -13,13 +13,19 @@
echo "Building and running (code)..."
make clean >/dev/null
make MENHIR="$MENHIR --trace" >/dev/null
echo "122 + 2 * 3 + 128" | ./calc > code.out 2> code.err
for f in *.real.in ; do
b=${f%.in}
./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
echo "122 + 2 * 3 + 128" | ./calc > table.out 2> table.err
for f in *.real.in ; do
b=${f%.in}
./calc < $f > $b.table.out 2> $b.table.err
done
# Run the reference interpreter.
echo "Running the reference interpreter..."
......@@ -27,22 +33,21 @@ echo "INT PLUS INT TIMES INT PLUS INT EOL" | $MENHIR --trace --interpret parser.
echo "Comparing results..."
# Compare the results to the reference outputs.
for mode in code table ; do
if ! diff -q ref.out $mode.out >/dev/null ; then
echo "The $mode parser produces a wrong result!"
echo "Expected:"
cat ref.out
echo "Got:"
cat $mode.out
fi
done
# Compare the logs to the reference logs.
# Compare the results to the reference.
for mode in code table ; do
if ! diff -q ref.err $mode.err >/dev/null ; then
echo "The $mode parser produces a wrong trace!"
diff ref.err $mode.err
for f in *.real.in ; do
b=${f%.in}
if ! diff -q $b.ref.out $b.$mode.out >/dev/null ; then
echo "($f) The $mode parser produces a wrong result!"
echo "Expected:"
cat $b.ref.out
echo "Got:"
cat $b.$mode.out
fi
done
if ! diff -q $b.ref.err $b.$mode.err >/dev/null ; then
echo "($f) The $mode parser produces a wrong trace!"
diff $b.ref.err $b.$mode.err
fi
done
......
......@@ -12,7 +12,10 @@
echo "Building and running (code)..."
make clean >/dev/null
make MENHIR="$MENHIR --trace" >/dev/null
echo "122 + 2 * 3 + 128" | ./calc > ref.out 2> ref.err
for f in *.real.in ; do
b=${f%.in}
./calc < $f > $b.ref.out 2> $b.ref.err
done
# Run the reference interpreter.
echo "Running the reference interpreter..."
......
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