ltlparse: add a lenient parsing mode
Spin 6 supports formulas such as []<>(a < b) so that atomic properties
need not be specified using #define. Of course we don't want to
implement all the syntax of Spin in our LTL parser because other tools
may have different syntaxes for their atomic propositions. The
lenient mode tells the scanner to return any (...), {...}, or {...}!
block as a single token. The parser will try to recursively parse
this block as a LTL/SERE formula, and if this fails, it will consider
the block to be an atomic proposition. The drawback is that most
syntax errors will no be considered to be atomic propositions. For
instance (a U b U) is a single atomic proposition in lenient mode, and
a syntax error in default mode.
* src/ltlparse/ltlparse.yy, src/ltlparse/ltlscan.ll,
src/ltlparse/parsedecl.hh, src/ltlparse/public.hh: Add a
lenient parsing mode. Simplify the lexer using yy_scan_string.
* src/bin/common_finput.cc: Add a --lenient option.
* src/ltltest/lenient.test: New file.
* src/ltltest/Makefile.am: Add it.
* src/neverparse/neverclaimparse.yy: Parse the guards in lenient mode.
* src/tgbatest/neverclaimread.test: Adjust.
* src/ltlvisit/tostring.cc: When outputing a formula in Spin's syntax,
output (a < b) instead of "a < b".
* src/misc/escape.cc, src/misc/escape.hh (trim): New helper function.
This commit is contained in:
parent
d9ceb4adc4
commit
86dac4aadf
12 changed files with 355 additions and 60 deletions
|
|
@ -86,10 +86,14 @@ skip
|
|||
}
|
||||
EOF
|
||||
|
||||
# We used to catch the following error:
|
||||
# input:5.11: syntax error, unexpected closing parenthesis
|
||||
# input:5.8-9: missing right operand for "and operator"
|
||||
# but since the guard parser is more lenient, we just assume
|
||||
# that "p1 && " is an atomic property.
|
||||
|
||||
run 2 ../ltl2tgba -XN input > stdout 2>stderr
|
||||
cat >expected <<EOF
|
||||
input:5.11: syntax error, unexpected closing parenthesis
|
||||
input:5.8-9: missing right operand for "and operator"
|
||||
input:9.16: syntax error, unexpected closing parenthesis
|
||||
input:9.16: ignoring trailing garbage
|
||||
EOF
|
||||
|
|
@ -98,24 +102,33 @@ diff stderrfilt expected
|
|||
|
||||
cat >formulae<<EOF
|
||||
a
|
||||
<>[] a
|
||||
FG a
|
||||
X false
|
||||
([] a) U X b
|
||||
(G a) U X b
|
||||
(a U b) U (c U d)
|
||||
true
|
||||
([]a && XXXX!a)
|
||||
(Ga && XXXX!a)
|
||||
"a > b" U "process@foo"
|
||||
GF("(a + b) == 42" U "process@foo")
|
||||
EOF
|
||||
while read f
|
||||
do
|
||||
run 0 ../ltl2tgba -b -f "!($f)" > f.tgba
|
||||
sf=`../../bin/ltlfilt -sf "$f"`
|
||||
if test -n "$SPIN"; then
|
||||
$SPIN -f "$f" > f.spin
|
||||
run 0 ../ltl2tgba -E -Pf.tgba -XN f.spin
|
||||
fi
|
||||
if test -n "$LTL2BA"; then
|
||||
$LTL2BA -f "$f" > f.ltl2ba
|
||||
run 0 ../ltl2tgba -E -Pf.tgba -XN f.ltl2ba
|
||||
# Old spin versions cannot parse formulas such as ((a + b) == 42).
|
||||
if $SPIN -f "$sf" > f.spin; then
|
||||
run 0 ../ltl2tgba -E -Pf.tgba -XN f.spin
|
||||
fi
|
||||
fi
|
||||
case $f in
|
||||
*\"*);;
|
||||
*)
|
||||
if test -n "$LTL2BA"; then
|
||||
$LTL2BA -f "$sf" > f.ltl2ba
|
||||
run 0 ../ltl2tgba -E -Pf.tgba -XN f.ltl2ba
|
||||
fi
|
||||
esac
|
||||
run 0 ../ltl2tgba -DS -NN -f "$f" > f.spot
|
||||
# Make sure there is no `!x' occurring in the
|
||||
# output. Because `x' is usually #define'd, we
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue