* src/evtgbatest/evtgbaparse.yy, src/evtgbaparse/evtgbascan.ll,

src/evtgbaparse/parsedecl.hh, src/evtgbaparse/public.hh,
src/ltlparse/fmterror.cc, src/ltlparse/ltlparse.yy,
src/ltlparse/ltlscan.ll, src/ltlparse/parsedecl.hh,
src/ltlparse/public.hh, src/tgbaparse/parsedecl.hh,
src/tgbaparse/public.hh, src/tgbaparse/tgbaparse.yy,
src/tgbaparse/tgbascan.ll: Adjust for Bison 2.3.  Use %name-prefix
instead of the "#define yy ... " kludge.
This commit is contained in:
Alexandre Duret-Lutz 2006-08-01 16:35:06 +00:00
parent db98955e9d
commit c055212326
14 changed files with 86 additions and 70 deletions

View file

@ -1,3 +1,14 @@
2006-08-01 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/evtgbatest/evtgbaparse.yy, src/evtgbaparse/evtgbascan.ll,
src/evtgbaparse/parsedecl.hh, src/evtgbaparse/public.hh,
src/ltlparse/fmterror.cc, src/ltlparse/ltlparse.yy,
src/ltlparse/ltlscan.ll, src/ltlparse/parsedecl.hh,
src/ltlparse/public.hh, src/tgbaparse/parsedecl.hh,
src/tgbaparse/public.hh, src/tgbaparse/tgbaparse.yy,
src/tgbaparse/tgbascan.ll: Adjust for Bison 2.3. Use %name-prefix
instead of the "#define yy ... " kludge.
2006-07-24 Alexandre Duret-Lutz <adl@src.lip6.fr> 2006-07-24 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/ltlvisit/contain.hh, src/ltlvisit/contain.cc: Adjust to only * src/ltlvisit/contain.hh, src/ltlvisit/contain.cc: Adjust to only

View file

@ -25,6 +25,7 @@
#include "evtgba/symbol.hh" #include "evtgba/symbol.hh"
%} %}
%name-prefix="evtgbayy"
%parse-param {spot::evtgba_parse_error_list &error_list} %parse-param {spot::evtgba_parse_error_list &error_list}
%parse-param {spot::evtgba_explicit* &result} %parse-param {spot::evtgba_explicit* &result}
%debug %debug
@ -120,7 +121,8 @@ init_decl:
%% %%
void void
yy::parser::error(const location_type& location, const std::string& message) evtgbayy::parser::error(const location_type& location,
const std::string& message)
{ {
error_list.push_back(spot::evtgba_parse_error(location, message)); error_list.push_back(spot::evtgba_parse_error(location, message));
} }
@ -135,7 +137,7 @@ namespace spot
if (evtgbayyopen(name)) if (evtgbayyopen(name))
{ {
error_list.push_back error_list.push_back
(evtgba_parse_error(yy::location(), (evtgba_parse_error(evtgbayy::location(),
std::string("Cannot open file ") + name)); std::string("Cannot open file ") + name));
return 0; return 0;
} }

View file

@ -33,6 +33,7 @@
#define YY_NEVER_INTERACTIVE 1 #define YY_NEVER_INTERACTIVE 1
typedef evtgbayy::parser::token token;
%} %}
eol \n|\r|\n\r|\r\n eol \n|\r|\n\r|\r\n
@ -43,12 +44,12 @@ eol \n|\r|\n\r|\r\n
yylloc->step (); yylloc->step ();
%} %}
acc[ \t]*= return ACC_DEF; acc[ \t]*= return token::ACC_DEF;
init[ \t]*= return INIT_DEF; init[ \t]*= return token::INIT_DEF;
[a-zA-Z][a-zA-Z0-9_]* { [a-zA-Z][a-zA-Z0-9_]* {
yylval->str = new std::string(yytext); yylval->str = new std::string(yytext);
return IDENT; return token::IDENT;
} }
/* discard whitespace */ /* discard whitespace */
@ -66,13 +67,13 @@ init[ \t]*= return INIT_DEF;
<STATE_STRING>{ <STATE_STRING>{
\" { \" {
BEGIN(INITIAL); BEGIN(INITIAL);
return STRING; return token::STRING;
} }
\\["\\] yylval->str->append(1, yytext[1]); \\["\\] yylval->str->append(1, yytext[1]);
[^"\\]+ yylval->str->append(yytext, yyleng); [^"\\]+ yylval->str->append(yytext, yyleng);
<<EOF>> { <<EOF>> {
BEGIN(INITIAL); BEGIN(INITIAL);
return UNTERMINATED_STRING; return token::UNTERMINATED_STRING;
} }
} }

