Beispiel #1
0
void FreeAttrList (Collection* C)
/* Free a list of attributes */
{
    unsigned I;

    /* Walk over the collection and free all attributes */
    for (I = 0; I < CollCount (C); ++I) {
        FreeAttr (CollAtUnchecked (C, I));
    }

    /* Free the collection itself */
    FreeCollection (C);
}
Beispiel #2
0
/* build a canonical LR(1) parse table */
int BuildLRParser(GRAMMAR_TABLE grammar,
                  LR_TABLE*     parser)
{
    FindNullableNonterminals(&grammar);
    BuildFirstSets(&grammar);
    BuildFollowSets(&grammar);
    
    // building the collection of item sets for an LR(1) grammar
    LR_ITEM_COLLECTION* C = CanonicalCollection(&grammar);
    //PrintCollection(C, &grammar);
    
    RemoveEpsilons(&grammar);
    
    *parser = ConstructTable(C, &grammar);
    FreeCollection(C);
    return 0;
}