Still broken, but all desugaring functions stubbed out.

This commit is contained in:
Meredith L. Patterson 2013-02-03 02:18:19 -05:00
parent 156be7a559
commit 5ae267f3ed
14 changed files with 147 additions and 26 deletions

View file

@ -42,10 +42,28 @@ static bool sequence_isValidCF(void *env) {
return true;
}
static HCFChoice* desugar_sequence(HAllocator *mm__, void *env) {
HSequence *s = (HSequence*)env;
HCFSequence *seq = h_new(HCFSequence, 1);
seq->items = h_new(HCFChoice*, s->len+1);
for (size_t i=0; i<s->len; ++i) {
seq->items[i] = s->p_array[i]->vtable->desugar(mm__, s->p_array[i]->env);
}
seq->items[s->len] = NULL;
HCFChoice *ret = h_new(HCFChoice, 1);
ret->type = HCF_CHOICE;
ret->seq = h_new(HCFSequence*, 2);
ret->seq[0] = seq;
ret->seq[1] = NULL;
ret->action = NULL;
return ret;
}
static const HParserVtable sequence_vt = {
.parse = parse_sequence,
.isValidRegular = sequence_isValidRegular,
.isValidCF = sequence_isValidCF,
.desugar = desugar_sequence,
};
const HParser* h_sequence(const HParser* p, ...) {