CF backends weren't checking whether a grammar is CF; they are now. Also, brace-fixing.

This commit is contained in:
Meredith L. Patterson 2014-04-20 16:57:01 +02:00
parent d947c6aede
commit c9419f4c34
5 changed files with 204 additions and 125 deletions

View file

@ -8,14 +8,16 @@ HCFChoice *h_desugar(HAllocator *mm__, HCFStack *stk__, const HParser *parser) {
if (nstk__ == NULL) {
nstk__ = h_cfstack_new(mm__);
}
if(nstk__->prealloc == NULL)
if (nstk__->prealloc == NULL) {
nstk__->prealloc = h_new(HCFChoice, 1);
}
// we're going to do something naughty and cast away the const to memoize
assert(parser->vtable->desugar != NULL);
((HParser *)parser)->desugared = nstk__->prealloc;
parser->vtable->desugar(mm__, nstk__, parser->env);
if (stk__ == NULL)
if (stk__ == NULL) {
h_cfstack_free(mm__, nstk__);
}
} else if (stk__ != NULL) {
HCFS_APPEND(parser->desugared);
}