ltl: keep track of spin-compatible AP

* src/misc/bareword.cc, src/misc/bareword.hh (is_spin_ap): New function.
* src/ltlast/formula.cc, src/ltlast/formula.hh (is_spin_atomic_props):
New method and boolean.
* src/ltlast/atomic_prop.cc, src/ltlast/constant.cc: Update it.
* src/ltltest/kind.test: Test it.
This commit is contained in:
Alexandre Duret-Lutz 2015-01-27 10:21:17 +01:00
parent 16a8c03143
commit a4a0cf3bb2
7 changed files with 143 additions and 108 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2013 Laboratoire de Recherche et Développement
// Copyright (C) 2011, 2013, 2015 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -50,4 +50,16 @@ namespace spot
return "\"" + escape_str(str) + "\"";
}
// This is for Spin 5. Spin 6 has a relaxed parser that can
// accept any parenthesized block as an atomic propoistion.
bool is_spin_ap(const char* str)
{
if (!str || !islower(*str))
return false;
while (*++str)
if (!(isalnum(*str) || *str == '_'))
return false;
return true;
}
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013 Laboratoire de Recherche et Développement
// Copyright (C) 2013, 2015 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -40,6 +40,13 @@ namespace spot
/// \brief Double-quote words that are not bare.
/// \see is_bare_word
SPOT_API std::string quote_unless_bare_word(const std::string& str);
/// \brief Whether a word can be used as an atomic proposition for Spin 5.
///
/// In Spin 5 (hence in ltl2ba and ltl3ba as well) atomic
/// propositions should start with a lowercase letter, and can then
/// consist solely of alphanumeric characters and underscores.
SPOT_API bool is_spin_ap(const char* str);
/// @}
}