Correctly parsing quantified expressions thanks to variable stack.

This commit is contained in:
Patrick Lühne 2016-09-06 17:36:51 +02:00
parent eb28ed3938
commit faa920e1ad

View File

@ -3,6 +3,7 @@
#include <plasp/pddl/Context.h> #include <plasp/pddl/Context.h>
#include <plasp/pddl/Expression.h> #include <plasp/pddl/Expression.h>
#include <plasp/pddl/ExpressionContext.h>
#include <plasp/pddl/expressions/Variable.h> #include <plasp/pddl/expressions/Variable.h>
namespace plasp namespace plasp
@ -65,9 +66,15 @@ boost::intrusive_ptr<Derived> Quantified<Derived>::parse(Context &context,
Variable::parseTypedDeclarations(context, expressionContext, expression->m_variables); Variable::parseTypedDeclarations(context, expressionContext, expression->m_variables);
parser.expect<std::string>(")"); parser.expect<std::string>(")");
// Push newly parsed variables to the stack
expressionContext.variables.push(&expression->m_variables);
// Parse argument of the expression // Parse argument of the expression
expression->Quantified<Derived>::setArgument(parseExpression(context, expressionContext)); expression->Quantified<Derived>::setArgument(parseExpression(context, expressionContext));
// Clean up variable stack
expressionContext.variables.pop();
parser.expect<std::string>(")"); parser.expect<std::string>(")");
return expression; return expression;