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:
Alexandre Duret-Lutz 2012-10-16 19:29:40 +02:00
parent d9ceb4adc4
commit 86dac4aadf
12 changed files with 355 additions and 60 deletions

View file

@ -201,7 +201,9 @@ transition:
else
{
spot::ltl::parse_error_list pel;
const spot::ltl::formula* f = spot::ltl::parse(*$3, pel);
const spot::ltl::formula* f = spot::ltl::parse(*$3, pel,
parse_environment,
false, true);
delete $3;
for(spot::ltl::parse_error_list::const_iterator i = pel.begin();
i != pel.end(); ++i)