* configure.ac: Output src/ltlenv/Makefile.

* src/ltlenv/Makefile.am, src/ltlenv/defaultenv.cc,
src/ltlenv/defaultenv.hh, src/ltlenv/environment.hh: New files.
* src/ltlparse/public.hh (parse): Take an environment as third
argument.
* src/ltlparse/ltlparse.yy (ATOMIC_PROP, parse): Require the
atomic proposition via the environment.
* src/ltltest/readltl.cc (main): Adjust the call to parse().
* src/ltltest/Makefile.am (LDADD): Add ../ltlenv/libltlenv.a.
This commit is contained in:
Alexandre Duret-Lutz 2003-04-17 15:09:49 +00:00
parent ae7fdeba59
commit a30a0638b9
12 changed files with 141 additions and 7 deletions

View file

@ -31,6 +31,7 @@ namespace spot
namespace ltl
{
extern parse_error_list* error_list;
extern environment* parse_environment;
}
}
%}
@ -93,7 +94,22 @@ many_errors: error
| many_errors error
subformula: ATOMIC_PROP
{ $$ = new atomic_prop(*$1); delete $1; }
{
$$ = parse_environment->require(*$1);
if (! $$)
{
std::string s = "unknown atomic proposition `";
s += *$1;
s += "' in environment `";
s += parse_environment->name();
s += "'";
error_list->push_back(parse_error(@1, s));
delete $1;
YYERROR;
}
else
delete $1;
}
| CONST_TRUE
{ $$ = new constant(constant::True); }
| CONST_FALSE
@ -162,14 +178,17 @@ 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;
flex_set_buffer(ltl_string.c_str());
yy::Parser parser(debug, yy::Location());
parser.parse();

View file

@ -1,9 +1,10 @@
#ifndef SPOT_LTLPARSE_PUBLIC_HH
# define SPOT_LTLPARSE_PUBLIC_HH
# include <string>
# include "ltlast/formula.hh"
# include "location.hh"
# include "ltlenv/defaultenv.hh"
# include <string>
# include <list>
# include <utility>
# include <iostream>
@ -17,8 +18,9 @@ namespace spot
// Beware: this function is *not* reentrant.
formula* parse(const std::string& ltl_string,
parse_error_list& error_list,
bool debug = false);
parse_error_list& error_list,
environment& env = default_environment::instance(),
bool debug = false);
// Return true iff any diagnostic was output to os.
bool format_parse_errors(std::ostream& os,