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

@ -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