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.
This commit is contained in:
parent
a0f5d53ea4
commit
8c2d7fcb7f
25 changed files with 436 additions and 125 deletions
3
NEWS
3
NEWS
|
|
@ -1,5 +1,8 @@
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
## 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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/* Copyright (C) 2008, 2009, 2010, 2011, 2012 Laboratoire de Recherche
|
||||
** et Développement 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
## Copyright (C) 2011 Laboratoire de Recherche et Développement de
|
||||
## Copyright (C) 2011, 2013 Laboratoire de Recherche et Développement 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 = \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// -*- 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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Copyright (C) 2008, 2009, 2010, 2011, 2012 Laboratoire de Recherche
|
||||
## et Développement de l'Epita (LRDE).
|
||||
## Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Laboratoire de
|
||||
## Recherche et Développement de l'Epita (LRDE).
|
||||
## 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.
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// 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)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
/* Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
|
||||
** Développement 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), département Systèmes Répartis Coopératifs (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,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// Copyright (C) 2010, 2012 Laboratoire de Recherche et Développement 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),
|
||||
// département Systèmes Répartis Coopératifs (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 \
|
||||
|
|
|
|||
172
src/misc/location.hh
Normal file
172
src/misc/location.hh
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
// 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
|
||||
169
src/misc/position.hh
Normal file
169
src/misc/position.hh
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
// 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;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
/// (line related) Advance to the COUNT next lines.
|
||||
void lines (int count = 1)
|
||||
{
|
||||
column = 1u;
|
||||
line += count;
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
void columns (int count = 1)
|
||||
{
|
||||
column = std::max (1u, column + count);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
/// File name to which this position refers.
|
||||
std::string* filename;
|
||||
/// Current line number.
|
||||
unsigned int line;
|
||||
/// Current column number.
|
||||
unsigned int column;
|
||||
};
|
||||
|
||||
/// Add and assign a position.
|
||||
inline position&
|
||||
operator+= (position& res, const int width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add two position objects.
|
||||
inline const position
|
||||
operator+ (const position& begin, const int width)
|
||||
{
|
||||
position res = begin;
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Add and assign a position.
|
||||
inline position&
|
||||
operator-= (position& res, const int width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Add two position objects.
|
||||
inline const position
|
||||
operator- (const position& begin, const int width)
|
||||
{
|
||||
return begin + -width;
|
||||
}
|
||||
|
||||
/// Compare two position objects.
|
||||
inline bool
|
||||
operator== (const position& pos1, const position& pos2)
|
||||
{
|
||||
return (pos1.line == pos2.line
|
||||
&& pos1.column == pos2.column
|
||||
&& (pos1.filename == pos2.filename
|
||||
|| (pos1.filename && pos2.filename
|
||||
&& *pos1.filename == *pos2.filename)));
|
||||
}
|
||||
|
||||
/// Compare two position objects.
|
||||
inline bool
|
||||
operator!= (const position& pos1, const position& pos2)
|
||||
{
|
||||
return !(pos1 == pos2);
|
||||
}
|
||||
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param pos a reference to the position to redirect
|
||||
*/
|
||||
template <typename YYChar>
|
||||
inline std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
|
||||
{
|
||||
if (pos.filename)
|
||||
ostr << *pos.filename << ':';
|
||||
return ostr << pos.line << '.' << pos.column;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // SPOT_MISC_POSITION_HH
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
## Copyright (C) 2010, 2011 Laboratoire de Recherche et Développement
|
||||
## de l'Epita (LRDE).
|
||||
## -*- coding: utf-8 -*-
|
||||
## Copyright (C) 2010, 2011, 2013 Laboratoire de Recherche et
|
||||
## Développement de l'Epita (LRDE).
|
||||
##
|
||||
## This file is part of Spot, a model checking library.
|
||||
##
|
||||
|
|
@ -22,10 +23,7 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS:-Werror=)
|
|||
|
||||
neverparsedir = $(pkgincludedir)/neverparse
|
||||
|
||||
neverparse_HEADERS = \
|
||||
public.hh \
|
||||
location.hh \
|
||||
position.hh
|
||||
neverparse_HEADERS = public.hh
|
||||
|
||||
noinst_LTLIBRARIES = libneverparse.la
|
||||
|
||||
|
|
@ -33,8 +31,6 @@ 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)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
%debug
|
||||
%error-verbose
|
||||
%lex-param { spot::neverclaim_parse_error_list& error_list }
|
||||
%define api.location.type "spot::location"
|
||||
|
||||
%code requires
|
||||
{
|
||||
|
|
@ -49,9 +50,6 @@
|
|||
%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.
|
||||
|
|
@ -234,7 +232,7 @@ src_dest: formula opt_dest
|
|||
i != pel.end(); ++i)
|
||||
{
|
||||
// Adjust the diagnostic to the current position.
|
||||
location here = @1;
|
||||
spot::location here = @1;
|
||||
here.end.line = here.begin.line + i->first.end.line - 1;
|
||||
here.end.column = here.begin.column + i->first.end.column -1;
|
||||
here.begin.line += i->first.begin.line - 1;
|
||||
|
|
@ -276,7 +274,7 @@ namespace spot
|
|||
if (neverclaimyyopen(name))
|
||||
{
|
||||
error_list.push_back
|
||||
(neverclaim_parse_error(neverclaimyy::location(),
|
||||
(neverclaim_parse_error(spot::location(),
|
||||
std::string("Cannot open file ") + name));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (C) 2010, 2013 Laboratoire de Recherche et Développement
|
||||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2010, 2013 Laboratoire de Recherche et Développement
|
||||
// de l'EPITA.
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -21,11 +22,11 @@
|
|||
|
||||
#include <string>
|
||||
#include "neverclaimparse.hh"
|
||||
#include "location.hh"
|
||||
#include "misc/location.hh"
|
||||
|
||||
# define YY_DECL \
|
||||
int neverclaimyylex(neverclaimyy::parser::semantic_type *yylval, \
|
||||
neverclaimyy::location *yylloc, \
|
||||
spot::location *yylloc, \
|
||||
spot::neverclaim_parse_error_list& error_list)
|
||||
YY_DECL;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (C) 2010 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2010, 2013 Laboratoire de Recherche et Développement
|
||||
// de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
|
|
@ -20,10 +21,7 @@
|
|||
# define SPOT_NEVERPARSE_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 "misc/location.hh"
|
||||
# include "ltlenv/defaultenv.hh"
|
||||
# include <string>
|
||||
# include <list>
|
||||
|
|
@ -36,7 +34,7 @@ namespace spot
|
|||
/// @{
|
||||
|
||||
/// \brief A parse diagnostic with its location.
|
||||
typedef std::pair<neverclaimyy::location, std::string> neverclaim_parse_error;
|
||||
typedef std::pair<spot::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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
## Copyright (C) 2008, 2009, 2011 Laboratoire de Recherche et
|
||||
## Développement de l'Epita (LRDE).
|
||||
## -*- coding: utf-8 -*-
|
||||
## Copyright (C) 2008, 2009, 2011, 2013 Laboratoire de Recherche et
|
||||
## Développement de l'Epita (LRDE).
|
||||
## Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de
|
||||
## Paris 6 (LIP6), département Systèmes Répartis Coopératifs (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.
|
||||
##
|
||||
|
|
@ -25,10 +26,7 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS:-Werror=)
|
|||
|
||||
tgbaparsedir = $(pkgincludedir)/tgbaparse
|
||||
|
||||
tgbaparse_HEADERS = \
|
||||
public.hh \
|
||||
location.hh \
|
||||
position.hh
|
||||
tgbaparse_HEADERS = public.hh
|
||||
|
||||
noinst_LTLIBRARIES = libtgbaparse.la
|
||||
|
||||
|
|
@ -36,8 +34,6 @@ TGBAPARSE_YY = tgbaparse.yy
|
|||
FROM_TGBAPARSE_YY_MAIN = tgbaparse.cc
|
||||
FROM_TGBAPARSE_YY_OTHERS = \
|
||||
stack.hh \
|
||||
position.hh \
|
||||
location.hh \
|
||||
tgbaparse.hh
|
||||
|
||||
FROM_TGBAPARSE_YY = $(FROM_TGBAPARSE_YY_MAIN) $(FROM_TGBAPARSE_YY_OTHERS)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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.
|
||||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2003, 2005, 2013 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.
|
||||
//
|
||||
|
|
@ -22,11 +23,11 @@
|
|||
|
||||
#include <string>
|
||||
#include "tgbaparse.hh"
|
||||
#include "location.hh"
|
||||
#include "misc/location.hh"
|
||||
|
||||
# define YY_DECL \
|
||||
int tgbayylex (tgbayy::parser::semantic_type *yylval, \
|
||||
tgbayy::location *yylloc)
|
||||
spot::location *yylloc)
|
||||
YY_DECL;
|
||||
|
||||
namespace spot
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2009, 2012 Laboratoire de Recherche et Développement
|
||||
// Copyright (C) 2009, 2012, 2013 Laboratoire de Recherche et Développement
|
||||
// de l'Epita.
|
||||
// Copyright (C) 2003, 2004, 2005, 2006 Laboratoire
|
||||
// d'Informatique de Paris 6 (LIP6), département Systèmes Répartis
|
||||
|
|
@ -24,10 +24,7 @@
|
|||
# define SPOT_TGBAPARSE_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 "tgbaparse/location.hh"
|
||||
# include "misc/location.hh"
|
||||
# include "ltlenv/defaultenv.hh"
|
||||
# include <string>
|
||||
# include <list>
|
||||
|
|
@ -41,7 +38,7 @@ namespace spot
|
|||
|
||||
#ifndef SWIG
|
||||
/// \brief A parse diagnostic with its location.
|
||||
typedef std::pair<tgbayy::location, std::string> tgba_parse_error;
|
||||
typedef std::pair<spot::location, std::string> tgba_parse_error;
|
||||
/// \brief A list of parser diagnostics, as filled by parse.
|
||||
typedef std::list<tgba_parse_error> tgba_parse_error_list;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* -*- coding: utf-8 -*-
|
||||
** Copyright (C) 2009, 2010, 2012 Laboratoire de Recherche et
|
||||
** Copyright (C) 2009, 2010, 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), département Systèmes Répartis Coopératifs (SRC),
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
%name-prefix "tgbayy"
|
||||
%debug
|
||||
%error-verbose
|
||||
%define api.location.type "spot::location"
|
||||
|
||||
%code requires
|
||||
{
|
||||
|
|
@ -55,9 +56,6 @@ typedef std::map<std::string, bdd> formula_cache;
|
|||
%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"
|
||||
#include <map>
|
||||
|
||||
|
|
@ -119,7 +117,7 @@ line: strident ',' strident ',' condition ',' acc_list ';'
|
|||
i != pel.end(); ++i)
|
||||
{
|
||||
// Adjust the diagnostic to the current position.
|
||||
location here = @5;
|
||||
spot::location here = @5;
|
||||
here.end.line = here.begin.line + i->first.end.line - 1;
|
||||
here.end.column =
|
||||
here.begin.column + i->first.end.column;
|
||||
|
|
@ -239,7 +237,7 @@ namespace spot
|
|||
if (tgbayyopen(name))
|
||||
{
|
||||
error_list.push_back
|
||||
(tgba_parse_error(tgbayy::location(),
|
||||
(tgba_parse_error(spot::location(),
|
||||
std::string("Cannot open file ") + name));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue