Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions applications/Validate/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 - University of Strathclyde, King's College London and Schlumberger Ltd
// Copyright 2019-2025 - University of Strathclyde, King's College London, Schlumberger Ltd and SIFT, LLC
// This source code is licensed under the BSD license found in the LICENSE file in the root directory of this source tree.

#include "Plan.h"
Expand Down Expand Up @@ -137,7 +137,16 @@ plan *getPlan(int &argc, char *argv[], int &argcount, TypeChecker &tc,
if (!the_plan || !tc.typecheckPlan(the_plan)) {
failed.push_back(name);

if (Silent < 2) *report << "Bad plan description!\n";
if (Silent < 2) {
*report << "Bad plan description!\n";
if (!the_plan) {
*report << "Unable to read plan file.\n";
}
else {
*report << "Plan failed to type-check\n";
*report << tc.planTypecheckFlaw(the_plan);
}
}
if (Silent > 1) *report << "failed\n";
delete the_plan;
the_plan = 0;
Expand Down
1 change: 1 addition & 0 deletions libraries/VAL/include/typecheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ namespace VAL {
bool typecheckAction(const operator_ *act);
bool typecheckProblem();
bool typecheckPlan(const plan *p);
std::string planTypecheckFlaw(const plan *p);
bool typecheckGoal(const goal *g);
bool typecheckProposition(const proposition *g);
bool typecheckActionInstance(const plan_step *p);
Expand Down
12 changes: 12 additions & 0 deletions libraries/VAL/src/typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "ptree.h"
#include <algorithm>
#include <functional>
#include <sstream>
#include <string>

namespace VAL {

Expand Down Expand Up @@ -708,6 +710,16 @@ namespace VAL {
return p->end() == std::find_if(p->begin(), p->end(), badchecker(this));
};


std::string TypeChecker::planTypecheckFlaw(const plan *p) {
std::ostringstream oss;
oss << "Type error in:\n";
oss << *(std::find_if(p->begin(), p->end(), badchecker(this)));
oss << "\n";
return oss.str();
};


vector< const_symbol * > TypeChecker::range(const var_symbol *v) {
vector< const_symbol * > l;
for (const_symbol_table::const_iterator i = thea->const_tab.begin();
Expand Down