Refactor ALL the things!

This commit is contained in:
Dan Hirsch 2012-05-26 16:00:43 +02:00
parent 6a2f10df0c
commit f2def8fa05
28 changed files with 930 additions and 855 deletions

20
src/parsers/indirect.c Normal file
View file

@ -0,0 +1,20 @@
#include "parser_internal.h"
static HParseResult* parse_indirect(void* env, HParseState* state) {
return h_do_parse(env, state);
}
static const HParserVtable indirect_vt = {
.parse = parse_indirect,
};
void h_bind_indirect(HParser* indirect, HParser* inner) {
assert_message(indirect->vtable == &indirect_vt, "You can only bind an indirect parser");
indirect->env = inner;
}
HParser* h_indirect() {
HParser *res = g_new(HParser, 1);
res->vtable = &indirect_vt;
res->env = NULL;
return res;
}