A set of benchmarks to compare a new prototype MiniZinc implementation
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
3/*
4 * Main authors:
5 * Guido Tack <guido.tack@monash.edu>
6 */
7
8/* This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11
12#ifndef __MINIZINC_ASTEXCEPTION_HH__
13#define __MINIZINC_ASTEXCEPTION_HH__
14
15#include <minizinc/ast.hh>
16#include <minizinc/exception.hh>
17#include <minizinc/model.hh>
18
19#include <string>
20
21namespace MiniZinc {
22
23class SyntaxError : public Exception {
24protected:
25 Location _loc;
26
27public:
28 SyntaxError(const Location& loc, const std::string& msg) : Exception(msg), _loc(loc) {}
29 virtual ~SyntaxError(void) throw() {}
30 virtual const char* what(void) const throw() { return "MiniZinc: syntax error"; }
31 const Location& loc(void) const { return _loc; }
32};
33
34class LocationException : public Exception {
35protected:
36 Location _loc;
37
38public:
39 LocationException(EnvI& env, const Location& loc, const std::string& msg);
40 virtual ~LocationException(void) throw() {}
41 const Location& loc(void) const { return _loc; }
42};
43
44class TypeError : public LocationException {
45public:
46 TypeError(EnvI& env, const Location& loc, const std::string& msg)
47 : LocationException(env, loc, msg) {}
48 ~TypeError(void) throw() {}
49 virtual const char* what(void) const throw() { return "MiniZinc: type error"; }
50};
51
52class EvalError : public LocationException {
53public:
54 EvalError(EnvI& env, const Location& loc, const std::string& msg)
55 : LocationException(env, loc, msg) {}
56 EvalError(EnvI& env, const Location& loc, const std::string& msg, const ASTString& name)
57 : LocationException(env, loc, msg + " '" + name.str() + "'") {}
58 ~EvalError(void) throw() {}
59 virtual const char* what(void) const throw() { return "MiniZinc: evaluation error"; }
60};
61
62class ModelInconsistent : public LocationException {
63public:
64 ModelInconsistent(EnvI& env, const Location& loc)
65 : LocationException(env, loc, "model inconsistency detected") {}
66 ~ModelInconsistent(void) throw() {}
67 virtual const char* what(void) const throw() { return "MiniZinc: warning"; }
68};
69
70class ResultUndefinedError : public LocationException {
71public:
72 ResultUndefinedError(EnvI& env, const Location& loc, const std::string& msg);
73 ~ResultUndefinedError(void) throw() {}
74 virtual const char* what(void) const throw() {
75 return "MiniZinc: result of evaluation is undefined";
76 }
77};
78
79} // namespace MiniZinc
80
81#endif