* src/ltlparse/ltlscan.ll: Do not recognize `.' as an AND. Allow it in atomic propositions. * src/evtgbaparse/evtgbascan.ll, src/tgbaparse/tgbascan.ll: Accept `.' in identifiers. * src/misc/bareword.cc (is_bareword): Accept `.' inside barewords, so that there is no need to quote `X.Y'. * src/ltltest/parse.test: Do not use `.' as and operator..
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
// Copyright (C) 2011 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
|
|
// et Marie Curie.
|
|
//
|
|
// This file is part of Spot, a model checking library.
|
|
//
|
|
// Spot is free software; you can redistribute it and/or modify it
|
|
// under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Spot is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
// License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Spot; see the file COPYING. If not, write to the Free
|
|
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
// 02111-1307, USA.
|
|
|
|
#include "bareword.hh"
|
|
#include <ctype.h>
|
|
#include "escape.hh"
|
|
|
|
namespace spot
|
|
{
|
|
bool
|
|
is_bare_word(const char* str)
|
|
{
|
|
// Bare words cannot be empty and should start with a letter.
|
|
if (!*str
|
|
|| !(isalpha(*str) || *str == '_' || *str == '.'))
|
|
return false;
|
|
// The remaining of the word must be alphanumeric.
|
|
while (*++str)
|
|
if (!(isalnum(*str) || *str == '_' || *str == '.'))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
std::string
|
|
quote_unless_bare_word(const std::string& str)
|
|
{
|
|
if (is_bare_word(str.c_str()))
|
|
return str;
|
|
else
|
|
return "\"" + escape_str(str) + "\"";
|
|
}
|
|
|
|
}
|