MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenShadingLanguage / parseCat

Method parseCat

src/liboslexec/lpeparse.cpp:172–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170
171
172LPexp *
173Parser::parseCat()
174{
175 //lpexp::Cat *cat = new lpexp::Cat();
176 std::vector<LPexp *> explist;
177 char endchar;
178 if (head() == '(') {
179 next();
180 endchar = ')';
181 }
182 else endchar = 0;
183
184 while (hasInput() && head() != endchar) {
185 if (head() == '|') {
186 if (!explist.size()) {
187 m_error = "No left expression to or with |";
188 for (size_t i=0; i < explist.size(); ++i)
189 delete explist[i];
190 return NULL;
191 }
192 next();
193 LPexp *e = _parse();
194 if (error()) {
195 for (size_t i=0; i < explist.size(); ++i)
196 delete explist[i];
197 return NULL;
198 }
199 if (explist.back()->getType() == lpexp::OR)
200 ((lpexp::Orlist*)explist.back())->append(e);
201 else {
202 lpexp::Orlist *orexp = new lpexp::Orlist();
203 orexp->append(explist.back());
204 orexp->append(e);
205 explist[explist.size() - 1] = orexp;
206 }
207 } else {
208 LPexp *e = _parse();
209 if (error()) {
210 for (size_t i=0; i < explist.size(); ++i)
211 delete explist[i];
212 return NULL;
213 }
214 explist.push_back(e);
215 }
216 }
217 if (hasInput() && head() == endchar)
218 next();
219 else if (endchar != 0) {
220 m_error = "Reached end of line looking for )";
221 for (size_t i=0; i < explist.size(); ++i)
222 delete explist[i];
223 return NULL;
224 }
225 lpexp::Cat *cat = new lpexp::Cat();
226 for (size_t i=0; i < explist.size(); ++i)
227 cat->append(explist[i]);
228 return cat;
229}

Callers

nothing calls this directly

Calls 4

errorFunction · 0.70
sizeMethod · 0.45
getTypeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected