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
|
|
@ -24,9 +24,11 @@
|
|||
#include <fstream>
|
||||
|
||||
#define OPT_LBT 1
|
||||
#define OPT_LENIENT 2
|
||||
|
||||
jobs_t jobs;
|
||||
bool lbt_input = false;
|
||||
static bool lenient = false;
|
||||
|
||||
static const argp_option options[] =
|
||||
{
|
||||
|
|
@ -36,6 +38,9 @@ static const argp_option options[] =
|
|||
"process each line of FILENAME as a formula", 0 },
|
||||
{ "lbt-input", OPT_LBT, 0, 0,
|
||||
"read all formulas using LBT's prefix syntax", 0 },
|
||||
{ "lenient", OPT_LENIENT, 0, 0,
|
||||
"parenthesized blocks that cannot be parsed as subformulas "
|
||||
"are considered as atomic properties", 0 },
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
|
@ -56,6 +61,9 @@ parse_opt_finput(int key, char* arg, struct argp_state*)
|
|||
case OPT_LBT:
|
||||
lbt_input = true;
|
||||
break;
|
||||
case OPT_LENIENT:
|
||||
lenient = true;
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
|
@ -68,7 +76,9 @@ parse_formula(const std::string& s, spot::ltl::parse_error_list& pel)
|
|||
if (lbt_input)
|
||||
return spot::ltl::parse_lbt(s, pel);
|
||||
else
|
||||
return spot::ltl::parse(s, pel);
|
||||
return spot::ltl::parse(s, pel,
|
||||
spot::ltl::default_environment::instance(),
|
||||
false, lenient);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue