Preliminary support for Event-based GBA.

* src/evtgba/Makefile.am, src/evtgba/evtgba.cc,
src/evtgba/evtgba.hh, src/evtgba/evtgbaiter.hh,
src/evtgba/explicit.cc, src/evtgba/explicit.hh,
src/evtgba/product.cc, src/evtgba/product.hh,
src/evtgba/symbol.cc, src/evtgba/symbol.hh,
src/evtgbaalgos/Makefile.am, src/evtgbaalgos/dotty.cc,
src/evtgbaalgos/dotty.hh, src/evtgbaalgos/reachiter.cc,
src/evtgbaalgos/reachiter.hh, src/evtgbaalgos/save.cc,
src/evtgbaalgos/save.hh, src/evtgbaparse/Makefile.am,
src/evtgbaparse/evtgbaparse.yy, src/evtgbaparse/evtgbascan.ll,
src/evtgbaparse/fmterror.cc, src/evtgbaparse/parsedecl.hh,
src/evtgbaparse/public.hh, src/evtgbatest/Makefile.am,
src/evtgbatest/defs.in, src/evtgbatest/explicit.cc,
src/evtgbatest/explicit.test, src/evtgbatest/product.cc,
src/evtgbatest/product.test, src/evtgbatest/readsave.cc,
src/evtgbatest/readsave.test: New files.
* configure.ac: Create the Makefiles in these new subdirectories.
* src/Makefile.am: Recurse them.
This commit is contained in:
Alexandre Duret-Lutz 2004-10-22 16:22:31 +00:00
parent d9b29a0590
commit 73ff928b6f
38 changed files with 3067 additions and 3 deletions

View file

@ -0,0 +1,13 @@
.deps
Makefile
Makefile.in
location.hh
evtgbaparse.cc
evtgbaparse.hh
evtgbaparse.output
evtgbascan.cc
position.hh
stack.hh
*.lo
*.la
.libs

View file

@ -0,0 +1,61 @@
## 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.
AM_CPPFLAGS = -I$(srcdir)/.. $(BUDDY_CPPFLAGS)
AM_CXXFLAGS = $(WARNING_CXXFLAGS)
evtgbaparsedir = $(pkgincludedir)/evtgbaparse
evtgbaparse_HEADERS = \
public.hh
noinst_LTLIBRARIES = libevtgbaparse.la
EVTGBAPARSE_YY = evtgbaparse.yy
FROM_EVTGBAPARSE_YY_MAIN = evtgbaparse.cc
FROM_EVTGBAPARSE_YY_OTHERS = \
stack.hh \
position.hh \
location.hh \
evtgbaparse.hh
FROM_EVTGBAPARSE_YY = $(FROM_EVTGBAPARSE_YY_MAIN) $(FROM_EVTGBAPARSE_YY_OTHERS)
BUILT_SOURCES = $(FROM_EVTGBAPARSE_YY)
MAINTAINERCLEANFILES = $(FROM_EVTGBAPARSE_YY)
$(FROM_EVTGBAPARSE_YY_MAIN): $(srcdir)/$(EVTGBAPARSE_YY)
## We must cd into $(srcdir) first because if we tell bison to read
## $(srcdir)/$(EVTGBAPARSE_YY), it will also use the value of $(srcdir)/
## in the generated include statements.
cd $(srcdir) && \
bison --defines --locations --skeleton=lalr1.cc --report=all \
$(EVTGBAPARSE_YY) -o $(FROM_EVTGBAPARSE_YY_MAIN)
$(FROM_EVTGBAPARSE_YY_OTHERS): $(EVTGBAPARSE_YY)
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) $(FROM_EVTGBAPARSE_YY_MAIN)
EXTRA_DIST = $(EVTGBAPARSE_YY)
libevtgbaparse_la_SOURCES = \
evtgbascan.ll \
fmterror.cc \
$(FROM_EVTGBAPARSE_YY) \
parsedecl.hh

View file

@ -0,0 +1,153 @@
/* 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 <string>
#include "public.hh"
#include "evtgba/symbol.hh"
%}
%parse-param {spot::evtgba_parse_error_list &error_list}
%parse-param {spot::evtgba_explicit* &result}
%debug
%error-verbose
%union
{
int token;
std::string* str;
spot::rsymbol_set* symset;
}
%{
/* evtgbaparse.hh and parsedecl.hh include each other recursively.
We mut ensure that YYSTYPE is declared (by the above %union)
before parsedecl.hh uses it. */
#include "parsedecl.hh"
/* Ugly hack so that Bison use tgbayylex, not yylex.
(%name-prefix doesn't work for the lalr1.cc skeleton
at the time of writing.) */
#define yylex evtgbayylex
%}
%token <str> STRING UNTERMINATED_STRING
%token <str> IDENT
%type <str> strident string
%type <symset> acc_list
%token ACC_DEF
%token INIT_DEF
%%
evtgba: lines
/* At least one line. */
lines: line
| lines line
;
line: strident ',' strident ',' strident ',' acc_list ';'
{
result->add_transition(*$1, *$5, *$7, *$3);
delete $1;
delete $5;
delete $3;
delete $7;
}
| ACC_DEF acc_decl ';'
| INIT_DEF init_decl ';'
;
string: STRING
| UNTERMINATED_STRING
{
error_list.push_back(spot::evtgba_parse_error(@1,
"unterminated string"));
}
strident: string | IDENT
acc_list:
{
$$ = new spot::rsymbol_set;
}
| acc_list strident
{
$1->insert(spot::rsymbol(*$2));
delete $2;
}
;
acc_decl:
| acc_decl strident
{
result->declare_acceptance_condition(*$2);
delete $2;
}
;
init_decl:
| init_decl strident
{
result->set_init_state(*$2);
delete $2;
}
;
%%
void
yy::Parser::print_()
{
if (looka_ == STRING || looka_ == IDENT)
YYCDEBUG << " '" << *value.str << "'";
}
void
yy::Parser::error_()
{
error_list.push_back(spot::evtgba_parse_error(location, message));
}
namespace spot
{
evtgba_explicit*
evtgba_parse(const std::string& name,
evtgba_parse_error_list& error_list,
bool debug)
{
if (evtgbayyopen(name))
{
error_list.push_back
(evtgba_parse_error(yy::Location(),
std::string("Cannot open file ") + name));
return 0;
}
evtgba_explicit* result = new evtgba_explicit();
evtgbayy::Parser parser(debug, yy::Location(), error_list, result);
parser.parse();
evtgbayyclose();
return result;
}
}
// Local Variables:
// mode: c++
// End:

