Commit bbd526ac authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Modernize Bison parsers.

* src/ltlparse/ltlparse.yy, src/tgbaparse/tgbaparse.yy,
src/evtgbaparse/evtgbaparse.yy, src/eltlparse/eltlparse.yy: Use
token types for %destructor and %printer.  Remove the yylex hack,
since %name-prefix is now honored by Bison.  Also remove the
useless <token> type.  Suggested by Akim Demaille.
parent d71ceb3b
2010-04-07 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Modernize Bison parsers.
* src/ltlparse/ltlparse.yy, src/tgbaparse/tgbaparse.yy,
src/evtgbaparse/evtgbaparse.yy, src/eltlparse/eltlparse.yy: Use
token types for %destructor and %printer. Remove the yylex hack,
since %name-prefix is now honored by Bison. Also remove the
useless <token> type. Suggested by Akim Demaille.
2010-03-10 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Fix column in LTL error messages, it was off by one.
......
/* Copyright (C) 2008, 2009 Laboratoire de Recherche et Développement
** de l'Epita (LRDE).
/* Copyright (C) 2008, 2009, 2010 Laboratoire de Recherche et
** Dveloppement de l'Epita (LRDE).
**
** This file is part of Spot, a model checking library.
**
......@@ -230,10 +230,10 @@ using namespace spot::ltl;
%type <pval> nfa_arg
%type <bval> nfa_arg_list
%destructor { delete $$; } "atomic proposition"
%destructor { $$->destroy(); } subformula
%destructor { delete $$; } <sval>
%destructor { $$->destroy(); } <fval>
%printer { debug_stream() << *$$; } "atomic proposition"
%printer { debug_stream() << *$$; } <sval>
%%
......
/* Copyright (C) 2009 Laboratoire de Recherche et Dveloppement
/* Copyright (C) 2009, 2010 Laboratoire de Recherche et Dveloppement
** de l'Epita (LRDE).
/* Copyright (C) 2004, 2005, 2006 Laboratoire d'Informatique de
** Copyright (C) 2004, 2005, 2006 Laboratoire d'Informatique de
** Paris 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
** Universit Pierre et Marie Curie.
**
......@@ -50,11 +50,6 @@
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
......@@ -64,11 +59,9 @@
%token ACC_DEF
%token INIT_DEF
%destructor { delete $$; } STRING UNTERMINATED_STRING IDENT
strident string acc_list
%destructor { delete $$; } <str>
%printer { debug_stream() << *$$; } STRING UNTERMINATED_STRING IDENT
strident string
%printer { debug_stream() << *$$; } <str>
%%
evtgba: lines
......
/* Copyright (C) 2009, 2010 Laboratoire de Recherche et Dveloppement
** de l'Epita (LRDE).
/* Copyright (C) 2003, 2004, 2005, 2006 Laboratoire d'Informatique de
/* Copyright (C) 2010 Laboratoire de Recherche et Dveloppement 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.
**
......@@ -40,7 +42,6 @@
%parse-param {spot::ltl::formula* &result}
%union
{
int token;
std::string* str;
spot::ltl::formula* ltl;
}
......@@ -52,11 +53,6 @@
#include "parsedecl.hh"
using namespace spot::ltl;
/* Ugly hack so that Bison uses ltlyylex, not yylex.
(%name-prefix doesn't work for the lalr1.cc skeleton
at the time of writing.) */
#define yylex ltlyylex
#define missing_right_op(res, op, str) \
do \
{ \
......@@ -79,13 +75,13 @@ using namespace spot::ltl;
/* All tokens. */
%token <token> PAR_OPEN "opening parenthesis" PAR_CLOSE "closing parenthesis"
%token <token> OP_OR "or operator" OP_XOR "xor operator" OP_AND "and operator"
%token <token> OP_IMPLIES "implication operator" OP_EQUIV "equivalent operator"
%token <token> OP_U "until operator" OP_R "release operator"
%token <token> OP_F "sometimes operator" OP_G "always operator"
%token <token> OP_X "next operator"
%token <str> ATOMIC_PROP "atomic proposition" OP_NOT "not operator"
%token PAR_OPEN "opening parenthesis" PAR_CLOSE "closing parenthesis"
%token OP_OR "or operator" OP_XOR "xor operator" OP_AND "and operator"
%token OP_IMPLIES "implication operator" OP_EQUIV "equivalent operator"
%token OP_U "until operator" OP_R "release operator"
%token OP_F "sometimes operator" OP_G "always operator"
%token OP_X "next operator" OP_NOT "not operator"
%token <str> ATOMIC_PROP "atomic proposition"
%token CONST_TRUE "constant true" CONST_FALSE "constant false"
%token END_OF_INPUT "end of formula"
%token OP_POST_NEG "negative suffix" OP_POST_POS "positive suffix"
......@@ -110,14 +106,10 @@ using namespace spot::ltl;
%type <ltl> subformula
/* At the time of writing (2004-01-05) there is a bug in CVS Bison: if
you give a token (such a ATOMIC_PROP) a name (such as "atomic
proposition"), then the %destructor should refer to that name.
References to ATOMIC_PROP are silently ignored. */
%destructor { delete $$; } "atomic proposition"
%destructor { $$->destroy(); } subformula
%destructor { delete $$; } <str>
%destructor { $$->destroy(); } <ltl>
%printer { debug_stream() << *$$; } "atomic proposition"
%printer { debug_stream() << *$$; } <str>
%%
result: subformula END_OF_INPUT
......
/* Copyright (C) 2009 Laboratoire de Recherche et Développement
/* Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
** de l'Epita (LRDE).
/* Copyright (C) 2003, 2004, 2005, 2006 Laboratoire d'Informatique de
** 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.
**
......@@ -68,11 +68,6 @@ typedef std::map<std::string, bdd> formula_cache;
#include "parsedecl.hh"
using namespace spot::ltl;
/* 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 tgbayylex
typedef std::pair<bool, spot::ltl::formula*> pair;
}
......@@ -83,17 +78,15 @@ typedef std::pair<bool, spot::ltl::formula*> pair;
%type <list> acc_list
%token ACC_DEF
%destructor { delete $$; } STRING UNTERMINATED_STRING IDENT
strident string condition
%destructor { delete $$; } <str>
%destructor {
for (std::list<spot::ltl::formula*>::iterator i = $$->begin();
i != $$->end(); ++i)
(*i)->destroy();
delete $$;
} acc_list
} <list>
%printer { debug_stream() << *$$; } STRING UNTERMINATED_STRING IDENT
strident string condition
%printer { debug_stream() << *$$; } <str>
%%
tgba: acceptance_decl lines
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment