From bbd526ac81cccbec7a8ed196e8818e17716ca106 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Wed, 7 Apr 2010 16:47:40 +0200 Subject: [PATCH] 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 type. Suggested by Akim Demaille. --- ChangeLog | 10 ++++++++++ src/eltlparse/eltlparse.yy | 10 +++++----- src/evtgbaparse/evtgbaparse.yy | 15 ++++----------- src/ltlparse/ltlparse.yy | 34 +++++++++++++--------------------- src/tgbaparse/tgbaparse.yy | 17 +++++------------ 5 files changed, 37 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 752b2a1aa..0020bd13c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-04-07 Alexandre Duret-Lutz + + 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 type. Suggested by Akim Demaille. + 2010-03-10 Alexandre Duret-Lutz Fix column in LTL error messages, it was off by one. diff --git a/src/eltlparse/eltlparse.yy b/src/eltlparse/eltlparse.yy index 529c0d183..2ab4971e2 100644 --- a/src/eltlparse/eltlparse.yy +++ b/src/eltlparse/eltlparse.yy @@ -1,5 +1,5 @@ -/* Copyright (C) 2008, 2009 Laboratoire de Recherche et Développement -** de l'Epita (LRDE). +/* Copyright (C) 2008, 2009, 2010 Laboratoire de Recherche et +** Développement de l'Epita (LRDE). ** ** This file is part of Spot, a model checking library. ** @@ -230,10 +230,10 @@ using namespace spot::ltl; %type nfa_arg %type nfa_arg_list -%destructor { delete $$; } "atomic proposition" -%destructor { $$->destroy(); } subformula +%destructor { delete $$; } +%destructor { $$->destroy(); } -%printer { debug_stream() << *$$; } "atomic proposition" +%printer { debug_stream() << *$$; } %% diff --git a/src/evtgbaparse/evtgbaparse.yy b/src/evtgbaparse/evtgbaparse.yy index dd14fb2a8..ed90a8fd8 100644 --- a/src/evtgbaparse/evtgbaparse.yy +++ b/src/evtgbaparse/evtgbaparse.yy @@ -1,6 +1,6 @@ -/* 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) 2004, 2005, 2006 Laboratoire d'Informatique de +** Copyright (C) 2004, 2005, 2006 Laboratoire d'Informatique de ** Paris 6 (LIP6), département Systèmes Répartis Coopératifs (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 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 $$; } -%printer { debug_stream() << *$$; } STRING UNTERMINATED_STRING IDENT - strident string +%printer { debug_stream() << *$$; } %% evtgba: lines diff --git a/src/ltlparse/ltlparse.yy b/src/ltlparse/ltlparse.yy index ff4874a7a..71ec3819d 100644 --- a/src/ltlparse/ltlparse.yy +++ b/src/ltlparse/ltlparse.yy @@ -1,6 +1,8 @@ /* 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) 2010 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. ** @@ -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 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" -%token 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 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 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 $$; } +%destructor { $$->destroy(); } -%printer { debug_stream() << *$$; } "atomic proposition" +%printer { debug_stream() << *$$; } %% result: subformula END_OF_INPUT diff --git a/src/tgbaparse/tgbaparse.yy b/src/tgbaparse/tgbaparse.yy index 7bbce303c..351d80622 100644 --- a/src/tgbaparse/tgbaparse.yy +++ b/src/tgbaparse/tgbaparse.yy @@ -1,6 +1,6 @@ -/* 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 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 pair; } @@ -83,17 +78,15 @@ typedef std::pair pair; %type acc_list %token ACC_DEF -%destructor { delete $$; } STRING UNTERMINATED_STRING IDENT - strident string condition +%destructor { delete $$; } %destructor { for (std::list::iterator i = $$->begin(); i != $$->end(); ++i) (*i)->destroy(); delete $$; - } acc_list + } -%printer { debug_stream() << *$$; } STRING UNTERMINATED_STRING IDENT - strident string condition +%printer { debug_stream() << *$$; } %% tgba: acceptance_decl lines