* 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

@ -27,7 +27,8 @@
#include "location.hh"
# define YY_DECL \
int tgbayylex (yystype *yylval, yy::location *yylloc)
int tgbayylex (tgbayy::parser::semantic_type *yylval, \
tgbayy::location *yylloc)
YY_DECL;
namespace spot
@ -42,11 +43,11 @@ namespace spot
// 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 tgbayy
{
using namespace yy;
}
#define yy tgbayy
// namespace tgbayy
// {
// using namespace yy;
// }
// #define yy tgbayy

View file

@ -23,7 +23,10 @@
# define SPOT_TGBAPARSE_PUBLIC_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 <string>
# include <list>
@ -36,7 +39,7 @@ namespace spot
/// @{
/// \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.
typedef std::list<tgba_parse_error> tgba_parse_error_list;

View file

@ -22,8 +22,15 @@
%{
#include <string>
#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::ltl::environment& parse_environment}
%parse-param {spot::ltl::environment& parse_envacc}
@ -42,11 +49,14 @@
%{
#include "ltlast/constant.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 <map>
/* 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. */
#include "parsedecl.hh"
using namespace spot::ltl;
@ -57,12 +67,6 @@ using namespace spot::ltl;
#define yylex tgbayylex
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
@ -215,7 +219,8 @@ acc_decl:
%%
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));
}
@ -233,7 +238,7 @@ namespace spot
if (tgbayyopen(name))
{
error_list.push_back
(tgba_parse_error(yy::location(),
(tgba_parse_error(tgbayy::location(),
std::string("Cannot open file ") + name));
return 0;
}

View file

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