Cleanup neverclaim support.
* src/neverclaimparse/: Shorthen as ... * src/neverparse/:... this. * src/Makefile.am: Adjust, and add back the directories mistakenly removed by previous patch. * README: Adjust, and keep the file's width under 80 columns. * configure.ac: Adjust. * src/neverparse/Makefile.am, src/neverparse/fmterror.cc, src/neverparse/neverclaimparse.yy, src/neverparse/neverclaimscan.ll, src/neverparse/public.hh: Fix copyright. * src/tgbatest/Makefile.am (check_PROGRAMS): Remove neverclaimread. * src/tgbatest/ltl2tgba.cc: Add option -XN to read a neverclaim. * src/tgbatest/readneverclaim.cc: Delete. * src/tgbatest/neverclaimread.test: Use ltl2tgba instead of neverclaimread.
This commit is contained in:
parent
ab6ec5cb63
commit
ac08c5abce
14 changed files with 113 additions and 166 deletions
63
src/neverparse/Makefile.am
Normal file
63
src/neverparse/Makefile.am
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
## Copyright (C) 2010 Laboratoire de Recherche et Développement
|
||||
## de l'Epita (LRDE).
|
||||
##
|
||||
## 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.
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/.. $(BUDDY_CPPFLAGS)
|
||||
# Disable -Werror because too many versions of flex yield warnings.
|
||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS:-Werror=)
|
||||
|
||||
neverclaimparsedir = $(pkgincludedir)/neverclaimparse
|
||||
|
||||
neverclaimparse_HEADERS = \
|
||||
public.hh \
|
||||
location.hh \
|
||||
position.hh
|
||||
|
||||
noinst_LTLIBRARIES = libneverclaimparse.la
|
||||
|
||||
NEVERCLAIMPARSE_YY = neverclaimparse.yy
|
||||
FROM_NEVERCLAIMPARSE_YY_MAIN = neverclaimparse.cc
|
||||
FROM_NEVERCLAIMPARSE_YY_OTHERS = \
|
||||
stack.hh \
|
||||
position.hh \
|
||||
location.hh \
|
||||
neverclaimparse.hh
|
||||
|
||||
FROM_NEVERCLAIMPARSE_YY = $(FROM_NEVERCLAIMPARSE_YY_MAIN) $(FROM_NEVERCLAIMPARSE_YY_OTHERS)
|
||||
|
||||
BUILT_SOURCES = $(FROM_NEVERCLAIMPARSE_YY)
|
||||
MAINTAINERCLEANFILES = $(FROM_NEVERCLAIMPARSE_YY)
|
||||
|
||||
$(FROM_NEVERCLAIMPARSE_YY_MAIN): $(srcdir)/$(NEVERCLAIMPARSE_YY)
|
||||
## We must cd into $(srcdir) first because if we tell bison to read
|
||||
## $(srcdir)/$(NEVERCLAIMPARSE_YY), it will also use the value of $(srcdir)/
|
||||
## in the generated include statements.
|
||||
cd $(srcdir) && \
|
||||
bison -Wall -Werror --report=all \
|
||||
$(NEVERCLAIMPARSE_YY) -o $(FROM_NEVERCLAIMPARSE_YY_MAIN)
|
||||
$(FROM_NEVERCLAIMPARSE_YY_OTHERS): $(NEVERCLAIMPARSE_YY)
|
||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) $(FROM_NEVERCLAIMPARSE_YY_MAIN)
|
||||
|
||||
EXTRA_DIST = $(NEVERCLAIMPARSE_YY)
|
||||
|
||||
libneverclaimparse_la_SOURCES = \
|
||||
fmterror.cc \
|
||||
$(FROM_NEVERCLAIMPARSE_YY) \
|
||||
neverclaimscan.ll \
|
||||
parsedecl.hh
|
||||
43
src/neverparse/fmterror.cc
Normal file
43
src/neverparse/fmterror.cc
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (C) 2010 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
//
|
||||
// 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 <ostream>
|
||||
#include "public.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
bool
|
||||
format_neverclaim_parse_errors(std::ostream& os,
|
||||
const std::string& filename,
|
||||
neverclaim_parse_error_list& error_list)
|
||||
{
|
||||
bool printed = false;
|
||||
spot::neverclaim_parse_error_list::iterator it;
|
||||
for (it = error_list.begin(); it != error_list.end(); ++it)
|
||||
{
|
||||
if (filename != "-")
|
||||
os << filename << ":";
|
||||
os << it->first << ": ";
|
||||
os << it->second << std::endl;
|
||||
printed = true;
|
||||
}
|
||||
return printed;
|
||||
}
|
||||
}
|
||||
178
src/neverparse/neverclaimparse.yy
Normal file
178
src/neverparse/neverclaimparse.yy
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
/* Copyright (C) 2010 Laboratoire de Recherche et Développement
|
||||
** de l'Epita (LRDE).
|
||||
**
|
||||
** 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.
|
||||
*/
|
||||
%language "C++"
|
||||
%locations
|
||||
%defines
|
||||
%expect 0 // No shift/reduce
|
||||
%expect-rr 0 // No reduce/reduce
|
||||
%name-prefix "neverclaimyy"
|
||||
%debug
|
||||
%error-verbose
|
||||
|
||||
%code requires
|
||||
{
|
||||
#include <string>
|
||||
#include "public.hh"
|
||||
typedef std::pair<std::string*, std::string*> pair;
|
||||
}
|
||||
|
||||
%parse-param {spot::neverclaim_parse_error_list& error_list}
|
||||
%parse-param {spot::ltl::environment& parse_environment}
|
||||
%parse-param {spot::tgba_explicit_string*& result}
|
||||
%union
|
||||
{
|
||||
std::string* str;
|
||||
pair* p;
|
||||
std::list<pair>* list;
|
||||
}
|
||||
|
||||
%code
|
||||
{
|
||||
#include "ltlast/constant.hh"
|
||||
/* Unfortunately Bison 2.3 uses the same guards in all parsers :( */
|
||||
#undef BISON_POSITION_HH
|
||||
#undef BISON_LOCATION_HH
|
||||
#include "ltlparse/public.hh"
|
||||
|
||||
/* neverclaimparse.hh and parsedecl.hh include each other recursively.
|
||||
We must ensure that YYSTYPE is declared (by the above %union)
|
||||
before parsedecl.hh uses it. */
|
||||
#include "parsedecl.hh"
|
||||
using namespace spot::ltl;
|
||||
}
|
||||
|
||||
%token NEVER "never"
|
||||
%token SKIP "skip"
|
||||
%token IF "if"
|
||||
%token FI "fi"
|
||||
%token ARROW "->"
|
||||
%token GOTO "goto"
|
||||
%token <str> FORMULA
|
||||
%token <str> IDENT
|
||||
%type <p> transition
|
||||
%type <list> transitions
|
||||
|
||||
%destructor { delete $$; } <str>
|
||||
%destructor { delete $$->first; delete $$->second; delete $$; } <p>
|
||||
%destructor {
|
||||
for (std::list<pair>::iterator i = $$->begin();
|
||||
i != $$->end(); ++i)
|
||||
{
|
||||
delete i->first;
|
||||
delete i->second;
|
||||
}
|
||||
delete $$;
|
||||
} <list>
|
||||
%printer { debug_stream() << *$$; } <str>
|
||||
|
||||
%%
|
||||
neverclaim:
|
||||
"never" '{' states '}'
|
||||
;
|
||||
|
||||
states:
|
||||
/* empty */
|
||||
| state states
|
||||
;
|
||||
|
||||
state:
|
||||
IDENT ':' "skip"
|
||||
{
|
||||
result->create_transition(*$1, *$1);
|
||||
delete $1;
|
||||
}
|
||||
| IDENT ':' { delete $1; }
|
||||
| IDENT ':' "if" transitions "fi"
|
||||
{
|
||||
std::list<pair>::iterator it;
|
||||
for (it = $4->begin(); it != $4->end(); ++it)
|
||||
{
|
||||
spot::tgba_explicit::transition* t =
|
||||
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, f);
|
||||
}
|
||||
// Free the list
|
||||
delete $1;
|
||||
for (std::list<pair>::iterator it = $4->begin();
|
||||
it != $4->end(); ++it)
|
||||
{
|
||||
delete it->first;
|
||||
delete it->second;
|
||||
}
|
||||
delete $4;
|
||||
}
|
||||
;
|
||||
|
||||
transitions:
|
||||
/* empty */ { $$ = new std::list<pair>; }
|
||||
| transition transitions
|
||||
{
|
||||
$2->push_back(*$1);
|
||||
delete $1;
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
transition:
|
||||
':' ':' FORMULA "->" "goto" IDENT
|
||||
{
|
||||
$$ = new pair($3, $6);
|
||||
}
|
||||
%%
|
||||
|
||||
void
|
||||
neverclaimyy::parser::error(const location_type& location,
|
||||
const std::string& message)
|
||||
{
|
||||
error_list.push_back(spot::neverclaim_parse_error(location, message));
|
||||
}
|
||||
|
||||
namespace spot
|
||||
{
|
||||
tgba_explicit_string*
|
||||
neverclaim_parse(const std::string& name,
|
||||
neverclaim_parse_error_list& error_list,
|
||||
bdd_dict* dict,
|
||||
environment& env,
|
||||
bool debug)
|
||||
{
|
||||
if (neverclaimyyopen(name))
|
||||
{
|
||||
error_list.push_back
|
||||
(neverclaim_parse_error(neverclaimyy::location(),
|
||||
std::string("Cannot open file ") + name));
|
||||
return 0;
|
||||
}
|
||||
tgba_explicit_string* result = new tgba_explicit_string(dict);
|
||||
neverclaimyy::parser parser(error_list, env, result);
|
||||
parser.set_debug_level(debug);
|
||||
parser.parse();
|
||||
neverclaimyyclose();
|
||||
result->merge_transitions();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// mode: c++
|
||||
// End:
|
||||
101
src/neverparse/neverclaimscan.ll
Normal file
101
src/neverparse/neverclaimscan.ll
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/* Copyright (C) 2010 Laboratoire de Recherche et Développement de
|
||||
** l'Epita (LRDE).
|
||||
**
|
||||
** 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.
|
||||
*/
|
||||
%option noyywrap
|
||||
%option prefix="neverclaimyy"
|
||||
%option outfile="lex.yy.c"
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include "neverparse/parsedecl.hh"
|
||||
|
||||
#define YY_USER_ACTION \
|
||||
yylloc->columns(yyleng);
|
||||
|
||||
#define YY_NEVER_INTERACTIVE 1
|
||||
|
||||
typedef neverclaimyy::parser::token token;
|
||||
|
||||
%}
|
||||
|
||||
eol \n|\r|\n\r|\r\n
|
||||
|
||||
%%
|
||||
|
||||
%{
|
||||
yylloc->step();
|
||||
%}
|
||||
|
||||
/* skip blanks */
|
||||
{eol} yylloc->lines(yyleng); yylloc->step();
|
||||
[ \t]+ yylloc->step();
|
||||
"/*".*"*/" yylloc->step();
|
||||
|
||||
"never" return token::NEVER;
|
||||
"skip"|"skip;" return token::SKIP;
|
||||
"if" return token::IF;
|
||||
"fi"|"fi;" return token::FI;
|
||||
"->" return token::ARROW;
|
||||
"goto" return token::GOTO;
|
||||
|
||||
"(".*")"|"true"|"1"|"false"|"0" {
|
||||
yylval->str =
|
||||
new std::string(yytext, yyleng);
|
||||
return token::FORMULA;
|
||||
}
|
||||
|
||||
[a-zA-Z][a-zA-Z0-9_]* {
|
||||
yylval->str = new std::string(yytext, yyleng);
|
||||
return token::IDENT;
|
||||
}
|
||||
|
||||
. return *yytext;
|
||||
|
||||
%{
|
||||
/* Dummy use of yyunput to shut up a gcc warning. */
|
||||
(void) &yyunput;
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
namespace spot
|
||||
{
|
||||
int
|
||||
neverclaimyyopen(const std::string &name)
|
||||
{
|
||||
if (name == "-")
|
||||
{
|
||||
yyin = stdin;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyin = fopen(name.c_str(), "r");
|
||||
if (!yyin)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
neverclaimyyclose()
|
||||
{
|
||||
fclose(yyin);
|
||||
}
|
||||
}
|
||||
40
src/neverparse/parsedecl.hh
Normal file
40
src/neverparse/parsedecl.hh
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (C) 2003, 2005 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.
|
||||
|
||||
#ifndef SPOT_NEVERCLAIMPARSE_PARSEDECL_HH
|
||||
# define SPOT_NEVERCLAIMPARSE_PARSEDECL_HH
|
||||
|
||||
#include <string>
|
||||
#include "neverclaimparse.hh"
|
||||
#include "location.hh"
|
||||
|
||||
# define YY_DECL \
|
||||
int neverclaimyylex (neverclaimyy::parser::semantic_type *yylval, \
|
||||
neverclaimyy::location *yylloc)
|
||||
YY_DECL;
|
||||
|
||||
namespace spot
|
||||
{
|
||||
int neverclaimyyopen(const std::string& name);
|
||||
void neverclaimyyclose();
|
||||
}
|
||||
|
||||
#endif // SPOT_NEVERCLAIMPARSE_PARSEDECL_HH
|
||||
83
src/neverparse/public.hh
Normal file
83
src/neverparse/public.hh
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
// Copyright (C) 2010 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
//
|
||||
// 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.
|
||||
|
||||
#ifndef SPOT_NEVERCLAIMPARSE_PUBLIC_HH
|
||||
# define SPOT_NEVERCLAIMPARSE_PUBLIC_HH
|
||||
|
||||
# include "tgba/tgbaexplicit.hh"
|
||||
// Unfortunately Bison 2.3 uses the same guards in all parsers :(
|
||||
# undef BISON_LOCATION_HH
|
||||
# undef BISON_POSITION_HH
|
||||
# include "neverparse/location.hh"
|
||||
# include "ltlenv/defaultenv.hh"
|
||||
# include <string>
|
||||
# include <list>
|
||||
# include <utility>
|
||||
# include <iosfwd>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
/// \addtogroup tgba_io
|
||||
/// @{
|
||||
|
||||
/// \brief A parse diagnostic with its location.
|
||||
typedef std::pair<neverclaimyy::location, std::string> neverclaim_parse_error;
|
||||
/// \brief A list of parser diagnostics, as filled by parse.
|
||||
typedef std::list<neverclaim_parse_error> neverclaim_parse_error_list;
|
||||
|
||||
/// \brief Build a spot::tgba_explicit from a Spin never claim file.
|
||||
/// \param filename The name of the file to parse.
|
||||
/// \param error_list A list that will be filled with
|
||||
/// parse errors that occured during parsing.
|
||||
/// \param dict The BDD dictionary where to use.
|
||||
/// \param env The environment of atomic proposition into which parsing
|
||||
/// should take place.
|
||||
/// \param debug When true, causes the parser to trace its execution.
|
||||
/// \return A pointer to the tgba built from \a filename, or
|
||||
/// 0 if the file could not be opened.
|
||||
///
|
||||
/// Note that the parser usually tries to recover from errors. It can
|
||||
/// return an non zero value even if it encountered error during the
|
||||
/// parsing of \a filename. If you want to make sure \a filename
|
||||
/// was parsed succesfully, check \a error_list for emptiness.
|
||||
///
|
||||
/// \warning This function is not reentrant.
|
||||
tgba_explicit_string* neverclaim_parse(
|
||||
const std::string& filename,
|
||||
neverclaim_parse_error_list&
|
||||
error_list,
|
||||
bdd_dict* dict,
|
||||
ltl::environment& env
|
||||
= ltl::default_environment::instance(),
|
||||
bool debug = false);
|
||||
|
||||
/// \brief Format diagnostics produced by spot::neverclaim_parse.
|
||||
/// \param os Where diagnostics should be output.
|
||||
/// \param filename The filename that should appear in the diagnostics.
|
||||
/// \param error_list The error list filled by spot::ltl::parse while
|
||||
/// parsing \a ltl_string.
|
||||
/// \return \c true iff any diagnostic was output.
|
||||
bool format_neverclaim_parse_errors(std::ostream& os,
|
||||
const std::string& filename,
|
||||
neverclaim_parse_error_list& error_list);
|
||||
/// @}
|
||||
}
|
||||
|
||||
#endif // SPOT_NEVERCLAIMPARSE_PUBLIC_HH
|
||||
Loading…
Add table
Add a link
Reference in a new issue