View file

@ -27,7 +27,8 @@
#include "location.hh" #include "location.hh"
# define YY_DECL \ # define YY_DECL \
int evtgbayylex (yystype *yylval, yy::location *yylloc) int evtgbayylex (evtgbayy::parser::semantic_type *yylval, \
evtgbayy::location *yylloc)
YY_DECL; YY_DECL;
namespace spot namespace spot
@ -37,17 +38,4 @@ namespace spot
} }
// Gross kludge to compile yy::Parser in another namespace (tgbayy::)
// but still use yy::Location. The reason is that Bison's C++
// skeleton does not support anything close to %name-prefix at the
// moment. All parser are named yy::Parser which makes it somewhat
// difficult to define multiple parsers.
namespace evtgbayy
{
using namespace yy;
}
#define yy evtgbayy
#endif // SPOT_EVTGBAPARSE_PARSEDECL_HH #endif // SPOT_EVTGBAPARSE_PARSEDECL_HH

View file

@ -23,7 +23,7 @@
# define SPOT_EVTGBAPARSE_PUBLIC_HH # define SPOT_EVTGBAPARSE_PUBLIC_HH
# include "evtgba/explicit.hh" # include "evtgba/explicit.hh"
# include "ltlparse/location.hh" # include "location.hh"
# include <string> # include <string>
# include <list> # include <list>
# include <utility> # include <utility>
@ -32,7 +32,7 @@
namespace spot namespace spot
{ {
/// \brief A parse diagnostic with its location. /// \brief A parse diagnostic with its location.
typedef std::pair<yy::location, std::string> evtgba_parse_error; typedef std::pair<evtgbayy::location, std::string> evtgba_parse_error;
/// \brief A list of parser diagnostics, as filled by parse. /// \brief A list of parser diagnostics, as filled by parse.
typedef std::list<evtgba_parse_error> evtgba_parse_error_list; typedef std::list<evtgba_parse_error> evtgba_parse_error_list;

View file

@ -37,7 +37,7 @@ namespace spot
for (it = error_list.begin(); it != error_list.end(); ++it) for (it = error_list.begin(); it != error_list.end(); ++it)
{ {
os << ">>> " << ltl_string << std::endl; os << ">>> " << ltl_string << std::endl;
yy::location& l = it->first; ltlyy::location& l = it->first;
unsigned n = 0; unsigned n = 0;
for (; n < 4 + l.begin.column; ++n) for (; n < 4 + l.begin.column; ++n)

View file

@ -27,6 +27,7 @@
%} %}
%name-prefix="ltlyy"
%parse-param {spot::ltl::parse_error_list &error_list} %parse-param {spot::ltl::parse_error_list &error_list}
%parse-param {spot::ltl::environment &parse_environment} %parse-param {spot::ltl::environment &parse_environment}
%parse-param {spot::ltl::formula* &result} %parse-param {spot::ltl::formula* &result}
@ -262,7 +263,7 @@ subformula: ATOMIC_PROP
%% %%
void void
yy::parser::error(const location_type& location, const std::string& message) ltlyy::parser::error(const location_type& location, const std::string& message)
{ {
error_list.push_back(parse_error(location, message)); error_list.push_back(parse_error(location, message));
} }
@ -279,7 +280,7 @@ namespace spot
{ {
formula* result = 0; formula* result = 0;
flex_set_buffer(ltl_string.c_str()); flex_set_buffer(ltl_string.c_str());
yy::parser parser(error_list, env, result); ltlyy::parser parser(error_list, env, result);
parser.set_debug_level(debug); parser.set_debug_level(debug);
parser.parse(); parser.parse();
return result; return result;

View file

@ -42,6 +42,8 @@
static const char* to_parse = 0; static const char* to_parse = 0;
static size_t to_parse_size = 0; static size_t to_parse_size = 0;
typedef ltlyy::parser::token token;
void void
flex_set_buffer(const char* buf) flex_set_buffer(const char* buf)
{ {
@ -59,36 +61,36 @@ flex_set_buffer(const char* buf)
yylloc->step(); yylloc->step();
%} %}
"(" BEGIN(0); return PAR_OPEN; "(" BEGIN(0); return token::PAR_OPEN;
")" BEGIN(not_prop); return PAR_CLOSE; ")" BEGIN(not_prop); return token::PAR_CLOSE;
/* Must go before the other operators, because the F of FALSE /* Must go before the other operators, because the F of FALSE
should not be mistaken with a unary F. */ should not be mistaken with a unary F. */
"1"|[tT][rR][uU][eE] BEGIN(0); return CONST_TRUE; "1"|[tT][rR][uU][eE] BEGIN(0); return token::CONST_TRUE;
"0"|[fF][aA][lL][sS][eE] BEGIN(0); return CONST_FALSE; "0"|[fF][aA][lL][sS][eE] BEGIN(0); return token::CONST_FALSE;
"!" BEGIN(0); return OP_NOT; "!" BEGIN(0); return token::OP_NOT;
/* & and | come from Spin. && and || from LTL2BA. /* & and | come from Spin. && and || from LTL2BA.
/\, \/, and xor are from LBTT. /\, \/, and xor are from LBTT.
*/ */
"||"|"|"|"+"|"\\/" BEGIN(0); return OP_OR; "||"|"|"|"+"|"\\/" BEGIN(0); return token::OP_OR;
"&&"|"&"|"."|"*"|"/\\" BEGIN(0); return OP_AND; "&&"|"&"|"."|"*"|"/\\" BEGIN(0); return token::OP_AND;
"^"|"xor" BEGIN(0); return OP_XOR; "^"|"xor" BEGIN(0); return token::OP_XOR;
"=>"|"->" BEGIN(0); return OP_IMPLIES; "=>"|"->" BEGIN(0); return token::OP_IMPLIES;
"<=>"|"<->" BEGIN(0); return OP_EQUIV; "<=>"|"<->" BEGIN(0); return token::OP_EQUIV;
/* <>, [], and () are used in Spin. */ /* <>, [], and () are used in Spin. */
"F"|"<>" BEGIN(0); return OP_F; "F"|"<>" BEGIN(0); return token::OP_F;
"G"|"[]" BEGIN(0); return OP_G; "G"|"[]" BEGIN(0); return token::OP_G;
"U" BEGIN(0); return OP_U; "U" BEGIN(0); return token::OP_U;
"R"|"V" BEGIN(0); return OP_R; "R"|"V" BEGIN(0); return token::OP_R;
"X"|"()" BEGIN(0); return OP_X; "X"|"()" BEGIN(0); return token::OP_X;
"=0" return OP_POST_NEG; "=0" return token::OP_POST_NEG;
"=1" return OP_POST_POS; "=1" return token::OP_POST_POS;
[ \t\n]+ /* discard whitespace */ yylloc->step (); [ \t\n]+ /* discard whitespace */ yylloc->step ();
@ -118,7 +120,7 @@ flex_set_buffer(const char* buf)
<not_prop>[a-zA-EH-QSTWYZ_][a-zA-EH-WYZ0-9_][a-zA-Z0-9_]* { <not_prop>[a-zA-EH-QSTWYZ_][a-zA-EH-WYZ0-9_][a-zA-Z0-9_]* {
yylval->str = new std::string(yytext, yyleng); yylval->str = new std::string(yytext, yyleng);
BEGIN(not_prop); BEGIN(not_prop);
return ATOMIC_PROP; return token::ATOMIC_PROP;
} }
/* Atomic propositions can also be enclosed in double quotes. */ /* Atomic propositions can also be enclosed in double quotes. */
@ -126,12 +128,12 @@ flex_set_buffer(const char* buf)
yylval->str = new std::string(yytext + 1, yylval->str = new std::string(yytext + 1,
yyleng - 2); yyleng - 2);
BEGIN(not_prop); BEGIN(not_prop);
return ATOMIC_PROP; return token::ATOMIC_PROP;
} }
. return *yytext; . return *yytext;
<<EOF>> return END_OF_INPUT; <<EOF>> return token::END_OF_INPUT;
%{ %{
/* Dummy use of yyunput to shut up a gcc warning. */ /* Dummy use of yyunput to shut up a gcc warning. */

View file

@ -26,7 +26,7 @@
#include "location.hh" #include "location.hh"
# define YY_DECL \ # define YY_DECL \
int ltlyylex (yystype *yylval, yy::location *yylloc) int ltlyylex (ltlyy::parser::semantic_type *yylval, ltlyy::location *yylloc)
YY_DECL; YY_DECL;
void flex_set_buffer(const char *buf); void flex_set_buffer(const char *buf);

View file

@ -23,7 +23,7 @@
# define SPOT_LTLPARSE_PUBLIC_HH # define SPOT_LTLPARSE_PUBLIC_HH
# include "ltlast/formula.hh" # include "ltlast/formula.hh"
# include "location.hh" # include "ltlparse/location.hh"
# include "ltlenv/defaultenv.hh" # include "ltlenv/defaultenv.hh"
# include <string> # include <string>
# include <list> # include <list>
@ -38,7 +38,7 @@ namespace spot
/// @{ /// @{
/// \brief A parse diagnostic with its location. /// \brief A parse diagnostic with its location.
typedef std::pair<yy::location, std::string> parse_error; typedef std::pair<ltlyy::location, std::string> parse_error;
/// \brief A list of parser diagnostics, as filled by parse. /// \brief A list of parser diagnostics, as filled by parse.
typedef std::list<parse_error> parse_error_list; typedef std::list<parse_error> parse_error_list;

View file

@ -27,7 +27,8 @@
#include "location.hh" #include "location.hh"
# define YY_DECL \ # define YY_DECL \
int tgbayylex (yystype *yylval, yy::location *yylloc) int tgbayylex (tgbayy::parser::semantic_type *yylval, \
tgbayy::location *yylloc)
YY_DECL; YY_DECL;
namespace spot namespace spot
@ -42,11 +43,11 @@ namespace spot
// skeleton does not support anything close to %name-prefix at the // skeleton does not support anything close to %name-prefix at the
// moment. All parser are named yy::Parser which makes it somewhat // moment. All parser are named yy::Parser which makes it somewhat
// difficult to define multiple parsers. // difficult to define multiple parsers.
namespace tgbayy // namespace tgbayy
{ // {
using namespace yy; // using namespace yy;
} // }
#define yy tgbayy // #define yy tgbayy

View file

@ -23,7 +23,10 @@
# define SPOT_TGBAPARSE_PUBLIC_HH # define SPOT_TGBAPARSE_PUBLIC_HH
# include "tgba/tgbaexplicit.hh" # include "tgba/tgbaexplicit.hh"
# include "ltlparse/location.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 "ltlenv/defaultenv.hh" # include "ltlenv/defaultenv.hh"
# include <string> # include <string>
# include <list> # include <list>
@ -36,7 +39,7 @@ namespace spot
/// @{ /// @{
/// \brief A parse diagnostic with its location. /// \brief A parse diagnostic with its location.
typedef std::pair<yy::location, std::string> tgba_parse_error; typedef std::pair<tgbayy::location, std::string> tgba_parse_error;
/// \brief A list of parser diagnostics, as filled by parse. /// \brief A list of parser diagnostics, as filled by parse.
typedef std::list<tgba_parse_error> tgba_parse_error_list; typedef std::list<tgba_parse_error> tgba_parse_error_list;

View file

@ -22,8 +22,15 @@
%{ %{
#include <string> #include <string>
#include "public.hh" #include "public.hh"
/* Cache parsed formulae. Labels on arcs are frequently identical and
it would be a waste of time to parse them to formula* over and
over, and to register all their atomic_propositions in the
bdd_dict. Keep the bdd result around so we can reuse it. */
typedef std::map<std::string, bdd> formula_cache;
%} %}
%name-prefix="tgbayy"
%parse-param {spot::tgba_parse_error_list& error_list} %parse-param {spot::tgba_parse_error_list& error_list}
%parse-param {spot::ltl::environment& parse_environment} %parse-param {spot::ltl::environment& parse_environment}
%parse-param {spot::ltl::environment& parse_envacc} %parse-param {spot::ltl::environment& parse_envacc}
@ -42,11 +49,14 @@
%{ %{
#include "ltlast/constant.hh" #include "ltlast/constant.hh"
#include "ltlvisit/destroy.hh" #include "ltlvisit/destroy.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 "ltlparse/public.hh"
#include <map> #include <map>
/* tgbaparse.hh and parsedecl.hh include each other recursively. /* tgbaparse.hh and parsedecl.hh include each other recursively.
We mut ensure that YYSTYPE is declared (by the above %union) We must ensure that YYSTYPE is declared (by the above %union)
before parsedecl.hh uses it. */ before parsedecl.hh uses it. */
#include "parsedecl.hh" #include "parsedecl.hh"
using namespace spot::ltl; using namespace spot::ltl;
@ -57,12 +67,6 @@ using namespace spot::ltl;
#define yylex tgbayylex #define yylex tgbayylex
typedef std::pair<bool, spot::ltl::formula*> pair; typedef std::pair<bool, spot::ltl::formula*> pair;
/* Cache parsed formulae. Labels on arcs are frequently identical and
it would be a waste of time to parse them to formula* over and
over, and to register all their atomic_propositions in the
bdd_dict. Keep the bdd result around so we can reuse it. */
typedef std::map<std::string, bdd> formula_cache;
%} %}
%token <str> STRING UNTERMINATED_STRING %token <str> STRING UNTERMINATED_STRING
@ -215,7 +219,8 @@ acc_decl:
%% %%
void void
yy::parser::error(const location_type& location, const std::string& message) tgbayy::parser::error(const location_type& location,
const std::string& message)
{ {
error_list.push_back(spot::tgba_parse_error(location, message)); error_list.push_back(spot::tgba_parse_error(location, message));
} }
@ -233,7 +238,7 @@ namespace spot
if (tgbayyopen(name)) if (tgbayyopen(name))
{ {
error_list.push_back error_list.push_back
(tgba_parse_error(yy::location(), (tgba_parse_error(tgbayy::location(),
std::string("Cannot open file ") + name)); std::string("Cannot open file ") + name));
return 0; return 0;
} }

View file

@ -33,6 +33,8 @@
#define YY_NEVER_INTERACTIVE 1 #define YY_NEVER_INTERACTIVE 1
typedef tgbayy::parser::token token;
%} %}
eol \n|\r|\n\r|\r\n eol \n|\r|\n\r|\r\n
@ -43,11 +45,11 @@ eol \n|\r|\n\r|\r\n
yylloc->step (); yylloc->step ();
%} %}
acc[ \t]*= return ACC_DEF; acc[ \t]*= return token::ACC_DEF;
[a-zA-Z][a-zA-Z0-9_]* { [a-zA-Z][a-zA-Z0-9_]* {
yylval->str = new std::string(yytext, yyleng); yylval->str = new std::string(yytext, yyleng);
return IDENT; return token::IDENT;
} }
/* discard whitespace */ /* discard whitespace */
@ -65,13 +67,13 @@ acc[ \t]*= return ACC_DEF;
<STATE_STRING>{ <STATE_STRING>{
\" { \" {
BEGIN(INITIAL); BEGIN(INITIAL);
return STRING; return token::STRING;
} }
\\["\\] yylval->str->append(1, yytext[1]); \\["\\] yylval->str->append(1, yytext[1]);
[^"\\]+ yylval->str->append(yytext, yyleng); [^"\\]+ yylval->str->append(yytext, yyleng);
<<EOF>> { <<EOF>> {
BEGIN(INITIAL); BEGIN(INITIAL);
return UNTERMINATED_STRING; return token::UNTERMINATED_STRING;
} }
} }