Added generic form of desugaring functions

This commit is contained in:
Dan Hirsch 2013-03-16 14:30:15 -07:00
parent 5df9db015c
commit ffd050e603
3 changed files with 4 additions and 1 deletions

View file

@ -34,6 +34,7 @@ HAMMER_PARTS := \
bitwriter.o \ bitwriter.o \
pprint.o \ pprint.o \
allocator.o \ allocator.o \
desugar.o \
datastructures.o \ datastructures.o \
system_allocator.o \ system_allocator.o \
benchmark.o \ benchmark.o \

View file

@ -224,6 +224,8 @@ long long h_read_bits(HInputStream* state, int count, char signed_p);
HParseResult* h_do_parse(const HParser* parser, HParseState *state); HParseResult* h_do_parse(const HParser* parser, HParseState *state);
void put_cached(HParseState *ps, const HParser *p, HParseResult *cached); void put_cached(HParseState *ps, const HParser *p, HParseResult *cached);
HCFChoice *h_desugar(HAllocator *mm__, HParser *parser);
HCountedArray *h_carray_new_sized(HArena * arena, size_t size); HCountedArray *h_carray_new_sized(HArena * arena, size_t size);
HCountedArray *h_carray_new(HArena * arena); HCountedArray *h_carray_new(HArena * arena);
void h_carray_append(HCountedArray *array, void* item); void h_carray_append(HCountedArray *array, void* item);

View file

@ -47,7 +47,7 @@ static HCFChoice* desugar_sequence(HAllocator *mm__, void *env) {
HCFSequence *seq = h_new(HCFSequence, 1); HCFSequence *seq = h_new(HCFSequence, 1);
seq->items = h_new(HCFChoice*, s->len+1); seq->items = h_new(HCFChoice*, s->len+1);
for (size_t i=0; i<s->len; ++i) { 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[i] = h_desugar(s->p_array[i]);
} }
seq->items[s->len] = NULL; seq->items[s->len] = NULL;
HCFChoice *ret = h_new(HCFChoice, 1); HCFChoice *ret = h_new(HCFChoice, 1);