CharSet* Action::Symbols(Tab *tab) { CharSet *s; if (typ == Node::clas) s = tab->CharClassSet(sym)->Clone(); else { s = new CharSet(); s->Set(sym); } return s; }
void CharSet::Subtract(CharSet *s) { CharSet *x = new CharSet(); Range *p = head; while (p != NULL) { for (int i = p->from; i <= p->to; i++) if (!s->Get(i)) x->Set(i); Range *del = p; p = p->next; delete del; } head = x->head; x->head = NULL; delete x; }
void CharSet::Subtract(const CharSet& b) { CharSet tmp; Range *p = head; while (p != NULL) { for (int i = p->from; i <= p->to; i++) { if (!b.Get(i)) { tmp.Set(i); } } // cleanup old storage - as per Clear Range *del = p; p = p->next; delete del; } head = tmp.head; tmp.head = NULL; // avoid double deletion }