Add support for ELTL (AST & parser), and an adaptation of LaCIM
for ELTL. This is a new version of the work started in 2008 with LTL and ELTL formulae now sharing the same class hierarchy. * configure.ac: Adjust for src/eltlparse/ and src/eltltest/ directories, and call AX_BOOST_BASE. * m4/boost.m4: New file defining AX_BOOST_BASE([MINIMUM-VERSION]). * src/Makefile.am: Add eltlparse and eltltest. * src/eltlparse/: New directory. Contains the ELTL parser. * src/eltltest/: New directory. Contains tests related to ELTL (parser and AST). * src/ltlast/Makefile.am: Adjust for ELTL AST files. * src/ltlast/automatop.cc, src/ltlast/automatop.hh: New files. Represent automaton operators nodes used in ELTL ASTs. * src/ltlast/nfa.cc, src/ltlast/nfa.hh: New files. Represent simple NFAs used internally by automatop nodes. * src/ltlast/allnode.hh, src/ltlast/predecl.hh, src/ltlast/visitor.hh: Adjust for automatop. * src/ltlvisit/basicreduce.cc, src/ltlvisit/clone.cc, src/ltlvisit/clone.hh, src/ltlvisit/contain.cc, src/ltlvisit/dotty.cc, src/ltlvisit/nenoform.cc, src/ltlvisit/postfix.cc, src/ltlvisit/postfix.hh, src/ltlvisit/reduce.cc, src/ltlvisit/syntimpl.cc, src/ltlvisit/tostring.cc: Because LTL and ELTL formulae share the same class hierarchy, LTL visitors need to handle automatop nodes to compile. When it's meaningful the visitor applies on automatop nodes or simply assert(0) otherwise. * src/tgba/tgbabddconcretefactory.cc (create_anonymous_state), src/tgba/tgbabddconcretefactory.hh (create_anonymous_state): New function used by the LaCIM translation algorithm for ELTL. * src/tgbaalgos/Makefile.am: Adjust for eltl2tgba_lacim* files. * src/tgbaalgos/eltl2tgba_lacim.cc, src/tgbaalgos/eltl2tgba_lacim.hh: New files. Implementation of the LaCIM translation algorithm for ELTL. * src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_lacim.cc: Handle automatop nodes in the translation by an assert(0). * src/tgbatest/Makefile.am: Adjust for eltl2tgba.* files. * src/src/tgbatest/eltl2tgba.cc, src/tgbatest/eltl2tgba.test: New files
This commit is contained in:
parent
90332d8d77
commit
2fbcd7e52f
46 changed files with 2509 additions and 3 deletions
208
src/eltlparse/eltlscan.ll
Normal file
208
src/eltlparse/eltlscan.ll
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
/* Copyright (C) 2008 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="eltlyy"
|
||||
%option outfile="lex.yy.c"
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include <stack>
|
||||
#include "eltlparse/parsedecl.hh"
|
||||
|
||||
static int _atoi (char* yytext, int base);
|
||||
|
||||
#define YY_USER_ACTION \
|
||||
yylloc->columns(yyleng);
|
||||
|
||||
// Flex uses `0' for end of file. 0 is not a token_type.
|
||||
#define yyterminate() return token::END_OF_FILE
|
||||
|
||||
// Stack for handling include files.
|
||||
typedef std::pair<YY_BUFFER_STATE, std::string> state;
|
||||
std::stack<state> include;
|
||||
|
||||
#define ERROR(Msg) \
|
||||
pe.list_.push_back \
|
||||
(spot::eltl::parse_error(*yylloc, spot::eltl::spair(pe.file_, Msg)))
|
||||
|
||||
typedef eltlyy::parser::token token;
|
||||
|
||||
%}
|
||||
|
||||
eol \n|\r|\n\r|\r\n
|
||||
%s formula
|
||||
%x incl
|
||||
|
||||
%%
|
||||
|
||||
%{
|
||||
yylloc->step();
|
||||
%}
|
||||
|
||||
/* Rules for the automaton definitions part. */
|
||||
|
||||
<INITIAL>"=" return token::EQ;
|
||||
<IINTIAL>"accept" return token::ACC;
|
||||
<INITIAL>[tT][rR][uU][eE] {
|
||||
return token::CONST_TRUE;
|
||||
}
|
||||
<INITIAL>"(" return token::LPAREN;
|
||||
<INITIAL>")" return token::RPAREN;
|
||||
<INITIAL>"%" BEGIN(formula);
|
||||
|
||||
<INITIAL>"include" BEGIN(incl);
|
||||
|
||||
<INITIAL>[a-zA-Z][a-zA-Z0-9_]* {
|
||||
yylval->sval = new std::string(yytext, yyleng);
|
||||
return token::IDENT;
|
||||
}
|
||||
|
||||
<INITIAL>[0-9]+ {
|
||||
// Out of range is checked in the parser.
|
||||
yylval->ival = _atoi(yytext, 10);
|
||||
return token::STATE;
|
||||
}
|
||||
|
||||
<INITIAL>$[0-9]+ {
|
||||
// Out of range is checked in the parser.
|
||||
yylval->ival = _atoi(++yytext, 10);
|
||||
return token::ARG;
|
||||
}
|
||||
|
||||
<INITIAL><<EOF>> {
|
||||
if (include.empty())
|
||||
yyterminate();
|
||||
|
||||
state s = include.top();
|
||||
include.pop();
|
||||
pe.file_ = s.second;
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||
yy_switch_to_buffer(s.first);
|
||||
}
|
||||
|
||||
/* Rules for the include part. */
|
||||
|
||||
<incl>[ \t]*
|
||||
<incl>[^ \t\n]+ {
|
||||
FILE* tmp = fopen(yytext, "r");
|
||||
if (!tmp)
|
||||
ERROR(std::string("cannot open file ") + yytext);
|
||||
else
|
||||
{
|
||||
include.push(make_pair(YY_CURRENT_BUFFER, pe.file_));
|
||||
pe.file_ = std::string(yytext);
|
||||
yy_switch_to_buffer(yy_create_buffer(tmp, YY_BUF_SIZE));
|
||||
}
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
|
||||
/* Rules for the formula part. */
|
||||
|
||||
<formula>"(" return token::LPAREN;
|
||||
<formula>")" return token::RPAREN;
|
||||
<formula>"!" return token::OP_NOT;
|
||||
<formula>"," return token::COMMA;
|
||||
|
||||
|
||||
<formula>"1"|[tT][rR][uU][eE] {
|
||||
return token::CONST_TRUE;
|
||||
}
|
||||
<formula>"0"|[fF][aA][lL][sS][eE] {
|
||||
return token::CONST_FALSE;
|
||||
}
|
||||
|
||||
/* & and | come from Spin. && and || from LTL2BA.
|
||||
/\, \/, and xor are from LBTT.
|
||||
*/
|
||||
<formula>"||"|"|"|"+"|"\\/" {
|
||||
return token::OP_OR;
|
||||
}
|
||||
<formula>"&&"|"&"|"."|"*"|"/\\" {
|
||||
return token::OP_AND;
|
||||
}
|
||||
<formula>"^"|"xor" return token::OP_XOR;
|
||||
<formula>"=>"|"->" return token::OP_IMPLIES;
|
||||
<formula>"<=>"|"<->" return token::OP_EQUIV;
|
||||
|
||||
<formula>[a-zA-Z][a-zA-Z0-9_]* {
|
||||
yylval->sval = new std::string(yytext, yyleng);
|
||||
return token::ATOMIC_PROP;
|
||||
}
|
||||
|
||||
/* Global rules. */
|
||||
|
||||
/* discard whitespace */
|
||||
{eol} yylloc->lines(yyleng); yylloc->step();
|
||||
[ \t]+ yylloc->step();
|
||||
|
||||
. return *yytext;
|
||||
|
||||
|
||||
%{
|
||||
/* Dummy use of yyunput to shut up a gcc warning. */
|
||||
(void) &yyunput;
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
namespace spot
|
||||
{
|
||||
namespace eltl
|
||||
{
|
||||
int
|
||||
flex_open(const std::string &name)
|
||||
{
|
||||
if (name == "-")
|
||||
yyin = stdin;
|
||||
else
|
||||
{
|
||||
yyin = fopen(name.c_str(), "r");
|
||||
if (!yyin)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
flex_close()
|
||||
{
|
||||
fclose(yyin);
|
||||
}
|
||||
|
||||
void
|
||||
flex_scan_string(const char* s)
|
||||
{
|
||||
yy_scan_string(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_atoi(char* yytext, int base)
|
||||
{
|
||||
errno = 0;
|
||||
long i = strtol(yytext, 0, base);
|
||||
if (i > std::numeric_limits<long>::max() ||
|
||||
i < std::numeric_limits<long>::min() || errno == ERANGE)
|
||||
return -1;
|
||||
return i;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue