Commit 8c2d7fcb authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

Use the same location.hh and position.hh in all parsers.

* src/misc/location.hh, src/misc/position.hh: New files,
from Bison 2.7.
* src/misc/Makefile.am: Distribute them.
* src/eltlparse/Makefile.am, src/eltlparse/eltlparse.yy,
src/eltlparse/parsedecl.hh, src/eltlparse/public.hh,
src/kripkeparse/Makefile.am, src/kripkeparse/kripkeparse.yy,
src/kripkeparse/parsedecl.hh, src/kripkeparse/public.hh,
src/ltlparse/Makefile.am, src/ltlparse/fmterror.cc,
src/ltlparse/ltlparse.yy, src/ltlparse/parsedecl.hh,
src/ltlparse/public.hh, src/neverparse/Makefile.am,
src/neverparse/neverclaimparse.yy, src/neverparse/parsedecl.hh,
src/neverparse/public.hh, src/tgbaparse/Makefile.am,
src/tgbaparse/parsedecl.hh, src/tgbaparse/public.hh,
src/tgbaparse/tgbaparse.yy: Adjust to use and include
misc/location.hh.
* NEWS: Mention this change.
parent a0f5d53e
New in spot 1.1.4a (not relased)
* All the parsers implemented in Spot now use the same type
to store locations.
* Cleanup of exported symbols
All symbols in the library now have hidden visibility on ELF systems.
......
## Copyright (C) 2008, 2011 Laboratoire de Recherche et Développement
## de l'Epita (LRDE).
## -*- coding: utf-8 -*-
## Copyright (C) 2008, 2011, 2013 Laboratoire de Recherche et
## Développement de l'Epita (LRDE).
##
## This file is part of Spot, a model checking library.
##
......@@ -28,8 +29,6 @@ ELTLPARSE_YY = eltlparse.yy
FROM_ELTLPARSE_YY_MAIN = eltlparse.cc
FROM_ELTLPARSE_YY_OTHERS = \
stack.hh \
position.hh \
location.hh \
eltlparse.hh
FROM_ELTLPARSE_YY = $(FROM_ELTLPARSE_YY_MAIN) $(FROM_ELTLPARSE_YY_OTHERS)
......@@ -54,7 +53,5 @@ libeltlparse_la_SOURCES = \
eltlscan.ll \
parsedecl.hh
eltlparse_HEADERS = \
public.hh \
location.hh \
position.hh
eltlparse_HEADERS = public.hh
/* Copyright (C) 2008, 2009, 2010, 2011, 2012 Laboratoire de Recherche
** et Dveloppement de l'Epita (LRDE).
/* -*- coding: utf-8 -*-
** Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Laboratoire de
** Recherche et Développement de l'Epita (LRDE).
**
** This file is part of Spot, a model checking library.
**
......@@ -22,6 +23,7 @@
%name-prefix "eltlyy"
%debug
%error-verbose
%define api.location.type "spot::location"
%code requires
{
......@@ -527,7 +529,7 @@ namespace spot
if (flex_open(name))
{
error_list.push_back
(parse_error(eltlyy::location(),
(parse_error(spot::location(),
spair("-", std::string("Cannot open file ") + name)));
return 0;
}
......
// Copyright (C) 2008 Laboratoire de Recherche et Développement
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -20,11 +21,11 @@
# define SPOT_ELTLPARSE_PARSEDECL_HH
#include "eltlparse.hh"
#include "location.hh"
#include "misc/location.hh"
# define YY_DECL \
int eltlyylex (eltlyy::parser::semantic_type *yylval, \
eltlyy::location *yylloc, \
spot::location *yylloc, \
spot::eltl::parse_error_list_t &pe)
YY_DECL;
......
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2010, 2012 Laboratoire de Recherche et
// Copyright (C) 2008, 2010, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -21,23 +21,15 @@
# define SPOT_ELTLPARSE_PUBLIC_HH
# include "ltlast/formula.hh"
// Unfortunately Bison 2.3 uses the same guards in all parsers :(
# undef BISON_LOCATION_HH
# undef BISON_POSITION_HH
# include "ltlenv/defaultenv.hh"
# include "ltlast/nfa.hh"
# include "eltlparse/location.hh"
# include "misc/location.hh"
# include <string>
# include <list>
# include <map>
# include <utility>
# include <iosfwd>
// namespace
// {
// typedef std::map<std::string, spot::ltl::nfa::ptr> nfamap;
// }
namespace spot
{
using namespace ltl;
......@@ -49,7 +41,7 @@ namespace spot
typedef std::pair<std::string, std::string> spair;
/// \brief A parse diagnostic <location, <file, message>>.
typedef std::pair<eltlyy::location, spair> parse_error;
typedef std::pair<spot::location, spair> parse_error;
/// \brief A list of parser diagnostics, as filled by parse.
typedef std::list<parse_error> parse_error_list;
......
## Copyright (C) 2011 Laboratoire de Recherche et Dveloppement de
## Copyright (C) 2011, 2013 Laboratoire de Recherche et Dveloppement de
## l'Epita (LRDE).
##
## This file is part of Spot, a model checking library.
......@@ -22,10 +22,7 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS:-Werror=)
kripkeparsedir = $(pkgincludedir)/kripkeparse
kripkeparse_HEADERS = \
public.hh \
location.hh \
position.hh
kripkeparse_HEADERS = public.hh
noinst_LTLIBRARIES = libkripkeparse.la
......@@ -33,8 +30,6 @@ 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 = \
......
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE)
// Copyright (C) 2011, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
//
......@@ -24,6 +24,7 @@
%name-prefix "kripkeyy"
%debug
%error-verbose
%define api.location.type "spot::location"
%code requires
{
......@@ -54,9 +55,6 @@ typedef std::map<std::string, bdd> formula_cache;
%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>
......@@ -117,7 +115,7 @@ strident "," condition "," follow_list ";"
i != pel.end(); ++i)
{
//Adjust the diagnostic to the current position.
location here = @3;
spot::location here = @3;
here.end.line = here.begin.line + i->first.end.line - 1;
here.end.column =
here.begin.column + i->first.end.column;
......@@ -209,8 +207,8 @@ namespace spot
if (kripkeyyopen(name))
{
error_list.push_back
(kripke_parse_error(kripkeyy::location(),
std::string("Cannot open file ") + name));
(kripke_parse_error(spot::location(),
std::string("Cannot open file ") + name));
return 0;
}
formula_cache fcache;
......
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2013 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
......@@ -22,11 +23,11 @@
# include <string>
# include "kripkeparse.hh"
# include "location.hh"
# include "misc/location.hh"
# define YY_DECL \
int kripkeyylex (kripkeyy::parser::semantic_type *yylval, \
kripkeyy::location *yylloc)
spot::location *yylloc)
YY_DECL;
......
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
// Copyright (C) 2011, 2013 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
......@@ -21,10 +21,7 @@
# 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 "misc/location.hh"
# include "ltlenv/defaultenv.hh"
# include <string>
# include <list>
......@@ -35,7 +32,7 @@ namespace spot
{
/// \brief A parse diagnostic with its location.
typedef std::pair<kripkeyy::location, std::string> kripke_parse_error;
typedef std::pair<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;
......
## Copyright (C) 2008, 2009, 2010, 2011, 2012 Laboratoire de Recherche
## et Dveloppement de l'Epita (LRDE).
## Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Laboratoire de
## Recherche et Dveloppement de l'Epita (LRDE).
## Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris
## 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
## Universit Pierre et Marie Curie.
......@@ -31,8 +31,6 @@ LTLPARSE_YY = ltlparse.yy
FROM_LTLPARSE_YY_MAIN = ltlparse.cc
FROM_LTLPARSE_YY_OTHERS = \
stack.hh \
position.hh \
location.hh \
ltlparse.hh
FROM_LTLPARSE_YY = $(FROM_LTLPARSE_YY_MAIN) $(FROM_LTLPARSE_YY_OTHERS)
......@@ -60,6 +58,5 @@ libltlparse_la_SOURCES = \
ltlparse_HEADERS = \
ltlfile.hh \
location.hh \
public.hh \
position.hh
public.hh
// Copyright (C) 2010, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2010, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2003, 2004, 2005 Laboratoire d'Informatique de Paris
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
......@@ -60,7 +60,7 @@ namespace spot
parse_error_list::iterator it;
for (it = error_list.begin(); it != error_list.end(); ++it)
{
ltlyy::location& l = it->first;
location& l = it->first;
l.begin.column = b2u[l.begin.column];
l.end.column = b2u[l.end.column];
}
......@@ -78,7 +78,7 @@ namespace spot
for (it = error_list.begin(); it != error_list.end(); ++it)
{
os << ">>> " << ltl_string << std::endl;
const ltlyy::location& l = it->first;
const location& l = it->first;
unsigned n = 1;
for (; n < 4 + l.begin.column; ++n)
......
/* Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
** Dveloppement de l'Epita (LRDE).
/* -*- coding: utf-8 -*-
** Copyright (C) 2009, 2010, 2011, 2012, 2013 Laboratoire de Recherche
** et Développement de l'Epita (LRDE).
** Copyright (C) 2003, 2004, 2005, 2006 Laboratoire d'Informatique de
** Paris 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
** Universit Pierre et Marie Curie.
** 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.
**
......@@ -27,6 +28,7 @@
%error-verbose
%expect 0
%lex-param { spot::ltl::parse_error_list& error_list }
%define api.location.type "spot::location"
%code requires
{
......@@ -90,7 +92,7 @@ using namespace spot::ltl;
const formula*
try_recursive_parse(const std::string& str,
const ltlyy::location& location,
const spot::location& location,
spot::ltl::environment& env,
bool debug,
parser_type type,
......
// Copyright (C) 2010, 2012 Laboratoire de Recherche et Dveloppement de
// l'Epita (LRDE)
// -*- coding: utf-8 -*-
// Copyright (C) 2010, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE)
// Copyright (C) 2003, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
// dpartement Systmes Rpartis Coopratifs (SRC), Universit Pierre
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
......@@ -23,11 +24,11 @@
# define SPOT_LTLPARSE_PARSEDECL_HH
#include "ltlparse.hh"
#include "location.hh"
#include "misc/location.hh"
# define YY_DECL \
int ltlyylex (ltlyy::parser::semantic_type *yylval, \
ltlyy::location *yylloc, \
spot::location *yylloc, \
spot::ltl::parse_error_list& error_list)
YY_DECL;
......
......@@ -24,10 +24,7 @@
# define SPOT_LTLPARSE_PUBLIC_HH
# include "ltlast/formula.hh"
// Unfortunately Bison 2.3 uses the same guards in all parsers :(
# undef BISON_LOCATION_HH
# undef BISON_POSITION_HH
# include "ltlparse/location.hh"
# include "misc/location.hh"
# include "ltlenv/defaultenv.hh"
# include <string>
# include <list>
......@@ -43,7 +40,7 @@ namespace spot
#ifndef SWIG
/// \brief A parse diagnostic with its location.
typedef std::pair<ltlyy::location, std::string> parse_error;
typedef std::pair<location, std::string> parse_error;
/// \brief A list of parser diagnostics, as filled by parse.
typedef std::list<parse_error> parse_error_list;
#else
......
......@@ -41,11 +41,13 @@ misc_HEADERS = \
hashfunc.hh \
intvcomp.hh \
intvcmp2.hh \
location.hh \
ltstr.hh \
minato.hh \
memusage.hh \
mspool.hh \
optionmap.hh \
position.hh \
random.hh \
timer.hh \
unique_ptr.hh \
......
// Note: this file was comped from A Bison parser, made by GNU Bison
// 2.7.12-4996. It is shared by all the parsers in Spot. Unfortunately,
// at the time of writing there is no Bison option to generate this
// file an update it.
/* Locations for Bison parsers in C++
Copyright (C) 2002-2007, 2009-2013 Free Software Foundation, Inc.
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef SPOT_MISC_LOCATION_HH
# define SPOT_MISC_LOCATION_HH
# include "position.hh"
namespace spot
{
/// Abstract a location.
class location
{
public:
/// Construct a location from \a b to \a e.
location (const position& b, const position& e)
: begin (b)
, end (e)
{
}
/// Construct a 0-width location in \a p.
explicit location (const position& p = position ())
: begin (p)
, end (p)
{
}
/// Construct a 0-width location in \a f, \a l, \a c.
explicit location (std::string* f,
unsigned int l = 1u,
unsigned int c = 1u)
: begin (f, l, c)
, end (f, l, c)
{
}
/// Initialization.
void initialize (std::string* f = YY_NULL,
unsigned int l = 1u,
unsigned int c = 1u)
{
begin.initialize (f, l, c);
end = begin;
}
/** \name Line and Column related manipulators
** \{ */
public:
/// Reset initial location to final location.
void step ()
{
begin = end;
}
/// Extend the current location to the COUNT next columns.
void columns (unsigned int count = 1)
{
end += count;
}
/// Extend the current location to the COUNT next lines.
void lines (unsigned int count = 1)
{
end.lines (count);
}
/** \} */
public:
/// Beginning of the located region.
position begin;
/// End of the located region.
position end;
};
/// Join two location objects to create a location.
inline const location operator+ (const location& begin, const location& end)
{
location res = begin;
res.end = end.end;
return res;
}
/// Add two location objects.
inline const location operator+ (const location& begin, unsigned int width)
{
location res = begin;
res.columns (width);
return res;
}
/// Add and assign a location.
inline location& operator+= (location& res, unsigned int width)
{
res.columns (width);
return res;
}
/// Compare two location objects.
inline bool
operator== (const location& loc1, const location& loc2)
{
return loc1.begin == loc2.begin && loc1.end == loc2.end;
}
/// Compare two location objects.
inline bool
operator!= (const location& loc1, const location& loc2)
{
return !(loc1 == loc2);
}
/** \brief Intercept output stream redirection.
** \param ostr the destination output stream
** \param loc a reference to the location to redirect
**
** Avoid duplicate information.
*/
template <typename YYChar>
inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
position last = loc.end - 1;
ostr << loc.begin;
if (last.filename
&& (!loc.begin.filename
|| *loc.begin.filename != *last.filename))
ostr << '-' << last;
else if (loc.begin.line != last.line)
ostr << '-' << last.line << '.' << last.column;
else if (loc.begin.column != last.column)
ostr << '-' << last.column;
return ostr;
}
}
#endif // SPOT_MISC_LOCATION_HH
// Note: this file was comped from A Bison parser, made by GNU Bison
// 2.7.12-4996. It is shared by all the parsers in Spot. Unfortunately,
// at the time of writing there is no Bison option to generate this
// file an update it.
/* Positions for Bison parsers in C++
Copyright (C) 2002-2007, 2009-2013 Free Software Foundation, Inc.
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef SPOT_MISC_POSITION_HH
# define SPOT_MISC_POSITION_HH
# include <algorithm> // std::max
# include <iostream>
# include <string>
# ifndef YY_NULL
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULL nullptr
# else
# define YY_NULL 0
# endif
# endif
namespace spot
{
/// Abstract a position.
class position
{
public:
/// Construct a position.
explicit position (std::string* f = YY_NULL,
unsigned int l = 1u,
unsigned int c = 1u)
: filename (f)
, line (l)
, column (c)
{
}
/// Initialization.
void initialize (std::string* fn = YY_NULL,
unsigned int l = 1u,
unsigned int c = 1u)
{
filename = fn;
line = l;
column = c;
}