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 * Pierre Wilke <wilke.pierre@gmail.com>
6 * Guido Tack <guido.tack@monash.edu>
7 */
8
9/* This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
12
13#ifndef __MINIZINC_PRETTYPRINTER_HH__
14#define __MINIZINC_PRETTYPRINTER_HH__
15
16#include <minizinc/ast.hh>
17
18#include <iostream>
19
20namespace MiniZinc {
21
22class Document;
23class ItemDocumentMapper;
24class PrettyPrinter;
25
26class Printer {
27private:
28 EnvI* env;
29 ItemDocumentMapper* ism;
30 PrettyPrinter* printer;
31 std::ostream& _os;
32 int _width;
33 bool _flatZinc;
34
35 void init(void);
36 void p(Document* d);
37 void p(const Item* i);
38
39public:
40 Printer(std::ostream& os, int width = 80, bool flatZinc = true, EnvI* env = NULL);
41 ~Printer(void);
42
43 void print(const Expression* e);
44 void print(const Item* i);
45 void print(const Model* m);
46
47 static std::string escapeStringLit(const ASTString& s);
48};
49
50/// Output operator for expressions
51template <class Char, class Traits>
52std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os,
53 const Expression& e) {
54 std::basic_ostringstream<Char, Traits> s;
55 s.copyfmt(os);
56 s.width(0);
57 Printer p(s, 0);
58 p.print(&e);
59 return os << s.str();
60}
61
62/// Output operator for items
63template <class Char, class Traits>
64std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os, const Item& i) {
65 std::basic_ostringstream<Char, Traits> s;
66 s.copyfmt(os);
67 s.width(0);
68 Printer p(s);
69 p.print(&i);
70 return os << s.str();
71}
72
73void ppFloatVal(std::ostream& os, const FloatVal& fv, bool hexFloat = false);
74
75} // namespace MiniZinc
76
77void debugprint(MiniZinc::Expression* e);
78void debugprint(MiniZinc::Item* i);
79void debugprint(MiniZinc::Model* m);
80void debugprint(const MiniZinc::Location& l);
81
82#endif