hoaparse: also accept LBTT input

This is probably the worse grammar I wrote: the LBTT format is designed
to be scanned with scanf, and very inconvenient to parse with
bison/flex.  Here the scanner basically has to emulate a parser to
classify the different INTs as tokens with different types.

* src/hoaparse/hoaparse.yy, src/hoaparse/hoascan.ll: Add rules for LBTT.
* src/hoaparse/parsedecl.hh: Add a way to reset the parser between each
automata.
* src/tgbatest/hoaparse.test, src/tgbatest/lbttparse.test: Add more
tests.
This commit is contained in:
Alexandre Duret-Lutz 2014-12-10 16:26:51 +01:00
parent e4158c21ee
commit 6eb2b06fa7
5 changed files with 340 additions and 72 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
# Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -25,45 +25,41 @@ set -e
for f in 'p0 U p1 U p2' 'Gp00 | Gp13 | Gp42' '{(1;1)*}[]->p1'
do
# Make sure Spot can read the LBTT it produces
run 0 ../ltl2tgba -t "$f" > out
run 0 ../../bin/ltl2tgba --lbtt "$f" > out
s=`wc -l < out`
run 0 ../ltl2tgba -t -XL out > out2
head -n 1 out | grep t
run 0 ../../bin/autfilt --lbtt out > out2
s2=`wc -l < out2`
test "$s" -eq "$s2"
# The LBTT output use 2 lines par state, one line per transition,
# and one extra line for header.
run 0 ../ltl2tgba -ks "$f" > size
st=`cat size | sed -n 's/states: //p'`
tr=`cat size | sed -n 's/transitions: //p'`
l=`expr $st \* 2 + $tr + 1`
run 0 ../../bin/ltl2tgba "$f" --stats 'expr %s \* 2 + %e + 1' > size
l=$(eval "$(cat size)")
test "$s" -eq "$l"
# Do the same with bin/ltl2tgba
run 0 ../../bin/ltl2tgba --low --any --lbtt "$f" >out3
cmp out out3
head -n 1 out3 | grep t
# Make sure we output the state-based format
# for BA...
run 0 ../../bin/ltl2tgba --ba --lbtt --low --any "$f" >out4
head -n 1 out4 | grep t && exit 1
s4=`wc -l < out4`
test "$s" -eq "$s4"
run 0 ../ltl2tgba -t -XL out4 > out5
s5=`wc -l < out5`
test "$s" -eq "$s5"
run 0 ../../bin/autfilt --lbtt out4 > out5
run 0 ../../bin/autfilt out4 --are-isomorphic out5
# ... unless --lbtt=t is used.
run 0 ../../bin/ltl2tgba --ba --lbtt=t --low --any "$f" >out6
head -n 1 out6 | grep t
s6=`wc -l < out6`
test "$s" -eq "$s6"
run 0 ../ltl2tgba -t -XL out6 > out7
s7=`wc -l < out7`
test "$s" -eq "$s7"
run 0 ../../bin/autfilt --lbtt out6 > out7
run 0 ../../bin/autfilt out6 --are-isomorphic out7
done
# This is the output of 'lbt' on the formula 'U p0 p1'.
cat >Up0p1 <<EOF
# multiple inputs (from different tools)
cat >input <<EOF
/* This is the output of 'lbt' on the formula 'U p0 p1'. */
4 1
0 1 -1
1 p0
@ -79,16 +75,8 @@ cat >Up0p1 <<EOF
3 0 0 -1
3 t
-1
EOF
run 0 ../ltl2tgba -ks -XL Up0p1 > size
test "`cat size | sed -n 's/states: //p'`" = 4
test "`cat size | sed -n 's/transitions: //p'`" = 6
# This kind of output is returned by wring2lbtt, on the same formula.
# (Newer versions of LBTT reject this input with missing new lines.)
cat >wring2lbtt <<EOF
/* This kind of output is returned by wring2lbtt, on the same formula.
(Newer versions of LBTT reject this input with missing new lines.) */
4 1 0 1 -1 1 p0
2 p1
-1 1 0 -1 1 p0
@ -96,15 +84,12 @@ cat >wring2lbtt <<EOF
-1 2 0 0 -1 3 t
-1 3 0 0 -1 3 t
-1
EOF
run 0 ../ltl2tgba -ks -XL wring2lbtt > size
test "`cat size | sed -n 's/states: //p'`" = 4
test "`cat size | sed -n 's/transitions: //p'`" = 6
# Another example from wring2lbtt (or modella), showing that the
# acceptance set of the state is not always numbered from 0.
cat >wring2lbtt2 <<EOF
/* This is an automaton without state and three acceptance sets.
Spot is not able to deal with automata that do not have initial
state, so it will add a dummy state. */
0 3
/* Another example from wring2lbtt (or modella), showing that the
acceptance set of the states is not always numbered from 0. */
6 1 0 1 -1 1 | & ! p0 ! p1 & p0 ! p1
2 & ! p0 ! p1
3 | & p0 p1 & ! p0 p1
@ -117,6 +102,12 @@ cat >wring2lbtt2 <<EOF
-1
EOF
run 0 ../ltl2tgba -ks -XL wring2lbtt2 > size
test "`cat size | sed -n 's/states: //p'`" = 6
test "`cat size | sed -n 's/transitions: //p'`" = 9
run 0 ../../bin/autfilt --stats '%s %t %e %a' input > output
cat >expected<<EOF
4 16 6 1
4 16 6 1
1 0 0 3
6 20 9 1
EOF
diff output expected