extend HOA I/O to preserve the state-player property
* spot/parseaut/parseaut.yy, spot/parseaut/scanaut.ll, spot/twaalgos/hoa.cc: Add input and output support. * doc/org/hoa.org: Document the HOA extension. * bin/ltlsynt.cc: Add a --print-game-hoa option to produce such format. * tests/core/gamehoa.test: New file to test this. * tests/Makefile.am: Add it. * NEWS: Mention this new feature.
This commit is contained in:
parent
25c75c55b1
commit
ea9384dd4b
8 changed files with 209 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/* -*- coding: utf-8 -*-
|
||||
** Copyright (C) 2014-2019 Laboratoire de Recherche et Développement
|
||||
** Copyright (C) 2014-2020 Laboratoire de Recherche et Développement
|
||||
** de l'Epita (LRDE).
|
||||
**
|
||||
** This file is part of Spot, a model checking library.
|
||||
|
|
@ -138,6 +138,8 @@ extern "C" int strverscmp(const char *s1, const char *s2);
|
|||
std::map<unsigned, unsigned>* highlight_edges = nullptr;
|
||||
std::map<unsigned, unsigned>* highlight_states = nullptr;
|
||||
std::map<unsigned, unsigned> states_map;
|
||||
std::vector<bool>* state_player = nullptr;
|
||||
spot::location state_player_loc;
|
||||
std::set<int> ap_set;
|
||||
unsigned cur_state;
|
||||
int states = -1;
|
||||
|
|
@ -238,6 +240,7 @@ extern "C" int strverscmp(const char *s1, const char *s2);
|
|||
%token STATE "State:";
|
||||
%token SPOT_HIGHLIGHT_EDGES "spot.highlight.edges:";
|
||||
%token SPOT_HIGHLIGHT_STATES "spot.highlight.states:";
|
||||
%token SPOT_STATE_PLAYER "spot.state-player:";
|
||||
%token <str> IDENTIFIER "identifier"; // also used by neverclaim
|
||||
%token <str> HEADERNAME "header name";
|
||||
%token <str> ANAME "alias name";
|
||||
|
|
@ -822,6 +825,15 @@ header-item: "States:" INT
|
|||
| "spot.highlight.states:"
|
||||
{ res.highlight_states = new std::map<unsigned, unsigned>; }
|
||||
highlight-states
|
||||
| "spot.state-player:"
|
||||
{ auto p = new std::vector<bool>;
|
||||
if (res.states >= 0)
|
||||
p->reserve(res.states);
|
||||
res.state_player = p;
|
||||
} state-player
|
||||
{
|
||||
res.state_player_loc = @$;
|
||||
}
|
||||
| HEADERNAME header-spec
|
||||
{
|
||||
char c = (*$1)[0];
|
||||
|
|
@ -918,6 +930,14 @@ highlight-states: %empty
|
|||
res.highlight_states->emplace($2, $3);
|
||||
}
|
||||
|
||||
state-player: %empty
|
||||
| state-player INT
|
||||
{
|
||||
if ($2 != 0 && $2 != 1)
|
||||
error(@2, "player should be 0 or 1");
|
||||
res.state_player->emplace_back($2);
|
||||
}
|
||||
|
||||
header-spec: %empty
|
||||
| header-spec BOOLEAN
|
||||
| header-spec INT
|
||||
|
|
@ -1196,6 +1216,16 @@ body: states
|
|||
"environment variable.");
|
||||
det_warned = true;
|
||||
}
|
||||
if (res.state_player)
|
||||
if (unsigned spsz = res.state_player->size(); spsz != n)
|
||||
{
|
||||
error(res.state_player_loc,
|
||||
"ignoring state-player header because it has "s
|
||||
+ std::to_string(spsz) + " entries while automaton has "
|
||||
+ std::to_string(n) + " states");
|
||||
delete res.state_player;
|
||||
res.state_player = nullptr;
|
||||
}
|
||||
}
|
||||
state-num: INT
|
||||
{
|
||||
|
|
@ -2621,6 +2651,8 @@ namespace spot
|
|||
r.aut_or_ks->set_named_prop("highlight-edges", r.highlight_edges);
|
||||
if (r.highlight_states)
|
||||
r.aut_or_ks->set_named_prop("highlight-states", r.highlight_states);
|
||||
if (r.state_player)
|
||||
r.aut_or_ks->set_named_prop("state-player", r.state_player);
|
||||
fix_acceptance(r);
|
||||
fix_initial_state(r);
|
||||
fix_properties(r);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* -*- coding: utf-8 -*-
|
||||
** Copyright (C) 2014-2018 Laboratoire de Recherche et Développement
|
||||
** Copyright (C) 2014-2018, 2020 Laboratoire de Recherche et Développement
|
||||
** de l'Epita (LRDE).
|
||||
**
|
||||
** This file is part of Spot, a model checking library.
|
||||
|
|
@ -129,6 +129,7 @@ identifier [[:alpha:]_][[:alnum:]_.-]*
|
|||
"properties:" return token::PROPERTIES;
|
||||
"spot.highlight.states:" return token::SPOT_HIGHLIGHT_STATES;
|
||||
"spot.highlight.edges:" return token::SPOT_HIGHLIGHT_EDGES;
|
||||
"spot"[.-]"state-player:" return token::SPOT_STATE_PLAYER;
|
||||
"--BODY--" return token::BODY;
|
||||
"--END--" BEGIN(INITIAL); return token::END;
|
||||
"State:" return token::STATE;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2014-2019 Laboratoire de Recherche et
|
||||
// Copyright (C) 2014-2020 Laboratoire de Recherche et
|
||||
// Developpement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -609,6 +609,24 @@ namespace spot
|
|||
os << (v1_1 ? "spot." : "spot-") << "rejected-word: \"";
|
||||
escape_str(os, *word) << '"' << nl;
|
||||
}
|
||||
if (auto player = aut->get_named_prop<std::vector<bool>>("state-player"))
|
||||
{
|
||||
os << (v1_1 ? "spot." : "spot-") << "state-player:";
|
||||
if (player->size() != num_states)
|
||||
throw std::runtime_error("print_hoa(): state-player property has"
|
||||
" (" + std::to_string(player->size()) +
|
||||
" states but automaton has " +
|
||||
std::to_string(num_states));
|
||||
unsigned n = 0;
|
||||
while (n < num_states)
|
||||
{
|
||||
os << ' ' << (*player)[n];
|
||||
++n;
|
||||
if (newline && n < num_states && (n % 30 == 0))
|
||||
os << "\n ";
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
|
||||
// If we want to output implicit labels, we have to
|
||||
// fill a vector with all destinations in order.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue