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:
parent
e4158c21ee
commit
6eb2b06fa7
5 changed files with 340 additions and 72 deletions
|
|
@ -74,6 +74,14 @@ State: 0 {0}
|
|||
State: 1 {0}
|
||||
[t] 1
|
||||
--END--
|
||||
2 1t
|
||||
2 1
|
||||
1 -1 "b"
|
||||
0 -1 & "a" ! "b"
|
||||
-1
|
||||
1 0
|
||||
2 0 -1 t
|
||||
-1
|
||||
EOF
|
||||
|
||||
expecterr input <<EOF
|
||||
|
|
@ -83,6 +91,10 @@ input:9.8: state number is larger than state count...
|
|||
input:2.1-9: ... declared here.
|
||||
input:10.5: state number is larger than state count...
|
||||
input:2.1-9: ... declared here.
|
||||
input:13.1: state number is larger than state count...
|
||||
input:12.1: ... declared here.
|
||||
input:18.1: state number is larger than state count...
|
||||
input:12.1: ... declared here.
|
||||
EOF
|
||||
|
||||
cat >input <<EOF
|
||||
|
|
@ -482,7 +494,7 @@ EOF
|
|||
diff expected input.out
|
||||
|
||||
|
||||
# Mix HOA with neverclaims
|
||||
# Mix HOA with neverclaims and LBTT automata
|
||||
cat >input <<EOF
|
||||
HOA: v1
|
||||
States: 2
|
||||
|
|
@ -500,6 +512,29 @@ State: 1
|
|||
[0] 0
|
||||
--END--
|
||||
|
||||
/* some LBTT with mixed state/transition acceptance,
|
||||
just because we can */
|
||||
4 2ts
|
||||
0 1 -1
|
||||
1 -1 "c"
|
||||
2 -1 & "b" ! "c"
|
||||
3 -1 ! "c"
|
||||
-1
|
||||
1 0 1 -1
|
||||
1 0 -1 t
|
||||
-1
|
||||
2 0 -1
|
||||
1 -1 "c"
|
||||
2 -1 & "b" ! "c"
|
||||
-1
|
||||
3 0 -1
|
||||
3 0 1 -1 & "a" "b"
|
||||
3 1 -1 & "a" ! "b"
|
||||
3 0 -1 & ! "a" "b"
|
||||
3 -1 & ! "a" ! "b"
|
||||
-1
|
||||
|
||||
|
||||
never { /* a U b */
|
||||
T0_init:
|
||||
if
|
||||
|
|
@ -539,6 +574,29 @@ State: 2 {0}
|
|||
[!1] 2
|
||||
--END--
|
||||
HOA: v1
|
||||
States: 4
|
||||
Start: 0
|
||||
AP: 3 "c" "b" "a"
|
||||
acc-name: generalized-Buchi 2
|
||||
Acceptance: 2 Inf(0)&Inf(1)
|
||||
properties: trans-labels explicit-labels trans-acc
|
||||
--BODY--
|
||||
State: 0
|
||||
[0] 1
|
||||
[!0&1] 2
|
||||
[!0] 3
|
||||
State: 1
|
||||
[t] 1 {0 1}
|
||||
State: 2
|
||||
[0] 1
|
||||
[!0&1] 2
|
||||
State: 3
|
||||
[1&2] 3 {0 1}
|
||||
[!1&2] 3 {0}
|
||||
[1&!2] 3 {1}
|
||||
[!1&!2] 3
|
||||
--END--
|
||||
HOA: v1
|
||||
States: 2
|
||||
Start: 0
|
||||
AP: 2 "b" "a"
|
||||
|
|
@ -722,16 +780,17 @@ and even more garbage
|
|||
EOF
|
||||
|
||||
se='syntax error, unexpected' # this is just to keep lines short
|
||||
end='end of file or HOA: or never or LBTT header'
|
||||
expecterr input <<EOF
|
||||
input:8.11: $se identifier, expecting integer or '}'
|
||||
input:8.10-12: ignoring this invalid acceptance set
|
||||
input:11.2: $se identifier
|
||||
input:11.1-3: ignoring this invalid label
|
||||
input:21.5-7: $se string, expecting integer
|
||||
input:25.1: $se \$undefined, expecting end of file or HOA: or never
|
||||
input:25.1: $se \$undefined, expecting $end
|
||||
input:25.1-12: ignoring leading garbage
|
||||
input:32.1-5: $se header name, expecting --END-- or State:
|
||||
input:37.1: $se 't', expecting end of file or HOA: or never
|
||||
input:37.1: $se 't', expecting $end
|
||||
autfilt: failed to read automaton from input
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue