| 231 | |
| 232 | |
| 233 | LPexp * |
| 234 | Parser::parseGroup() |
| 235 | { |
| 236 | ASSERT(head() == '<'); |
| 237 | if (m_ingroup) { |
| 238 | m_error = "No groups allowed inside of groups"; |
| 239 | return NULL; |
| 240 | } |
| 241 | int basicpos = 0; |
| 242 | LPexp *basics[2] = {NULL, NULL}; |
| 243 | std::list<LPexp *> custom; |
| 244 | #define THROWAWAY() do{\ |
| 245 | for (int i=0;i<2;++i) if(basics[i]) delete basics[i];\ |
| 246 | for (std::list<LPexp *>::iterator i = custom.begin();i!=custom.end();++i) delete *i;\ |
| 247 | m_ingroup = false;\ |
| 248 | return NULL;\ |
| 249 | }while(0) |
| 250 | |
| 251 | m_ingroup = true; |
| 252 | next(); |
| 253 | while (hasInput() && head() != '>') { |
| 254 | LPexp *e = _parse(); |
| 255 | if (error()) THROWAWAY(); |
| 256 | if (basicpos < 2) |
| 257 | basics[basicpos++] = e; |
| 258 | else |
| 259 | custom.push_back(e); |
| 260 | } |
| 261 | |
| 262 | if (!hasInput()) { |
| 263 | m_error = "Reached end of line looking for > to end a group"; |
| 264 | THROWAWAY(); |
| 265 | } |
| 266 | next(); |
| 267 | m_ingroup = false; |
| 268 | for (; basicpos < 2; ++basicpos) |
| 269 | basics[basicpos] = new lpexp::Wildexp(m_minus_stop); |
| 270 | return buildStop(basics[0], basics[1], custom); |
| 271 | } |
| 272 | |
| 273 | |
| 274 | |