View file

@ -0,0 +1,119 @@
/* 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.
*/
%option noyywrap
%option prefix="evtgbayy"
%option outfile="lex.yy.c"
%x STATE_STRING
%{
#include <string>
#include "evtgbaparse/parsedecl.hh"
#define YY_USER_ACTION \
yylloc->columns(yyleng);
#define YY_USER_INIT \
do { \
yylloc->begin.filename = current_file; \
yylloc->end.filename = current_file; \
} while (0)
#define YY_NEVER_INTERACTIVE 1
static std::string current_file;
%}
eol \n|\r|\n\r|\r\n
%%
%{
yylloc->step ();
%}
acc[ \t]*= return ACC_DEF;
init[ \t]*= return INIT_DEF;
[a-zA-Z][a-zA-Z0-9_]* {
yylval->str = new std::string(yytext);
return IDENT;
}
/* discard whitespace */
{eol} yylloc->lines(yyleng); yylloc->step();
[ \t]+ yylloc->step();
\" {
yylval->str = new std::string;
BEGIN(STATE_STRING);
}
. return *yytext;
/* Handle \" and \\ in strings. */
<STATE_STRING>{
\" {
BEGIN(INITIAL);
return STRING;
}
\\["\\] yylval->str->append(1, yytext[1]);
[^"\\]+ yylval->str->append(yytext, yyleng);
<<EOF>> {
BEGIN(INITIAL);
return UNTERMINATED_STRING;
}
}
%{
/* Dummy use of yyunput to shut up a gcc warning. */
(void) &yyunput;
%}
%%
namespace spot
{
int
evtgbayyopen(const std::string &name)
{
if (name == "-")
{
yyin = stdin;
current_file = "standard input";
}
else
{
yyin = fopen (name.c_str (), "r");
current_file = name;
if (!yyin)
return 1;
}
return 0;
}
void
evtgbayyclose()
{
fclose(yyin);
}
}

View file

@ -0,0 +1,42 @@
// Copyright (C) 2003, 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 <ostream>
#include "public.hh"
namespace spot
{
bool
format_evtgba_parse_errors(std::ostream& os,
evtgba_parse_error_list& error_list)
{
bool printed = false;
spot::evtgba_parse_error_list::iterator it;
for (it = error_list.begin(); it != error_list.end(); ++it)
{
if (it->first.begin.filename != "")
os << it->first << ": ";
os << it->second << std::endl;
printed = true;
}
return printed;
}
}

View file

@ -0,0 +1,53 @@
// Copyright (C) 2003, 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.
#ifndef SPOT_EVTGBAPARSE_PARSEDECL_HH
# define SPOT_EVTGBAPARSE_PARSEDECL_HH
#include <string>
#include "evtgbaparse.hh"
#include "location.hh"
# define YY_DECL \
int evtgbayylex (yystype *yylval, yy::Location *yylloc)
YY_DECL;
namespace spot
{
int evtgbayyopen(const std::string& name);
void evtgbayyclose();
}
// Gross kludge to compile yy::Parser in another namespace (tgbayy::)
// but still use yy::Location. The reason is that Bison's C++
// skeleton does not support anything close to %name-prefix at the
// moment. All parser are named yy::Parser which makes it somewhat
// difficult to define multiple parsers.
namespace evtgbayy
{
using namespace yy;
}
#define yy evtgbayy
#endif // SPOT_EVTGBAPARSE_PARSEDECL_HH

68
src/evtgbaparse/public.hh Normal file
View file

@ -0,0 +1,68 @@
// Copyright (C) 2003, 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.
#ifndef SPOT_EVTGBAPARSE_PUBLIC_HH
# define SPOT_EVTGBAPARSE_PUBLIC_HH
# include "evtgba/explicit.hh"
# include "ltlparse/location.hh"
# include <string>
# include <list>
# include <utility>
# include <iosfwd>
namespace spot
{
/// \brief A parse diagnostic with its location.
typedef std::pair<yy::Location, std::string> evtgba_parse_error;
/// \brief A list of parser diagnostics, as filled by parse.
typedef std::list<evtgba_parse_error> evtgba_parse_error_list;
/// \brief Build a spot::evtgba_explicit from a text 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 into which parsing should take place.
/// \param debug When true, causes the parser to trace its execution.
/// \return A pointer to the evtgba 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.
evtgba_explicit* evtgba_parse(const std::string& filename,
evtgba_parse_error_list& error_list,
bool debug = false);
/// \brief Format diagnostics produced by spot::evtgba_parse.
/// \param os Where diagnostics should be output.
/// \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_evtgba_parse_errors(std::ostream& os,
evtgba_parse_error_list& error_list);
}
#endif // SPOT_EVTGBAPARSE_PUBLIC_HH