3 #include <boost/algorithm/string.hpp>
18 auto h = boost::replace_all_copy(algo,
"_",
"-");
20 for (
auto s: {
"-automaton",
22 "-expansion",
"-label",
"-polynomial",
23 "-ratexp",
"-vector",
"-weight"})
24 if (boost::ends_with(h, s))
25 boost::erase_tail(h, strlen(s));
30 #define ALGO(In, Out) \
33 ALGO(
"ambiguous-word",
"is-ambiguous");
34 ALGO(
"chain",
"concatenate");
35 ALGO(
"coaccessible",
"accessible");
36 ALGO(
"codeterminize",
"determinize");
37 ALGO(
"cominimize",
"minimize");
38 ALGO(
"conjunction",
"product");
39 ALGO(
"context-of",
"make-context");
40 ALGO(
"copy-convert",
"copy");
41 ALGO(
"costandard",
"standard");
42 ALGO(
"difference",
"are-equivalent");
43 ALGO(
"eliminate-state",
"to-expression");
44 ALGO(
"factor",
"prefix");
45 ALGO(
"infiltration",
"product");
46 ALGO(
"is-accessible",
"accessible");
47 ALGO(
"is-coaccessible",
"accessible");
48 ALGO(
"is-codeterministic",
"is-deterministic");
49 ALGO(
"is-costandard",
"standard");
50 ALGO(
"is-cycle-ambiguous",
"is-ambiguous");
51 ALGO(
"is-empty",
"accessible");
52 ALGO(
"is-normalized",
"normalize");
53 ALGO(
"is-out-sorted",
"sort");
54 ALGO(
"is-standard",
"standard");
55 ALGO(
"is-synchronized-by",
"synchronizing-word");
56 ALGO(
"is-trim",
"accessible");
57 ALGO(
"is-useless",
"accessible");
58 ALGO(
"list",
"print");
59 ALGO(
"make-ratexpset",
"make-context");
60 ALGO(
"make-word-context",
"make-context");
61 ALGO(
"multiply",
"concatenate");
62 ALGO(
"num-sccs",
"scc");
63 ALGO(
"pair",
"synchronizing-word");
64 ALGO(
"power",
"product");
65 ALGO(
"right-mult",
"left-mult");
66 ALGO(
"shortest",
"enumerate");
67 ALGO(
"shuffle",
"product");
68 ALGO(
"subword",
"prefix");
69 ALGO(
"suffix",
"prefix");
70 ALGO(
"trim",
"accessible");
71 ALGO(
"union-a",
"union");
74 if (algo ==
"is_valid_ratexp")
75 h =
"is-valid-ratexp";
77 h =
"vcsn/algos/" + h +
".hh";
102 "#define BUILD_LIBVCSN 1\n"
103 "#define VCSN_INSTANTIATION 1\n"
104 "#define MAYBE_EXTERN\n"
107 o <<
"#include <" << h <<
">\n";
110 o <<
"#include <" << h <<
">\n";
116 #define DEFINE(Type) \
117 void context_printer::visit(const Type& t)
121 auto type = t.get_type();
122 if (type ==
"blind_automaton")
123 header(
"vcsn/algos/blind.hh");
124 else if (type ==
"determinized_automaton")
125 header(
"vcsn/algos/determinize.hh");
126 else if (type ==
"detweighted_automaton")
127 header(
"vcsn/algos/determinize.hh");
128 else if (type ==
"filter_automaton")
129 header(
"vcsn/algos/filter.hh");
130 else if (type ==
"mutable_automaton")
131 header(
"vcsn/core/mutable-automaton.hh");
132 else if (type ==
"pair_automaton")
133 header(
"vcsn/algos/synchronizing-word.hh");
134 else if (type ==
"partition_automaton")
135 header(
"vcsn/core/partition-automaton.hh");
136 else if (type ==
"product_automaton")
137 header(
"vcsn/algos/product.hh");
138 else if (type ==
"permutation_automaton")
139 header(
"vcsn/core/permutation-automaton.hh");
140 else if (type ==
"ratexp_automaton")
141 header(
"vcsn/core/ratexp-automaton.hh");
142 else if (type ==
"transpose_automaton")
143 header(
"vcsn/algos/transpose.hh");
144 else if (type ==
"tuple_automaton")
145 header(
"vcsn/core/tuple-automaton.hh");
147 raise(
"unsupported automaton type: ", type);
149 os_ <<
"vcsn::" << type <<
'<' <<
incendl;
151 for (
auto c: t.get_content())
158 os_ << decendl << '>
';
163 header("vcsn/ctx/context.hh");
164 os_ << "vcsn::context<" << incendl;
165 t.get_labelset()->accept(*this);
167 t.get_weightset()->accept(*this);
168 os_ << decendl << '>
';
173 headers_late_.insert("vcsn/labelset/tupleset.hh");
174 os_ << "vcsn::tupleset<" << incendl;
176 for (auto v: t.get_sets())
183 os_ << decendl << '>
';
189 header("vcsn/labelset/nullableset.hh");
190 os_ << "vcsn::nullableset<" << incendl;
191 t.get_labelset()->accept(*this);
192 os_ << decendl << ">";
198 header("vcsn/labelset/oneset.hh");
199 os_ << "vcsn::oneset";
204 header("vcsn/alphabets/setalpha.hh"); // set_alphabet
205 if (t.letter_type() == "char_letters")
206 header("vcsn/alphabets/char.hh");
207 os_ << "vcsn::set_alphabet<vcsn::" << t.letter_type() << '>
';
212 header("vcsn/labelset/letterset.hh");
213 os_ << "vcsn::letterset<";
214 t.genset()->accept(*this);
220 os_ << "vcsn::ratexpset<" << incendl;
221 t.get_context()->accept(*this);
222 os_ << decendl << '>
';
223 header("vcsn/core/rat/ratexpset.hh");
228 header("vcsn/weightset/" + t.get_type() + ".hh");
229 if (t.get_type() == "qmp")
230 linkflags("-lgmp -lgmpxx");
231 os_ << "vcsn::" << t.get_type();
236 header("vcsn/labelset/wordset.hh");
237 os_ << "vcsn::wordset<";
238 t.genset()->accept(*this);
247 DEFINE(polynomialset)
249 os_ << "vcsn::polynomialset<" << incendl;
250 t.get_content()->accept(*this);
251 os_ << decendl << '>
';
252 header("vcsn/weightset/polynomialset.hh");
std::ostream & iendl(std::ostream &o)
Print an end of line, then set the indentation.
std::ostream & print(std::ostream &o)
Generate the code to compile on o.
std::set< std::string > headers_
Headers to include.
Indentation relative functions.
const std::string & linkflags() const
Get the link flags.
std::ostream & incendl(std::ostream &o)
Increment the indentation, print an end of line, and set the indentation.
std::string linkflags_
Flags to pass to the linker.
void header(const std::string &h)
Record that we need an include for this header.
void header_algo(const std::string &algo)
Record that we need an include for this algorithm.
std::set< std::string > headers_late_