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

* src/ltlparse/ltlparse.yy (error_list, parse_environment, result):

CVS Bison now supports %parse-param for the C++ skeleton; pass these
variables as arguments to the Parser::Parser constructor instead of
using globals.
(parse): Adjust Parser::Parser call.
parent 8e988470
2003-05-15 Alexandre Duret-Lutz <aduret@src.lip6.fr>
* src/ltlparse/ltlparse.yy (error_list, parse_environment, result):
CVS Bison now supports %parse-param for the C++ skeleton; pass these
variables as arguments to the Parser::Parser constructor instead of
using globals.
(parse): Adjust Parser::Parser call.
2003-05-12 Alexandre Duret-Lutz <aduret@src.lip6.fr>
* src/ltlvisit/tostring.cc: Reindent and strip out superfluous
......
......@@ -7,6 +7,9 @@ extern spot::ltl::formula* result;
%}
%parse-param {spot::ltl::parse_error_list &error_list}
%parse-param {spot::ltl::environment &parse_environment}
%parse-param {spot::ltl::formula* &result}
%debug
%error-verbose
%union
......@@ -22,18 +25,6 @@ extern spot::ltl::formula* result;
before parsedecl.hh uses it. */
#include "parsedecl.hh"
using namespace spot::ltl;
// At the time of writing C++ support in Bison is quite
// new and there is still no way to pass error_list to
// the parser. We use a global variable instead.
namespace spot
{
namespace ltl
{
extern parse_error_list* error_list;
extern environment* parse_environment;
}
}
%}
/* Logical operators. */
......@@ -67,20 +58,19 @@ result: ltl_formula END_OF_INPUT
YYACCEPT;
}
| many_errors END_OF_INPUT
{ error_list->push_back(parse_error(@1,
{ error_list.push_back(parse_error(@1,
"couldn't parse anything sensible"));
result = $$ = 0;
YYABORT;
}
| END_OF_INPUT
{ error_list->push_back(parse_error(@1,
"empty input"));
{ error_list.push_back(parse_error(@1, "empty input"));
result = $$ = 0;
YYABORT;
}
many_errors_diagnosed : many_errors
{ error_list->push_back(parse_error(@1,
{ error_list.push_back(parse_error(@1,
"unexpected input ignored")); }
ltl_formula: subformula
......@@ -95,15 +85,15 @@ many_errors: error
subformula: ATOMIC_PROP
{
$$ = parse_environment->require(*$1);
$$ = parse_environment.require(*$1);
if (! $$)
{
std::string s = "unknown atomic proposition `";
s += *$1;
s += "' in environment `";
s += parse_environment->name();
s += parse_environment.name();
s += "'";
error_list->push_back(parse_error(@1, s));
error_list.push_back(parse_error(@1, s));
delete $1;
YYERROR;
}
......@@ -117,12 +107,12 @@ subformula: ATOMIC_PROP
| PAR_OPEN subformula PAR_CLOSE
{ $$ = $2; }
| PAR_OPEN error PAR_CLOSE
{ error_list->push_back(parse_error(@$,
{ error_list.push_back(parse_error(@$,
"treating this parenthetical block as false"));
$$ = new constant(constant::False);
}
| PAR_OPEN subformula many_errors PAR_CLOSE
{ error_list->push_back(parse_error(@3,
{ error_list.push_back(parse_error(@3,
"unexpected input ignored"));
$$ = $2;
}
......@@ -168,29 +158,22 @@ yy::Parser::print_()
void
yy::Parser::error_()
{
error_list->push_back(parse_error(location, message));
error_list.push_back(parse_error(location, message));
}
formula* result = 0;
namespace spot
{
namespace ltl
{
parse_error_list* error_list;
environment* parse_environment;
formula*
parse(const std::string& ltl_string,
parse_error_list& error_list,
environment& env,
bool debug)
{
result = 0;
ltl::error_list = &error_list;
parse_environment = &env;
formula* result = 0;
flex_set_buffer(ltl_string.c_str());
yy::Parser parser(debug, yy::Location());
yy::Parser parser(debug, yy::Location(), error_list, env, result);
parser.parse();
return result;
}
......
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