Make sure the neverclaim parser works on the output of spin and
ltl2ba. * src/neverparse/neverclaimparse.yy: Accept multiple labels for the same state. Honor accepting states. Forward parse error from the parser used for guards. Accept "false" as a single instruction for a state. * src/neverparse/neverclaimscan.ll: Recognize "false" specifically, and remove the ";" hack. * src/tgba/tgbaexplicit.cc (tgba_explicit_string::~tgba_explicit_string): Adjust not to destroy a state twice. * src/tgba/tgbaexplicit.hh (tgba_explicit_string::add_state_alias): New function. * src/tgbatest/defs.in (SPIN, LTL2BA): New variables. * src/tgbatest/neverclaimread.test: Check error messages for syntax errors in guards. Make sure we can read the output of `spin -f' and `ltl2ba -f' on a few test formulae.
This commit is contained in:
parent
ac08c5abce
commit
fe1f59cd30
7 changed files with 173 additions and 43 deletions
21
ChangeLog
21
ChangeLog
|
|
@ -1,3 +1,24 @@
|
||||||
|
2010-11-06 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
|
Make sure the neverclaim parser works on the output of spin and
|
||||||
|
ltl2ba.
|
||||||
|
|
||||||
|
* src/neverparse/neverclaimparse.yy: Accept multiple labels
|
||||||
|
for the same state. Honor accepting states. Forward parse
|
||||||
|
error from the parser used for guards. Accept "false" as a
|
||||||
|
single instruction for a state.
|
||||||
|
* src/neverparse/neverclaimscan.ll: Recognize "false" specifically,
|
||||||
|
and remove the ";" hack.
|
||||||
|
* src/tgba/tgbaexplicit.cc
|
||||||
|
(tgba_explicit_string::~tgba_explicit_string): Adjust not to
|
||||||
|
destroy a state twice.
|
||||||
|
* src/tgba/tgbaexplicit.hh
|
||||||
|
(tgba_explicit_string::add_state_alias): New function.
|
||||||
|
* src/tgbatest/defs.in (SPIN, LTL2BA): New variables.
|
||||||
|
* src/tgbatest/neverclaimread.test: Check error messages for
|
||||||
|
syntax errors in guards. Make sure we can read the output
|
||||||
|
of `spin -f' and `ltl2ba -f' on a few test formulae.
|
||||||
|
|
||||||
2010-11-06 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
2010-11-06 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
Cleanup neverclaim support.
|
Cleanup neverclaim support.
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,11 @@
|
||||||
%code requires
|
%code requires
|
||||||
{
|
{
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <cstring>
|
||||||
|
#include "ltlast/constant.hh"
|
||||||
#include "public.hh"
|
#include "public.hh"
|
||||||
typedef std::pair<std::string*, std::string*> pair;
|
|
||||||
|
typedef std::pair<spot::ltl::formula*, std::string*> pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
%parse-param {spot::neverclaim_parse_error_list& error_list}
|
%parse-param {spot::neverclaim_parse_error_list& error_list}
|
||||||
|
|
@ -65,18 +68,22 @@ using namespace spot::ltl;
|
||||||
%token FI "fi"
|
%token FI "fi"
|
||||||
%token ARROW "->"
|
%token ARROW "->"
|
||||||
%token GOTO "goto"
|
%token GOTO "goto"
|
||||||
%token <str> FORMULA
|
%token FALSE "false"
|
||||||
%token <str> IDENT
|
%token <str> FORMULA "boolean formula"
|
||||||
|
%token <str> IDENT "identifier"
|
||||||
|
%type <str> formula
|
||||||
%type <p> transition
|
%type <p> transition
|
||||||
%type <list> transitions
|
%type <list> transitions
|
||||||
|
%type <str> ident_list
|
||||||
|
|
||||||
|
|
||||||
%destructor { delete $$; } <str>
|
%destructor { delete $$; } <str>
|
||||||
%destructor { delete $$->first; delete $$->second; delete $$; } <p>
|
%destructor { $$->first->destroy(); delete $$->second; delete $$; } <p>
|
||||||
%destructor {
|
%destructor {
|
||||||
for (std::list<pair>::iterator i = $$->begin();
|
for (std::list<pair>::iterator i = $$->begin();
|
||||||
i != $$->end(); ++i)
|
i != $$->end(); ++i)
|
||||||
{
|
{
|
||||||
delete i->first;
|
i->first->destroy();
|
||||||
delete i->second;
|
delete i->second;
|
||||||
}
|
}
|
||||||
delete $$;
|
delete $$;
|
||||||
|
|
@ -86,42 +93,60 @@ using namespace spot::ltl;
|
||||||
%%
|
%%
|
||||||
neverclaim:
|
neverclaim:
|
||||||
"never" '{' states '}'
|
"never" '{' states '}'
|
||||||
;
|
|
||||||
|
|
||||||
states:
|
states:
|
||||||
/* empty */
|
/* empty */
|
||||||
| state states
|
| state
|
||||||
;
|
| states ';' state
|
||||||
|
| states ';'
|
||||||
|
|
||||||
|
ident_list:
|
||||||
|
IDENT ':'
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
|
| ident_list IDENT ':'
|
||||||
|
{
|
||||||
|
result->add_state_alias(*$2, *$1);
|
||||||
|
delete $1;
|
||||||
|
$$ = $2;
|
||||||
|
}
|
||||||
|
|
||||||
state:
|
state:
|
||||||
IDENT ':' "skip"
|
ident_list "skip"
|
||||||
{
|
{
|
||||||
result->create_transition(*$1, *$1);
|
spot::tgba_explicit::transition* t = result->create_transition(*$1, *$1);
|
||||||
|
bool acc = !strncmp("accept", $1->c_str(), 6);
|
||||||
|
if (acc)
|
||||||
|
result->add_acceptance_condition(t,
|
||||||
|
spot::ltl::constant::true_instance());
|
||||||
delete $1;
|
delete $1;
|
||||||
}
|
}
|
||||||
| IDENT ':' { delete $1; }
|
| ident_list { delete $1; }
|
||||||
| IDENT ':' "if" transitions "fi"
|
| ident_list "false" { delete $1; }
|
||||||
|
| ident_list "if" transitions "fi"
|
||||||
{
|
{
|
||||||
std::list<pair>::iterator it;
|
std::list<pair>::iterator it;
|
||||||
for (it = $4->begin(); it != $4->end(); ++it)
|
bool acc = !strncmp("accept", $1->c_str(), 6);
|
||||||
|
for (it = $3->begin(); it != $3->end(); ++it)
|
||||||
{
|
{
|
||||||
spot::tgba_explicit::transition* t =
|
spot::tgba_explicit::transition* t =
|
||||||
result->create_transition(*$1,*it->second);
|
result->create_transition(*$1,*it->second);
|
||||||
spot::ltl::parse_error_list pel;
|
|
||||||
spot::ltl::formula* f = spot::ltl::parse(*(it->first), pel);
|
result->add_condition(t, it->first);
|
||||||
result->add_condition(t, f);
|
if (acc)
|
||||||
|
result
|
||||||
|
->add_acceptance_condition(t, spot::ltl::constant::true_instance());
|
||||||
}
|
}
|
||||||
// Free the list
|
// Free the list
|
||||||
delete $1;
|
delete $1;
|
||||||
for (std::list<pair>::iterator it = $4->begin();
|
for (std::list<pair>::iterator it = $3->begin();
|
||||||
it != $4->end(); ++it)
|
it != $3->end(); ++it)
|
||||||
{
|
|
||||||
delete it->first;
|
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
delete $3;
|
||||||
delete $4;
|
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
transitions:
|
transitions:
|
||||||
/* empty */ { $$ = new std::list<pair>; }
|
/* empty */ { $$ = new std::list<pair>; }
|
||||||
|
|
@ -131,12 +156,29 @@ transitions:
|
||||||
delete $1;
|
delete $1;
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
|
formula: FORMULA | "false" { $$ = new std::string("0"); }
|
||||||
|
|
||||||
transition:
|
transition:
|
||||||
':' ':' FORMULA "->" "goto" IDENT
|
':' ':' formula "->" "goto" IDENT
|
||||||
{
|
{
|
||||||
$$ = new pair($3, $6);
|
spot::ltl::parse_error_list pel;
|
||||||
|
spot::ltl::formula* f = spot::ltl::parse(*$3, pel);
|
||||||
|
delete $3;
|
||||||
|
for(spot::ltl::parse_error_list::const_iterator i = pel.begin();
|
||||||
|
i != pel.end(); ++i)
|
||||||
|
{
|
||||||
|
// Adjust the diagnostic to the current position.
|
||||||
|
location here = @3;
|
||||||
|
here.end.line = here.begin.line + i->first.end.line - 1;
|
||||||
|
here.end.column = here.begin.column + i->first.end.column -1;
|
||||||
|
here.begin.line += i->first.begin.line - 1;
|
||||||
|
here.begin.column += i->first.begin.column - 1;
|
||||||
|
error(here, i->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
$$ = new pair(f, $6);
|
||||||
}
|
}
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|
@ -164,11 +206,11 @@ namespace spot
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
tgba_explicit_string* result = new tgba_explicit_string(dict);
|
tgba_explicit_string* result = new tgba_explicit_string(dict);
|
||||||
|
result->declare_acceptance_condition(spot::ltl::constant::true_instance());
|
||||||
neverclaimyy::parser parser(error_list, env, result);
|
neverclaimyy::parser parser(error_list, env, result);
|
||||||
parser.set_debug_level(debug);
|
parser.set_debug_level(debug);
|
||||||
parser.parse();
|
parser.parse();
|
||||||
neverclaimyyclose();
|
neverclaimyyclose();
|
||||||
result->merge_transitions();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,17 +49,17 @@ eol \n|\r|\n\r|\r\n
|
||||||
"/*".*"*/" yylloc->step();
|
"/*".*"*/" yylloc->step();
|
||||||
|
|
||||||
"never" return token::NEVER;
|
"never" return token::NEVER;
|
||||||
"skip"|"skip;" return token::SKIP;
|
"skip" return token::SKIP;
|
||||||
"if" return token::IF;
|
"if" return token::IF;
|
||||||
"fi"|"fi;" return token::FI;
|
"fi" return token::FI;
|
||||||
"->" return token::ARROW;
|
"->" return token::ARROW;
|
||||||
"goto" return token::GOTO;
|
"goto" return token::GOTO;
|
||||||
|
"false"|"0" return token::FALSE;
|
||||||
|
|
||||||
"(".*")"|"true"|"1"|"false"|"0" {
|
"(".*")"|"true"|"1" {
|
||||||
yylval->str =
|
yylval->str = new std::string(yytext, yyleng);
|
||||||
new std::string(yytext, yyleng);
|
return token::FORMULA;
|
||||||
return token::FORMULA;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[a-zA-Z][a-zA-Z0-9_]* {
|
[a-zA-Z][a-zA-Z0-9_]* {
|
||||||
yylval->str = new std::string(yytext, yyleng);
|
yylval->str = new std::string(yytext, yyleng);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2009 Laboratoire de Recherche et Développement
|
// Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
||||||
// de l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
|
|
@ -291,10 +291,14 @@ namespace spot
|
||||||
ns_map::iterator i;
|
ns_map::iterator i;
|
||||||
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
for (i = name_state_map_.begin(); i != name_state_map_.end(); ++i)
|
||||||
{
|
{
|
||||||
tgba_explicit::state::iterator i2;
|
// Do not erase the same state twice. (Because of possible aliases.)
|
||||||
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
|
if (state_name_map_.erase(i->second))
|
||||||
delete *i2;
|
{
|
||||||
delete i->second;
|
tgba_explicit::state::iterator i2;
|
||||||
|
for (i2 = i->second->begin(); i2 != i->second->end(); ++i2)
|
||||||
|
delete *i2;
|
||||||
|
delete i->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2009 Laboratoire de Recherche et Développement
|
// Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
||||||
// de l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
// Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de
|
// Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de
|
||||||
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||||
|
|
@ -212,7 +212,7 @@ namespace spot
|
||||||
}
|
}
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
state*
|
state*
|
||||||
set_init_state(const label& state)
|
set_init_state(const label& state)
|
||||||
{
|
{
|
||||||
|
|
@ -323,6 +323,15 @@ namespace spot
|
||||||
virtual ~tgba_explicit_string();
|
virtual ~tgba_explicit_string();
|
||||||
virtual state* add_default_init();
|
virtual state* add_default_init();
|
||||||
virtual std::string format_state(const spot::state* s) const;
|
virtual std::string format_state(const spot::state* s) const;
|
||||||
|
|
||||||
|
/// Create an alias for a state. Any reference to \a alias_name
|
||||||
|
/// will act as a reference to \a real_name.
|
||||||
|
virtual
|
||||||
|
void add_state_alias(const std::string& alias_name,
|
||||||
|
const std::string& real_name)
|
||||||
|
{
|
||||||
|
name_state_map_[alias_name] = add_state(real_name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class tgba_explicit_formula:
|
class tgba_explicit_formula:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- shell-script -*-
|
# -*- shell-script -*-
|
||||||
# Copyright (C) 2009 Laboratoire de Recherche et Développement
|
# Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
||||||
# de l'Epita (LRDE).
|
# de l'Epita (LRDE).
|
||||||
# Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris 6 (LIP6),
|
# Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
|
|
@ -65,6 +65,8 @@ top_builddir='../@top_builddir@'
|
||||||
LBTT="@LBTT@"
|
LBTT="@LBTT@"
|
||||||
LBTT_TRANSLATE="@LBTT_TRANSLATE@"
|
LBTT_TRANSLATE="@LBTT_TRANSLATE@"
|
||||||
VALGRIND='@VALGRIND@'
|
VALGRIND='@VALGRIND@'
|
||||||
|
SPIN='@SPIN@'
|
||||||
|
LTL2BA='@LTL2BA@'
|
||||||
|
|
||||||
run()
|
run()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ digraph G {
|
||||||
2 -> 2 [label="p1\n"]
|
2 -> 2 [label="p1\n"]
|
||||||
2 -> 3 [label="p1 & !p0\n"]
|
2 -> 3 [label="p1 & !p0\n"]
|
||||||
3 [label="accept_all"]
|
3 [label="accept_all"]
|
||||||
3 -> 3 [label="1\n"]
|
3 -> 3 [label="1\n{Acc[1]}"]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
@ -65,3 +65,55 @@ sed -e 's/!p0 & p1/p1 \& !p0/g' -e 's/p1 & p0/p0 \& p1/g' stdout \
|
||||||
diff stdout expected
|
diff stdout expected
|
||||||
|
|
||||||
rm input stdout expected
|
rm input stdout expected
|
||||||
|
|
||||||
|
|
||||||
|
# Test broken guards in input
|
||||||
|
cat >input <<EOF
|
||||||
|
never {
|
||||||
|
T2_init:
|
||||||
|
if
|
||||||
|
:: (1) -> goto T2_init
|
||||||
|
:: (p1 && ) -> goto T1
|
||||||
|
fi;
|
||||||
|
T1:
|
||||||
|
if
|
||||||
|
:: (p1 && ! p0)) -> goto accept_all
|
||||||
|
:: (p1) -> goto T1
|
||||||
|
fi;
|
||||||
|
accept_all:
|
||||||
|
skip
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
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
|
||||||
|
grep input: stderr >> stderrfilt
|
||||||
|
diff stderrfilt expected
|
||||||
|
|
||||||
|
# Skip the rest of this test if neither Spin nor ltl2ba are installed.
|
||||||
|
test -n "$SPIN$LTL2BA" || exit
|
||||||
|
|
||||||
|
cat >formulae<<EOF
|
||||||
|
a
|
||||||
|
<>[] a
|
||||||
|
X false
|
||||||
|
([] a) U X b
|
||||||
|
(a U b) U (c U d)
|
||||||
|
EOF
|
||||||
|
while read f
|
||||||
|
do
|
||||||
|
run 0 ../ltl2tgba -b -f "!($f)" > f.tgba
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
done <formulae
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue