Add text I/O for Kripke structures.
* src/kripke/kripkeexplicit.cc, src/kripke/kripkeexplicit.hh, src/kripke/kripkeprint.cc, src/kripke/kripkeprint.hh: New files. * src/kripke/Makefile.am: Add them. * src/kripkeparse/fmterror.cc, src/kripkeparse/kripkeparse.yy, src/kripkeparse/kripkescan.ll, src/kripkeparse/parsedecl.hh, src/kripkeparse/public.hh, src/kripkeparse/scankripke.ll: New files. * src/kripkeparse/Makefile.am: Add them. * src/kripketest/bad_parsing.test, src/kripketest/defs.in, src/kripketest/kripke.test, src/kripketest/origin, src/kripketest/parse_print_test.cc: New files. * src/kripketest/Makefile.am: Add them. * src/Makefile.am (SUBDIRS): Add kripkeparse and kripketest. * README: Document src/kripketest/ and src/kripkeparse/. * configure.ac: Generate src/kripkeparse/Makefile, src/kripketest/Makefile, src/kripketest/defs. * iface/dve2/defs.in (run2): New function. * iface/dve2/dve2check.cc (syntax, main): Add option -gK. * iface/dve2/kripke.test: New file. * iface/dve2/Makefile.am (TESTS): Add kripke.test.
This commit is contained in:
parent
71d1a4fe25
commit
bb5949f6de
28 changed files with 1824 additions and 7 deletions
11
src/kripkeparse/.gitignore
vendored
Normal file
11
src/kripkeparse/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
location.hh
|
||||
kripkeparse.hh
|
||||
kripkeparse.cc
|
||||
kripkeparse.output
|
||||
kripkescan.cc
|
||||
position.hh
|
||||
stack.hh
|
||||
*.lo
|
||||
*.la
|
||||
65
src/kripkeparse/Makefile.am
Normal file
65
src/kripkeparse/Makefile.am
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
## Copyright (C) 2011 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) -DYY_NO_INPUT
|
||||
# Disable -Werror because too many versions of flex yield warnings.
|
||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS:-Werror=)
|
||||
|
||||
kripkeparsedir = $(pkgincludedir)/kripkeparse
|
||||
|
||||
kripkeparse_HEADERS = \
|
||||
public.hh \
|
||||
location.hh \
|
||||
position.hh
|
||||
|
||||
noinst_LTLIBRARIES = libkripkeparse.la
|
||||
|
||||
KRIPKEPARSE_YY = kripkeparse.yy
|
||||
FROM_KRIPKEPARSE_YY_MAIN = kripkeparse.cc
|
||||
FROM_KRIPKEPARSE_YY_OTHERS = \
|
||||
stack.hh \
|
||||
position.hh \
|
||||
location.hh \
|
||||
kripkeparse.hh
|
||||
|
||||
FROM_KRIPKEPARSE_YY = \
|
||||
$(FROM_KRIPKEPARSE_YY_MAIN) \
|
||||
$(FROM_KRIPKEPARSE_YY_OTHERS)
|
||||
|
||||
BUILT_SOURCES = $(FROM_KRIPKEPARSE_YY)
|
||||
MAINTAINERCLEANFILES = $(FROM_KRIPKEPARSE_YY)
|
||||
|
||||
$(FROM_KRIPKEPARSE_YY_MAIN): $(srcdir)/$(KRIPKEPARSE_YY)
|
||||
## We must cd into $(srcdir) first because if we tell bison to read
|
||||
## $(srcdir)/$(KRIPKEPARSE_YY), it will also use the value of $(srcdir)/
|
||||
## in the generated include statements.
|
||||
cd $(srcdir) && \
|
||||
bison -Wall -Werror --report=all \
|
||||
$(KRIPKEPARSE_YY) -o $(FROM_KRIPKEPARSE_YY_MAIN)
|
||||
$(FROM_KRIPKEPARSE_YY_OTHERS): $(KRIPKEPARSE_YY)
|
||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) $(FROM_KRIPKEPARSE_YY_MAIN)
|
||||
|
||||
EXTRA_DIST = $(KRIPKEPARSE_YY)
|
||||
|
||||
libkripkeparse_la_SOURCES = \
|
||||
$(FROM_KRIPKEPARSE_YY) \
|
||||
kripkescan.ll \
|
||||
parsedecl.hh \
|
||||
fmterror.cc
|
||||
43
src/kripkeparse/fmterror.cc
Normal file
43
src/kripkeparse/fmterror.cc
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
|
||||
// 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_kripke_parse_errors(std::ostream& os,
|
||||
const std::string& filename,
|
||||
kripke_parse_error_list& error_list)
|
||||
{
|
||||
bool printed = false;
|
||||
spot::kripke_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;
|
||||
}
|
||||
}
|
||||
230
src/kripkeparse/kripkeparse.yy
Normal file
230
src/kripkeparse/kripkeparse.yy
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
|
||||
// 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
|
||||
%name-prefix "kripkeyy"
|
||||
%debug
|
||||
%error-verbose
|
||||
|
||||
%code requires
|
||||
{
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "public.hh"
|
||||
|
||||
/* Cache parsed formulae. Labels on arcs are frequently identical and
|
||||
it would be a waste of time to parse them to formula* over and
|
||||
over, and to register all their atomic_propositions in the
|
||||
bdd_dict. Keep the bdd result around so we can reuse it. */
|
||||
typedef std::map<std::string, bdd> formula_cache;
|
||||
}
|
||||
|
||||
%parse-param {spot::kripke_parse_error_list& error_list}
|
||||
%parse-param {spot::ltl::environment& parse_environment}
|
||||
%parse-param {spot::kripke_explicit*& result}
|
||||
%parse-param {formula_cache& fcache}
|
||||
|
||||
%union
|
||||
{
|
||||
int token;
|
||||
std::string* str;
|
||||
spot::ltl::formula* f;
|
||||
std::list<std::string*>* list;
|
||||
}
|
||||
|
||||
%code
|
||||
{
|
||||
#include "kripke/kripkeexplicit.hh"
|
||||
/* Unfortunately Bison 2.3 uses the same guards in all parsers :( */
|
||||
#undef BISON_POSITION_HH
|
||||
#undef BISON_LOCATION_HH
|
||||
#include "ltlparse/public.hh"
|
||||
#include <map>
|
||||
|
||||
/* tgbaparse.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;
|
||||
#include <iostream>
|
||||
//typedef std::pair<bool, spot::ltl::formula*> pair;
|
||||
}
|
||||
|
||||
%token <str> STRING UNTERMINATED_STRING IDENT
|
||||
%token COMA ","
|
||||
%token SEMICOL ";"
|
||||
%type <str> strident string
|
||||
%type <str> condition
|
||||
%type <list> follow_list
|
||||
|
||||
%destructor { delete $$; } <str>
|
||||
%destructor {
|
||||
std::cout << $$->size() << std::endl;
|
||||
for (std::list<std::string*>::iterator i = $$->begin();
|
||||
i != $$->end(); ++i)
|
||||
delete (*i);
|
||||
delete $$;
|
||||
} <list>
|
||||
|
||||
%printer { debug_stream() << *$$; } <str>
|
||||
|
||||
%%
|
||||
|
||||
kripke:
|
||||
lines {
|
||||
}
|
||||
| {
|
||||
}
|
||||
;
|
||||
|
||||
/* At least one line. */
|
||||
lines: line { }
|
||||
| lines line { }
|
||||
;
|
||||
|
||||
line:
|
||||
strident "," condition "," follow_list ";"
|
||||
{
|
||||
result->add_state(*$1);
|
||||
if ($3)
|
||||
{
|
||||
formula_cache::const_iterator i = fcache.find(*$3);
|
||||
if (i == fcache.end())
|
||||
{
|
||||
parse_error_list pel;
|
||||
formula* f = spot::ltl::parse(*$3, pel, parse_environment);
|
||||
for (parse_error_list::iterator i = pel.begin();
|
||||
i != pel.end(); ++i)
|
||||
{
|
||||
//Adjust the diagnostic to the current position.
|
||||
location here = @3;
|
||||
here.end.line = here.begin.line + i->first.end.line - 1;
|
||||
here.end.column =
|
||||
here.begin.column + i->first.end.column;
|
||||
here.begin.line += i->first.begin.line - 1;
|
||||
here.begin.column += i->first.begin.column;
|
||||
error_list.push_back(spot::kripke_parse_error(here,
|
||||
i->second));
|
||||
}
|
||||
if (f)
|
||||
result->add_condition(f, *$1);
|
||||
else
|
||||
result->add_conditions(bddfalse, *$1);
|
||||
fcache[*$3] = result->state_condition(*$1);
|
||||
}
|
||||
else
|
||||
{
|
||||
result->add_conditions(i->second, *$1);
|
||||
}
|
||||
delete $3;
|
||||
}
|
||||
std::list<std::string*>::iterator i;
|
||||
for (i = $5->begin(); i != $5->end(); ++i)
|
||||
{
|
||||
result->add_transition(*$1, **i);
|
||||
delete *i;
|
||||
}
|
||||
|
||||
delete $1;
|
||||
delete $5;
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
string: STRING
|
||||
{ $$ = $1; }
|
||||
| UNTERMINATED_STRING
|
||||
{
|
||||
$$ = $1;
|
||||
error_list.push_back(spot::kripke_parse_error(@1,
|
||||
"unterminated string"));
|
||||
}
|
||||
;
|
||||
|
||||
strident: string
|
||||
{ $$ = $1; }
|
||||
| IDENT
|
||||
{ $$ = $1; }
|
||||
;
|
||||
|
||||
follow_list:
|
||||
follow_list strident
|
||||
{
|
||||
$$ = $1;
|
||||
$$->push_back($2);
|
||||
}
|
||||
| {
|
||||
$$ = new std::list<std::string*>;
|
||||
}
|
||||
;
|
||||
|
||||
condition:
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
| string
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
void
|
||||
kripkeyy::parser::error(const location_type& location,
|
||||
const std::string& message)
|
||||
{
|
||||
error_list.push_back(spot::kripke_parse_error(location, message));
|
||||
}
|
||||
|
||||
namespace spot
|
||||
{
|
||||
kripke_explicit*
|
||||
kripke_parse(const std::string& name,
|
||||
kripke_parse_error_list& error_list,
|
||||
bdd_dict* dict,
|
||||
environment& env,
|
||||
bool debug)
|
||||
{
|
||||
if (kripkeyyopen(name))
|
||||
{
|
||||
error_list.push_back
|
||||
(kripke_parse_error(kripkeyy::location(),
|
||||
std::string("Cannot open file ") + name));
|
||||
return 0;
|
||||
}
|
||||
formula_cache fcache;
|
||||
kripke_explicit* result = new kripke_explicit(dict);
|
||||
kripkeyy::parser parser(error_list, env, result, fcache);
|
||||
parser.set_debug_level(debug);
|
||||
parser.parse();
|
||||
kripkeyyclose();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// mode: c++
|
||||
// End:
|
||||
115
src/kripkeparse/kripkescan.ll
Normal file
115
src/kripkeparse/kripkescan.ll
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/* Copyright (C) 2011 Laboratoire de Recherche et Developpement
|
||||
* 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="kripkeyy"
|
||||
%option outfile="lex.yy.c"
|
||||
%x STATE_STRING
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include "kripkeparse/parsedecl.hh"
|
||||
|
||||
|
||||
#define YY_USER_ACTION \
|
||||
yylloc->columns(yyleng);
|
||||
|
||||
#define YY_NEVER_INTERACTIVE 1
|
||||
|
||||
typedef kripkeyy::parser::token token;
|
||||
|
||||
|
||||
%}
|
||||
|
||||
eol \n|\r|\n\r|\r\n
|
||||
|
||||
%%
|
||||
|
||||
%{
|
||||
yylloc->step ();
|
||||
%}
|
||||
|
||||
[a-zA-Z][a-zA-Z0-9_]* {
|
||||
yylval->str = new std::string(yytext, yyleng);
|
||||
return token::IDENT;
|
||||
}
|
||||
|
||||
/* discard whitespace */
|
||||
{eol} yylloc->lines(yyleng); yylloc->step();
|
||||
[ \t]+ yylloc->step();
|
||||
|
||||
\" {
|
||||
yylval->str = new std::string;
|
||||
BEGIN(STATE_STRING);
|
||||
}
|
||||
|
||||
"," {
|
||||
return token::COMA;
|
||||
}
|
||||
|
||||
";" return token::SEMICOL;
|
||||
|
||||
. return *yytext;
|
||||
|
||||
/* Handle \" and \\ in strings. */
|
||||
<STATE_STRING>{
|
||||
\" {
|
||||
BEGIN(INITIAL);
|
||||
return token::STRING;
|
||||
}
|
||||
\\["\\] yylval->str->append(1, yytext[1]);
|
||||
[^"\\]+ yylval->str->append(yytext, yyleng);
|
||||
<<EOF>> {
|
||||
BEGIN(INITIAL);
|
||||
return token::UNTERMINATED_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
%{
|
||||
/* Dummy use of yyunput to shut up a gcc warning. */
|
||||
(void) &yyunput;
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
namespace spot
|
||||
{
|
||||
int
|
||||
kripkeyyopen(const std::string &name)
|
||||
{
|
||||
if (name == "-")
|
||||
{
|
||||
yyin = stdin;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyin = fopen(name.c_str(), "r");
|
||||
if (!yyin)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
kripkeyyclose()
|
||||
{
|
||||
fclose(yyin);
|
||||
}
|
||||
}
|
||||
41
src/kripkeparse/parsedecl.hh
Normal file
41
src/kripkeparse/parsedecl.hh
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
|
||||
// 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_KRIPKEPARSE_PARSEDECL_HH
|
||||
# define SPOT_KRIPKEPARSE_PARSEDECL_HH
|
||||
|
||||
# include <string>
|
||||
# include "kripkeparse.hh"
|
||||
# include "location.hh"
|
||||
|
||||
# define YY_DECL \
|
||||
int kripkeyylex (kripkeyy::parser::semantic_type *yylval, \
|
||||
kripkeyy::location *yylloc)
|
||||
|
||||
YY_DECL;
|
||||
|
||||
namespace spot
|
||||
{
|
||||
int kripkeyyopen(const std::string& name);
|
||||
void kripkeyyclose();
|
||||
}
|
||||
|
||||
#endif /* !PARSEDECL_HH_ */
|
||||
68
src/kripkeparse/public.hh
Normal file
68
src/kripkeparse/public.hh
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
|
||||
// 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_KRIPKEPARSE_PUBLIC_HH
|
||||
# define SPOT_KRIPKEPARSE_PUBLIC_HH
|
||||
|
||||
# include "kripke/kripkeexplicit.hh"
|
||||
// Unfortunately Bison 2.3 uses the same guards in all parsers :(
|
||||
# undef BISON_LOCATION_HH
|
||||
# undef BISON_POSITION_HH
|
||||
# include "kripkeparse/location.hh"
|
||||
# include "ltlenv/defaultenv.hh"
|
||||
# include <string>
|
||||
# include <list>
|
||||
# include <utility>
|
||||
# include <iosfwd>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
||||
/// \brief A parse diagnostic with its location.
|
||||
typedef std::pair<kripkeyy::location, std::string> kripke_parse_error;
|
||||
/// \brief A list of parser diagnostics, as filled by parse.
|
||||
typedef std::list<kripke_parse_error> kripke_parse_error_list;
|
||||
|
||||
|
||||
|
||||
kripke_explicit*
|
||||
kripke_parse(const std::string& name,
|
||||
kripke_parse_error_list& error_list,
|
||||
bdd_dict* dict,
|
||||
ltl::environment& env
|
||||
= ltl::default_environment::instance(),
|
||||
bool debug = false);
|
||||
|
||||
|
||||
/// \brief Format diagnostics produced by spot::kripke_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 if any diagnostic was output.
|
||||
bool format_kripke_parse_errors(std::ostream& os,
|
||||
const std::string& filename,
|
||||
kripke_parse_error_list& error_list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* !SPOT_KRIPKEPARSE_PUBLIC_HH_ */
|
||||
117
src/kripkeparse/scankripke.ll
Normal file
117
src/kripkeparse/scankripke.ll
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/* Copyright (C) 2011 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="tgbayy"
|
||||
%option prefix="kripkeyy"
|
||||
%option outfile="lex.yy.c"
|
||||
%x STATE_STRING
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include "parsekripke.tab.hh"
|
||||
|
||||
|
||||
#define YY_USER_ACTION \
|
||||
yylloc->columns(yyleng);
|
||||
|
||||
#define YY_NEVER_INTERACTIVE 1
|
||||
|
||||
typedef kripkeyy::parser::token token;
|
||||
|
||||
|
||||
%}
|
||||
|
||||
eol \n|\r|\n\r|\r\n
|
||||
|
||||
%%
|
||||
|
||||
%{
|
||||
yylloc->step ();
|
||||
%}
|
||||
|
||||
[a-zA-Z][a-zA-Z0-9_]* {
|
||||
yylval->str = new std::string(yytext, yyleng);
|
||||
return token::IDENT;
|
||||
}
|
||||
|
||||
/* discard whitespace */
|
||||
{eol} yylloc->lines(yyleng); yylloc->step();
|
||||
[ \t]+ yylloc->step();
|
||||
|
||||
\" {
|
||||
yylval->str = new std::string;
|
||||
BEGIN(STATE_STRING);
|
||||
}
|
||||
|
||||
"," {
|
||||
return token::COMA;
|
||||
}
|
||||
|
||||
";" return token::SEMICOL;
|
||||
|
||||
. return *yytext;
|
||||
|
||||
/* Handle \" and \\ in strings. */
|
||||
<STATE_STRING>{
|
||||
\" {
|
||||
BEGIN(INITIAL);
|
||||
return token::STRING;
|
||||
}
|
||||
\\["\\] yylval->str->append(1, yytext[1]);
|
||||
[^"\\]+ yylval->str->append(yytext, yyleng);
|
||||
<<EOF>> {
|
||||
BEGIN(INITIAL);
|
||||
return token::UNTERMINATED_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
%{
|
||||
/* Dummy use of yyunput to shut up a gcc warning. */
|
||||
(void) &yyunput;
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
//namespace spot
|
||||
//{
|
||||
int
|
||||
kripkeyyopen(const std::string &name)
|
||||
{
|
||||
if (name == "-")
|
||||
{
|
||||
yyin = stdin;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyin = fopen(name.c_str(), "r");
|
||||
if (!yyin)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
kripkeyyclose()
|
||||
{
|
||||
fclose(yyin);
|
||||
}
|
||||
//}
|
||||
Loading…
Add table
Add a link
Reference in a new issue