static void test_sets() { CC_Set set; CC_Class *cc[10]; CC_initSet(&set); cc[0] = CC_addToSet(&set); CC_addChar(cc[0], 1); CC_addChar(cc[0], 2); CC_addChar(cc[0], 3); CC_addChar(cc[0], 9); CC_addChar(cc[0], 10); CC_addChar(cc[0], 11); cc[1] = CC_addToSet(&set); CC_addChar(cc[1], 3); CC_addChar(cc[1], 4); cc[2] = CC_addToSet(&set); CC_addChar(cc[2], 4); CC_addChar(cc[2], 5); CC_addChar(cc[2], 6); CC_addChar(cc[2], 7); CC_addChar(cc[2], 8); cc[3] = CC_addToSet(&set); CC_addChar(cc[3], 3); CC_addChar(cc[3], 8); CC_addChar(cc[3], 9); CC_partitionSet(&set); /* printf("partitioned set:\n"); CC_writeSetToFile(stdout, &set); printf("\n"); */ CC_flushSet(&set); cc[0] = CC_addToSet(&set); CC_addATermClass(cc[0], ATparse("char-class([range(65,90)])")); cc[1] = CC_addToSet(&set); CC_addATermClass(cc[1], ATparse("char-class([range(65,90)])")); cc[2] = CC_addToSet(&set); CC_addATermClass(cc[2], ATparse("char-class([76])")); CC_partitionSet(&set); /* printf("partitioned set:\n"); CC_writeSetToFile(stdout, &set); printf("\n"); */ }
/* Given an itemset find the productions or symbols that will label the edges * leaving the state containing the given itemset. Specifically: * - For items of the form (\cdot \alpha -> X) add that item's production * number to predprods. * - For items of the form (\alpha \cdot A \beta -> X) add A to predchars, * where can be a terminal or a non-terminal encoded as a char-class. */ void outgoing(ItemSet itemset, ATermList *predprods, CC_Set *predchars) { Item item; PT_Symbol symbol; ItemSetIterator iter; *predprods = ATempty; ITS_iterator(itemset, &iter); while (ITS_hasNext(&iter)) { item = ITS_next(&iter); if (IT_getDotPosition(item) == 0) { ATerm prod = (ATerm)ATmakeInt(IT_getProdNr(item)); /*assert(ATindexOf(*predprods, prod, 0) == -1);*/ *predprods = ATinsert(*predprods, prod); } symbol = (PT_Symbol)IT_getDotSymbol(item); if (PT_isSymbolCharClass(symbol)) { CC_addPTSymbolToClass(CC_addToSet(predchars), symbol); } } }