hammer/src/parsers/epsilon.c

35 lines
745 B
C
Raw Normal View History

2012-05-26 16:00:43 +02:00
#include "parser_internal.h"
static HParseResult* parse_epsilon(void* env, HParseState* state) {
(void)env;
HParseResult* res = a_new(HParseResult, 1);
res->ast = NULL;
res->arena = state->arena;
return res;
}
static bool epsilon_ctrvm(HRVMProg *prog, void* env) {
2013-03-18 15:27:16 -07:00
return true;
}
2012-05-26 16:00:43 +02:00
static const HParserVtable epsilon_vt = {
.parse = parse_epsilon,
.isValidRegular = h_true,
.isValidCF = h_true,
.compile_to_rvm = epsilon_ctrvm,
2012-05-26 16:00:43 +02:00
};
2012-05-26 16:02:50 +02:00
static const HParser epsilon_p = {
.vtable = &epsilon_vt,
.env = NULL
};
2013-04-26 20:36:54 -07:00
HParser* h_epsilon_p() {
return h_epsilon_p__m(&system_allocator);
2012-05-26 16:00:43 +02:00
}
2013-04-26 20:36:54 -07:00
HParser* h_epsilon_p__m(HAllocator* mm__) {
HParser *epsilon_p = h_new(HParser, 1);
epsilon_p->vtable = &epsilon_vt;
return epsilon_p;
2012-10-10 15:58:03 +02:00
}