hoa: make the parser more resilient to errors

* src/hoaparse/hoaparse.yy: Improve error recovery,
and fix location tracking in streams.
* src/hoaparse/public.hh: Store the last location so
that the next parse start at the correct position.
* src/bin/autfilt.cc: Stop parsing a stream on irrecoverable errors.
* src/tgbatest/hoaparse.test: Adjust tests.
This commit is contained in:
Alexandre Duret-Lutz 2014-11-20 12:29:18 +01:00
parent 392c527d31
commit 1d962f79ac
4 changed files with 152 additions and 80 deletions

View file

@ -26,7 +26,7 @@ set -e
expecterr()
{
cat >$1.exp
../ltl2tgba -XH $1 2>$1.err && exit 1
../../bin/autfilt $1 2>$1.err && exit 1
test $? = 2
cat $1.err
diff $1.err $1.exp
@ -100,8 +100,8 @@ Acceptance: 0 t
EOF
expecterr input <<EOF
input:4.1-3: redeclaration of APs...
input:2.1-5: ... previously defined here.
input:4.1-3: ignoring this redeclaration of APs...
input:2.1-5: ... previously declared here.
EOF
cat >input <<EOF
@ -110,6 +110,8 @@ AP: 1 "a"
States: 0
Start: 1
--BODY--
State: 0 {0 1}
[0] 0 {0}
--END--
EOF
@ -117,13 +119,18 @@ expecterr input <<EOF
input:4.8: state number is larger than state count...
input:3.1-9: ... declared here.
input:1.1-4.8: missing 'Acceptance:' header
input:6.8: state number is larger than state count...
input:3.1-9: ... declared here.
input:6.10-14: ignoring acceptance sets because of missing acceptance condition
input:7.5: state number is larger than state count...
input:3.1-9: ... declared here.
EOF
cat >input <<EOF
HOA: v1
AP: 1 "a"
Start: 0
States: 0
Start: 1
States: 1
--BODY--
--END--
EOF
@ -131,6 +138,7 @@ EOF
expecterr input <<EOF
input:3.1-8: initial state number is larger than state count...
input:4.1-9: ... declared here.
input:1.1-4.9: missing 'Acceptance:' header
EOF
cat >input <<EOF
@ -144,7 +152,7 @@ Acceptance: 1 Inf(0)
EOF
expecterr input <<EOF
input:5.1-13: redefinition of the acceptance condition...
input:5.1-13: ignoring this redefinition of the acceptance condition...
input:2.1-13: ... previously defined here.
EOF
@ -179,20 +187,14 @@ State: 0 {0}
State: 1 {0}
[t] 1
--END--
EOF
expecterr input <<EOF
input:5.19: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
EOF
cat >input <<EOF
HOA: v2
--BODY--
--END--
EOF
expecterr input <<EOF
input:1.1-7: unsupported version of the HOA format
input:1.1-7: missing 'Acceptance:' header
input:5.19: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
input:12.1-7: unsupported version of the HOA format
input:12.1-7: missing 'Acceptance:' header
EOF