30 #include <agrum/PRM/o3prm/errors.h> 32 #ifndef DOXYGEN_SHOULD_SKIP_THIS 38 void O3PRM_TYPE_NOT_FOUND(
const O3Label& val, ErrorsContainer& errors) {
39 auto pos = val.position();
40 std::stringstream msg;
42 <<
"Unknown type " << val.label();
43 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
46 void O3PRM_TYPE_AMBIGUOUS(
const O3Label& val,
47 const std::vector< std::string >& matches,
48 ErrorsContainer& errors) {
49 const auto& pos = val.position();
50 std::stringstream msg;
52 <<
"Ambiguous name " << val.label() <<
", found more than one elligible types: ";
53 for (std::size_t i = 0; i < matches.size() - 1; ++i) {
54 msg << matches[i] <<
", ";
56 msg << matches.back();
57 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
60 void O3PRM_TYPE_RESERVED(
const O3Label& val, ErrorsContainer& errors) {
61 const auto& pos = val.position();
62 std::stringstream msg;
64 <<
"Type name " << val.label() <<
" is reserved";
65 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
68 void O3PRM_TYPE_DUPPLICATE(
const O3Label& val, ErrorsContainer& errors) {
69 const auto& pos = val.position();
70 std::stringstream msg;
72 <<
"Type " << val.label() <<
" exists already";
73 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
76 void O3PRM_TYPE_CYCLIC_INHERITANCE(
const O3Label& sub_type,
77 const O3Label& super_type,
78 ErrorsContainer& errors) {
79 const auto& pos = sub_type.position();
80 std::stringstream msg;
82 <<
"Cyclic inheritance between type " << sub_type.label() <<
" and type " 83 << super_type.label();
84 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
88 O3PRM_TYPE_UNKNOWN_LABEL(
const O3Label& type,
const O3Label& l, ErrorsContainer& errors) {
89 const auto& pos = l.position();
90 std::stringstream msg;
92 <<
"Unknown label " << l.label() <<
" in " << type.label();
93 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
96 void O3PRM_TYPE_INVALID_RANGE(
const O3IntType& val, ErrorsContainer& errors) {
97 const auto& pos = val.position();
98 std::stringstream msg;
100 <<
"Invalid range " << val.start().value() <<
" -> " << val.end().value();
101 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
104 void O3PRM_TYPE_INVALID_RANGE(
const O3RealType& val, ErrorsContainer& errors) {
105 const auto& pos = val.position();
106 std::stringstream msg;
108 <<
"Found " << val.values().size() <<
" values in range expected at least 3";
109 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
112 void O3PRM_CLASS_NOT_FOUND(
const O3Label& val, ErrorsContainer& errors) {
113 const auto& pos = val.position();
114 std::stringstream msg;
116 <<
"Unknown class " << val.label();
117 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
118 GUM_ERROR(FatalError, msg.str())
121 void O3PRM_CLASS_AMBIGUOUS(
const O3Label& val,
122 const std::vector< std::string >& matches,
123 ErrorsContainer& errors) {
124 const auto& pos = val.position();
125 std::stringstream msg;
127 <<
"Name " << val.label() <<
" is ambiguous: ";
128 for (std::size_t i = 0; i < matches.size() - 1; ++i) {
129 msg << matches[i] <<
", ";
131 msg << matches.back();
132 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
135 void O3PRM_CLASS_DUPLICATE(
const O3Label& val, ErrorsContainer& errors) {
137 const auto& pos = val.position();
138 std::stringstream msg;
140 <<
"Class name " << val.label() <<
" exists already";
141 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
144 void O3PRM_CLASS_CYLIC_INHERITANCE(
const O3Label& sub,
145 const O3Label& super,
146 ErrorsContainer& errors) {
148 const auto& pos = sub.position();
149 std::stringstream msg;
151 <<
"Cyclic inheritance between class " << sub.label() <<
" and class " << super.label();
152 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
156 void O3PRM_CLASS_ATTR_IMPLEMENTATION(
const O3Label& c,
159 ErrorsContainer& errors) {
160 const auto& pos = attr.position();
161 std::stringstream msg;
163 <<
"Class " << c.label() <<
" attribute " << attr.label()
164 <<
" does not respect interface " << i.label();
165 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
168 void O3PRM_CLASS_AGG_IMPLEMENTATION(
const O3Label& c,
171 ErrorsContainer& errors) {
172 const auto& pos = attr.position();
173 std::stringstream msg;
175 <<
"Class " << c.label() <<
" aggregate " << attr.label()
176 <<
" does not respect interface " << i.label();
177 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
180 void O3PRM_CLASS_REF_IMPLEMENTATION(
const O3Label& c,
183 ErrorsContainer& errors) {
184 const auto& pos = ref.position();
185 std::stringstream msg;
187 <<
"Class " << c.label() <<
" reference " << ref.label()
188 <<
" does not respect interface " << i.label();
189 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
193 void O3PRM_CLASS_MISSING_ATTRIBUTES(
const O3Label& c,
195 ErrorsContainer& errors) {
196 const auto& pos = c.position();
197 std::stringstream msg;
199 <<
"Class " << c.label() <<
" does not implement all of interface " << i.label()
201 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
204 void O3PRM_CLASS_DUPLICATE_REFERENCE(
const O3Label& ref, ErrorsContainer& errors) {
205 const auto& pos = ref.position();
206 std::stringstream msg;
208 <<
"Reference Slot name " << ref.label() <<
" exists already";
209 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
213 O3PRM_CLASS_SELF_REFERENCE(
const O3Label& c,
const O3Label& ref, ErrorsContainer& errors) {
214 const auto& pos = ref.position();
215 std::stringstream msg;
217 <<
"Class " << c.label() <<
" cannot reference itself";
218 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
221 void O3PRM_CLASS_ILLEGAL_SUB_REFERENCE(
const O3Label& c,
223 ErrorsContainer& errors) {
224 const auto& pos = sub.position();
225 std::stringstream msg;
227 <<
"Class " << c.label() <<
" cannot reference subclass " << sub.label();
228 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
231 void O3PRM_CLASS_PARENT_NOT_FOUND(
const O3Label& parent, ErrorsContainer& errors) {
232 const auto& pos = parent.position();
233 std::stringstream msg;
235 <<
"Parent " << parent.label() <<
" not found";
236 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
239 void O3PRM_CLASS_ILLEGAL_PARENT(
const O3Label& parent, ErrorsContainer& errors) {
240 const auto& pos = parent.position();
241 std::stringstream msg;
243 <<
"Illegal parent " << parent.label();
244 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
247 void O3PRM_CLASS_LINK_NOT_FOUND(
const O3Label& chain,
248 const std::string& s,
249 ErrorsContainer& errors) {
250 const auto& pos = chain.position();
251 std::stringstream msg;
253 <<
"Link " << s <<
" in chain " << chain.label() <<
" not found";
254 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
257 void O3PRM_CLASS_ILLEGAL_CPT_SIZE(
const std::string& c,
261 ErrorsContainer& errors) {
262 const auto& pos = attr.position();
263 std::stringstream msg;
265 <<
"Illegal CPT size, expected " << expected <<
" found " << found <<
" for attribute " 266 << c <<
"." << attr.label();
267 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
270 void O3PRM_CLASS_ILLEGAL_CPT_VALUE(
const std::string& c,
273 ErrorsContainer& errors) {
274 const auto& pos = f.position();
275 std::stringstream msg;
277 <<
"Illegal CPT value \"" << f.formula().formula() <<
"\" in attribute " << c <<
"." 280 auto result = f.formula().result();
281 msg <<
", formula resolve to " << result;
283 msg <<
", could not resolve the following formula: " 284 <<
"\"" << f.formula().formula() <<
"\"";
286 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
289 void O3PRM_CLASS_CPT_DOES_NOT_SUM_TO_1(
const std::string& c,
292 ErrorsContainer& errors) {
293 const auto& pos = attr.position();
294 std::stringstream msg;
296 <<
"PRMAttribute " << c <<
"." << attr.label() <<
" CPT does not sum to 1, found " << f;
297 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
300 void O3PRM_CLASS_CPT_DOES_NOT_SUM_TO_1_WARNING(
const std::string& c,
303 ErrorsContainer& errors) {
304 const auto& pos = attr.position();
305 std::stringstream msg;
307 <<
"PRMAttribute " << c <<
"." << attr.label() <<
" CPT does not sum to 1, found " << f;
308 errors.addWarning(msg.str(), pos.file(), pos.line(), pos.column());
311 void O3PRM_CLASS_ILLEGAL_RULE_SIZE(
const O3RuleCPT::O3Rule& rule,
314 ErrorsContainer& errors) {
315 const auto& pos = rule.first.front().position();
316 std::stringstream msg;
318 <<
"Expected " << expected <<
" value(s), found " << found;
319 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
322 void O3PRM_CLASS_ILLEGAL_RULE_LABEL(
const O3RuleCPT::O3Rule& rule,
323 const O3Label& label,
324 const O3Label& parent,
325 ErrorsContainer& errors) {
326 const auto& pos = label.position();
327 std::stringstream msg;
329 <<
"Label " << label <<
" is not part of " << parent <<
" domain";
330 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
333 void O3PRM_CLASS_WRONG_PARENT(
const O3Label& prnt, ErrorsContainer& errors) {
334 const auto& pos = prnt.position();
335 std::stringstream msg;
337 <<
"Illegal parent " << prnt;
338 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
341 void O3PRM_CLASS_WRONG_PARENT_TYPE(
const O3Label& prnt,
342 const std::string& expected,
343 const std::string& found,
344 ErrorsContainer& errors) {
345 const auto& pos = prnt.position();
346 std::stringstream msg;
348 <<
"Expected type " << expected <<
" for parent " << prnt.label() <<
", found " 350 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
353 void O3PRM_CLASS_ILLEGAL_OVERLOAD(
const O3Label& elt,
355 ErrorsContainer& errors) {
356 const auto& pos = elt.position();
357 std::stringstream msg;
359 <<
"Illegal overload of element " << elt.label() <<
" from class " << c.label();
360 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
363 void O3PRM_CLASS_AGG_PARAMETERS(
const O3Label& agg,
366 ErrorsContainer& errors) {
367 const auto& pos = agg.position();
368 std::stringstream msg;
370 <<
"Expected " << expected <<
" parameters " 371 <<
", found " << found;
372 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
375 void O3PRM_CLASS_AGG_PARAMETER_NOT_FOUND(
const O3Label& agg,
376 const O3Label& param,
377 ErrorsContainer& errors) {
378 const auto& pos = param.position();
379 std::stringstream msg;
381 <<
"Parameter " << param.label() <<
" in aggregate " << agg.label()
382 <<
" does not match any expected values";
383 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
386 void O3PRM_INTERFACE_ILLEGAL_ARRAY(
const O3Label& val, ErrorsContainer& errors) {
387 const auto& pos = val.position();
388 std::stringstream msg;
390 <<
"PRMAttribute " << val.label() <<
" can not be an array";
391 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
394 void O3PRM_INTERFACE_NOT_FOUND(
const O3Label& val, ErrorsContainer& errors) {
395 const auto& pos = val.position();
396 std::stringstream msg;
398 <<
"Interface " << val.label() <<
" not found";
399 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
402 void O3PRM_INTERFACE_AMBIGUOUS(
const O3Label& val,
403 const std::vector< std::string >& matches,
404 ErrorsContainer& errors) {
405 const auto& pos = val.position();
406 std::stringstream msg;
408 <<
"Name " << val.label() <<
" is ambiguous: ";
409 for (std::size_t i = 0; i < matches.size() - 1; ++i) {
410 msg << matches[i] <<
", ";
412 msg << matches.back();
413 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
416 void O3PRM_INTERFACE_DUPLICATE(
const O3Label& val, ErrorsContainer& errors) {
417 const auto& pos = val.position();
418 std::stringstream msg;
420 <<
"Interface name " << val.label() <<
" exists already";
421 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
424 void O3PRM_INTERFACE_DUPLICATE_ELEMENT(
const O3InterfaceElement& elt,
425 ErrorsContainer& errors) {
426 const auto& pos = elt.type().position();
427 std::stringstream msg;
429 <<
"Element " << elt.name().label() <<
" already exists";
430 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
433 void O3PRM_INTERFACE_CYCLIC_INHERITANCE(
const O3Label& sub,
434 const O3Label& super,
435 ErrorsContainer& errors) {
436 const auto& pos = super.position();
437 std::stringstream msg;
439 <<
"Cyclic inheritance between interface " << sub.label() <<
" and interface " 441 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
444 void O3PRM_INTERFACE_SELF_REFERENCE(
const O3Interface& i,
445 const O3InterfaceElement& r,
446 ErrorsContainer& errors) {
447 const auto& pos = r.type().position();
448 std::stringstream msg;
450 <<
"Interface " << i.name().label() <<
" cannot reference itself";
451 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
454 void O3PRM_INTERFACE_ILLEGAL_SUB_REFERENCE(
const O3Interface& i,
455 const O3InterfaceElement& ref,
456 ErrorsContainer& errors) {
457 const auto& pos = ref.type().position();
458 std::stringstream msg;
460 <<
"Interface " << i.name().label() <<
" cannot reference subinterface " 461 << ref.type().label();
462 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
465 void O3PRM_INTERFACE_ILLEGAL_OVERLOAD(
const O3InterfaceElement& elt,
466 ErrorsContainer& errors) {
467 const auto& pos = elt.type().position();
468 std::stringstream msg;
470 <<
"Illegal overload of element " << elt.name().label();
471 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
474 void O3PRM_REFERENCE_NOT_FOUND(
const O3Label& val, ErrorsContainer& errors) {
475 const auto& pos = val.position();
476 std::stringstream msg;
478 <<
"Reference Slot type " << val.label() <<
" not found";
479 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
482 void O3PRM_REFERENCE_AMBIGUOUS(
const O3Label& val,
483 const std::vector< std::string >& matches,
484 ErrorsContainer& errors) {
485 const auto& pos = val.position();
486 std::stringstream msg;
488 <<
"Name " << val.label() <<
" is ambiguous: ";
489 for (std::size_t i = 0; i < matches.size() - 1; ++i) {
490 msg << matches[i] <<
", ";
492 msg << matches.back();
493 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
496 void O3PRM_SYSTEM_INSTANTIATION_FAILED(
const O3System& sys, ErrorsContainer& errors) {
497 const auto& pos = sys.name().position();
498 std::stringstream msg;
500 <<
"Could not instantiate the system, some reference slots must be " 502 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
505 void O3PRM_SYSTEM_NOT_A_CLASS(
const O3Instance& i, ErrorsContainer& errors) {
506 const auto& pos = i.type().position();
507 std::stringstream msg;
508 msg <<
"Error : " << i.type().label() <<
" is not a class";
509 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
512 void O3PRM_SYSTEM_DUPLICATE_INSTANCE(
const O3Instance& i, ErrorsContainer& errors) {
513 const auto& pos = i.type().position();
514 std::stringstream msg;
516 <<
"Instance " << i.name().label() <<
" already exists";
517 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
520 void O3PRM_SYSTEM_NOT_A_PARAMETER(
const O3InstanceParameter& param, ErrorsContainer& errors) {
521 const auto& pos = param.name().position();
522 std::stringstream msg;
523 msg <<
"Instance error : " << param.name().label() <<
" is not a parameter";
524 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
527 void O3PRM_SYSTEM_PARAMETER_NOT_FOUND(
const O3InstanceParameter& param,
528 ErrorsContainer& errors) {
529 const auto& pos = param.name().position();
530 std::stringstream msg;
532 <<
"Parameter " << param.name().label() <<
" not found";
533 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
536 void O3PRM_SYSTEM_PARAMETER_NOT_INT(
const O3InstanceParameter& param,
537 ErrorsContainer& errors) {
538 const auto& pos = param.value().position();
539 std::stringstream msg;
541 <<
"Parameter " << param.name().label() <<
" is an integer";
542 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
545 void O3PRM_SYSTEM_PARAMETER_NOT_FLOAT(
const O3InstanceParameter& param,
546 ErrorsContainer& errors) {
547 const auto& pos = param.value().position();
548 std::stringstream msg;
550 <<
"Parameter " << param.name().label() <<
" is a float";
551 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
554 void O3PRM_SYSTEM_INVALID_LEFT_VALUE(
const O3Label& val, ErrorsContainer& errors) {
555 const auto& pos = val.position();
556 std::stringstream msg;
558 <<
"Invalid left expression " << val.label();
559 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
562 void O3PRM_SYSTEM_INSTANCE_NOT_FOUND(
const O3Label& i, ErrorsContainer& errors) {
563 const auto& pos = i.position();
564 std::stringstream msg;
566 <<
"Instance " << i.label() <<
" not found";
567 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
570 void O3PRM_SYSTEM_REFERENCE_NOT_FOUND(
const O3Label& ref,
571 const std::string& type,
572 ErrorsContainer& errors) {
573 const auto& pos = ref.position();
574 std::stringstream msg;
576 <<
"Reference " << ref.label() <<
" not found in class " << type;
577 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
580 void O3PRM_SYSTEM_NOT_AN_ARRAY(
const O3Label& val, ErrorsContainer& errors) {
581 const auto& pos = val.position();
582 std::stringstream msg;
583 msg <<
"Error : " << val.label() <<
" is not an array";
584 errors.addError(msg.str(), pos.file(), pos.line(), pos.column());
587 void O3PRM_DEPRECATED_TYPE_WARNING(
const O3Label& val, ErrorsContainer& errors) {
588 const auto& pos = val.position();
589 std::stringstream msg;
590 msg <<
"Warning : " << val.label() <<
" is declared using a deprecated syntax.";
591 errors.addWarning(msg.str(), pos.file(), pos.line(), pos.column());
INLINE void emplace(Args &&... args)
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)