Commit c0552123 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

* 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.
parent db98955e
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>
* src/ltlvisit/contain.hh, src/ltlvisit/contain.cc: Adjust to only
......
......@@ -25,6 +25,7 @@
#include "evtgba/symbol.hh"
%}
%name-prefix="evtgbayy"
%parse-param {spot::evtgba_parse_error_list &error_list}
%parse-param {spot::evtgba_explicit* &result}
%debug
......@@ -120,7 +121,8 @@ init_decl:
%%
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));
}
......@@ -135,7 +137,7 @@ namespace spot
if (evtgbayyopen(name))
{
error_list.push_back
(evtgba_parse_error(yy::location(),
(evtgba_parse_error(evtgbayy::location(),
std::string("Cannot open file ") + name));
return 0;
}
......
......@@ -33,6 +33,7 @@
#define YY_NEVER_INTERACTIVE 1
typedef evtgbayy::parser::token token;
%}
eol \n|\r|\n\r|\r\n
......@@ -43,12 +44,12 @@ eol \n|\r|\n\r|\r\n
yylloc->step ();
%}
acc[ \t]*= return ACC_DEF;
init[ \t]*= return INIT_DEF;
acc[ \t]*= return token::ACC_DEF;
init[ \t]*= return token::INIT_DEF;
[a-zA-Z][a-zA-Z0-9_]* {
yylval->str = new std::string(yytext);
return IDENT;
return token::IDENT;
}
/* discard whitespace */
......@@ -66,13 +67,13 @@ init[ \t]*= return INIT_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;
}
}
......
......@@ -27,7 +27,8 @@
#include "location.hh"
# define YY_DECL \
int evtgbayylex (yystype *yylval, yy::location *yylloc)
int evtgbayylex (evtgbayy::parser::semantic_type *yylval, \
evtgbayy::location *yylloc)
YY_DECL;
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
......@@ -23,7 +23,7 @@
# define SPOT_EVTGBAPARSE_PUBLIC_HH
# include "evtgba/explicit.hh"
# include "ltlparse/location.hh"
# include "location.hh"
# include <string>
# include <list>
# include <utility>
......@@ -32,7 +32,7 @@
namespace spot
{
/// \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.
typedef std::list<evtgba_parse_error> evtgba_parse_error_list;
......
......@@ -37,7 +37,7 @@ namespace spot
for (it = error_list.begin(); it != error_list.end(); ++it)
{
os << ">>> " << ltl_string << std::endl;
yy::location& l = it->first;
ltlyy::location& l = it->first;
unsigned n = 0;
for (; n < 4 + l.begin.column; ++n)
......
......@@ -27,6 +27,7 @@
%}
%name-prefix="ltlyy"
%parse-param {spot::ltl::parse_error_list &error_list}
%parse-param {spot::ltl::environment &parse_environment}
%parse-param {spot::ltl::formula* &result}
......@@ -262,7 +263,7 @@ subformula: ATOMIC_PROP
%%
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));
}
......@@ -279,7 +280,7 @@ namespace spot
{
formula* result = 0;
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.parse();
return result;
......
......@@ -42,6 +42,8 @@
static const char* to_parse = 0;
static size_t to_parse_size = 0;
typedef ltlyy::parser::token token;
void
flex_set_buffer(const char* buf)
{
......@@ -59,36 +61,36 @@ flex_set_buffer(const char* buf)
yylloc->step();
%}
"(" BEGIN(0); return PAR_OPEN;
")" BEGIN(not_prop); return PAR_CLOSE;
"(" BEGIN(0); return token::PAR_OPEN;
")" BEGIN(not_prop); return token::PAR_CLOSE;
/* Must go before the other operators, because the F of FALSE
should not be mistaken with a unary F. */
"1"|[tT][rR][uU][eE] BEGIN(0); return CONST_TRUE;
"0"|[fF][aA][lL][sS][eE] BEGIN(0); return CONST_FALSE;
"1"|[tT][rR][uU][eE] BEGIN(0); return token::CONST_TRUE;
"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 xor are from LBTT.
*/
"||"|"|"|"+"|"\\/" BEGIN(0); return OP_OR;
"&&"|"&"|"."|"*"|"/\\" BEGIN(0); return OP_AND;
"^"|"xor" BEGIN(0); return OP_XOR;
"=>"|"->" BEGIN(0); return OP_IMPLIES;
"<=>"|"<->" BEGIN(0); return OP_EQUIV;
"||"|"|"|"+"|"\\/" BEGIN(0); return token::OP_OR;
"&&"|"&"|"."|"*"|"/\\" BEGIN(0); return token::OP_AND;
"^"|"xor" BEGIN(0); return token::OP_XOR;
"=>"|"->" BEGIN(0); return token::OP_IMPLIES;
"<=>"|"<->" BEGIN(0); return token::OP_EQUIV;
/* <>, [], and () are used in Spin. */
"F"|"<>" BEGIN(0); return OP_F;
"G"|"[]" BEGIN(0); return OP_G;
"U" BEGIN(0); return OP_U;
"R"|"V" BEGIN(0); return OP_R;
"X"|"()" BEGIN(0); return OP_X;
"F"|"<>" BEGIN(0); return token::OP_F;
"G"|"[]" BEGIN(0); return token::OP_G;
"U" BEGIN(0); return token::OP_U;
"R"|"V" BEGIN(0); return token::OP_R;
"X"|"()" BEGIN(0); return token::OP_X;
"=0" return OP_POST_NEG;
"=1" return OP_POST_POS;
"=0" return token::OP_POST_NEG;
"=1" return token::OP_POST_POS;
[ \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_]* {
yylval->str = new std::string(yytext, yyleng);
BEGIN(not_prop);
return ATOMIC_PROP;
return token::ATOMIC_PROP;
}
/* 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,
yyleng - 2);
BEGIN(not_prop);
return ATOMIC_PROP;
return token::ATOMIC_PROP;
}
. return *yytext;
<<EOF>> return END_OF_INPUT;
<<EOF>> return token::END_OF_INPUT;
%{
/* Dummy use of yyunput to shut up a gcc warning. */
......
......@@ -26,7 +26,7 @@
#include "location.hh"
# define YY_DECL \
int ltlyylex (yystype *yylval, yy::location *yylloc)
int ltlyylex (ltlyy::parser::semantic_type *yylval, ltlyy::location *yylloc)
YY_DECL;
void flex_set_buffer(const char *buf);
......
......@@ -23,7 +23,7 @@
# define SPOT_LTLPARSE_PUBLIC_HH
# include "ltlast/formula.hh"
# include "location.hh"
# include "ltlparse/location.hh"
# include "ltlenv/defaultenv.hh"
# include <string>
# include <list>
......@@ -38,7 +38,7 @@ namespace spot
/// @{
/// \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.
typedef std::list<parse_error> parse_error_list;
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
}
......
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