tl: add support for X[n], F[n:m] and G[n:m]

* NEWS, doc/tl/tl.tex, doc/tl/tl.bib: Document these new operators.
* spot/parsetl/parsetl.yy, spot/parsetl/scantl.ll: Parse those.
* spot/tl/formula.cc, spot/tl/formula.hh: Add constructors.
* spot/gen/formulas.cc: Use it.
* tests/core/sugar.test: New file.
* tests/Makefile.am: Add it.
This commit is contained in:
Alexandre Duret-Lutz 2018-07-05 17:29:25 +02:00
parent 2616ea7c80
commit e7aa334a71
10 changed files with 364 additions and 12 deletions

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2015, 2016, 2017 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
// Copyright (C) 2015-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -155,6 +155,10 @@ namespace spot
static const fnode* bunop(op o, const fnode* f,
uint8_t min, uint8_t max = unbounded());
/// \see formula::nested_unop_range
static const fnode* nested_unop_range(op uo, op bo, unsigned min,
unsigned max, const fnode* f);
/// \see formula::kind
op kind() const
{
@ -887,11 +891,39 @@ namespace spot
SPOT_DEF_UNOP(X);
/// @}
/// \brief Construct an X[n]
///
/// X[3]f = XXXf
static formula X(unsigned level, const formula& f)
{
return nested_unop_range(op::X, op::Or /* unused */, level, level, f);
}
/// \brief Construct an F
/// @{
SPOT_DEF_UNOP(F);
/// @}
/// \brief Construct F[n:m]
///
/// F[2:3] = XX(a | Xa)
///
/// This syntax is from TSLF; the operator is called next_e![n..m] in PSL.
static formula F(unsigned min_level, unsigned max_level, const formula& f)
{
return nested_unop_range(op::X, op::Or, min_level, max_level, f);
}
/// \brief Construct G[n:m]
///
/// G[2:3] = XX(a & Xa)
///
/// This syntax is from TSLF; the operator is called next_a![n..m] in PSL.
static formula G(unsigned min_level, unsigned max_level, const formula& f)
{
return nested_unop_range(op::X, op::And, min_level, max_level, f);
}
/// \brief Construct a G
/// @{
SPOT_DEF_UNOP(G);
@ -1173,6 +1205,20 @@ namespace spot
/// @}
#undef SPOT_DEF_BUNOP
/// \brief Nested operator construction (syntactic sugar).
///
/// Build between min and max nested uo, and chose between the
/// different numbers with bo.
///
/// For instance nested_unup_range(op::X, op::Or, 2, 4, a) returns
/// XX(a | X(a | Xa)).
static const formula nested_unop_range(op uo, op bo, unsigned min,
unsigned max, formula f)
{
return formula(fnode::nested_unop_range(uo, bo, min, max,
f.ptr_->clone()));
}
/// \brief Create a SERE equivalent to b[->min..max]
///
/// The operator does not exist: it is handled as sugar by the parser