2012-05-26 16:00:43 +02:00
|
|
|
#include "parser_internal.h"
|
|
|
|
|
|
|
|
|
|
static HParseResult* parse_end(void *env, HParseState *state) {
|
|
|
|
|
if (state->input_stream.index == state->input_stream.length) {
|
|
|
|
|
HParseResult *ret = a_new(HParseResult, 1);
|
|
|
|
|
ret->ast = NULL;
|
|
|
|
|
return ret;
|
|
|
|
|
} else {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-25 03:35:42 +02:00
|
|
|
static void desugar_end(HAllocator *mm__, HCFStack *stk__, void *env) {
|
|
|
|
|
HCFS_ADD_END();
|
2013-02-02 19:31:18 -05:00
|
|
|
}
|
|
|
|
|
|
2013-04-22 18:06:17 -07:00
|
|
|
static bool end_ctrvm(HRVMProg *prog, void *env) {
|
|
|
|
|
h_rvm_insert_insn(prog, RVM_EOF, 0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-26 16:00:43 +02:00
|
|
|
static const HParserVtable end_vt = {
|
|
|
|
|
.parse = parse_end,
|
2012-12-18 18:10:40 -05:00
|
|
|
.isValidRegular = h_true,
|
|
|
|
|
.isValidCF = h_true,
|
2013-02-02 19:31:18 -05:00
|
|
|
.desugar = desugar_end,
|
2013-04-22 18:06:17 -07:00
|
|
|
.compile_to_rvm = end_ctrvm,
|
2012-05-26 16:00:43 +02:00
|
|
|
};
|
|
|
|
|
|
2013-04-26 20:36:54 -07:00
|
|
|
HParser* h_end_p() {
|
2012-10-10 15:58:03 +02:00
|
|
|
return h_end_p__m(&system_allocator);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-26 20:36:54 -07:00
|
|
|
HParser* h_end_p__m(HAllocator* mm__) {
|
2013-04-27 04:17:47 +02:00
|
|
|
return h_new_parser(mm__, &end_vt, NULL);
|
2012-05-26 16:00:43 +02:00
|
|
|
}
|