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

22
src/parsers/and.c Normal file
View file

@ -0,0 +1,22 @@
#include "parser_internal.h"
static HParseResult *parse_and(void* env, HParseState* state) {
HInputStream bak = state->input_stream;
HParseResult *res = h_do_parse((HParser*)env, state);
state->input_stream = bak;
if (res)
return make_result(state, NULL);
return NULL;
}
static const HParserVtable and_vt = {
.parse = parse_and,
};
const HParser* h_and(const HParser* p) {
// zero-width postive lookahead
HParser *res = g_new(HParser, 1);
res->env = (void*)p;
res->vtable = &and_vt;
return res;
}