MCPcopy Create free account
hub / github.com/Gecode/gecode / toString

Method toString

gecode/minimodel/reg.cpp:153–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151 }
152
153 void
154 REG::Exp::toString(std::ostringstream& os) const {
155 switch (type) {
156 case ET_SYMBOL:
157 os << "[" << data.symbol << "]";
158 return;
159 case ET_STAR:
160 {
161 bool par = ((data.kids[0] != nullptr) &&
162 ((data.kids[0]->type == ET_CONC) ||
163 (data.kids[0]->type == ET_OR)));
164 os << (par ? "*(" : "*");
165 if (data.kids[0]==nullptr) {
166 os << "[]";
167 } else {
168 data.kids[0]->toString(os);
169 }
170 os << (par ? ")" : "");
171 return;
172 }
173 case ET_CONC:
174 {
175 bool par0 = ((data.kids[0] != nullptr) &&
176 (data.kids[0]->type == ET_OR));
177 os << (par0 ? "(" : "");
178 if (data.kids[0]==nullptr) {
179 os << "[]";
180 } else {
181 data.kids[0]->toString(os);
182 }
183 os << (par0 ? ")+" : "+");
184 bool par1 = ((data.kids[1] != nullptr) &&
185 (data.kids[1]->type == ET_OR));
186 os << (par1 ? "(" : "");
187 if (data.kids[1]==nullptr) {
188 os << "[]";
189 } else {
190 data.kids[1]->toString(os);
191 }
192 os << (par1 ? ")" : "");
193 return;
194 }
195 case ET_OR:
196 if (data.kids[0]==nullptr) {
197 os << "[]";
198 } else {
199 data.kids[0]->toString(os);
200 }
201 os << "|";
202 if (data.kids[1]==nullptr) {
203 os << "[]";
204 } else {
205 data.kids[1]->toString(os);
206 }
207 return;
208 default: GECODE_NEVER;
209 }
210 GECODE_NEVER;

Callers 4

mainFunction · 0.80
runMethod · 0.80
initfgFunction · 0.80
yyparseFunction · 0.80

Calls 1

strMethod · 0.45

Tested by

no test coverage detected