hammer/src/parsers/end.c

37 lines
786 B
C
Raw Normal View History

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;
}
}
static const HCFChoice* desugar_end(HAllocator *mm__, void *env) {
static HCFChoice ret = {
.type = HCF_END
};
return &ret;
}
2012-05-26 16:00:43 +02:00
static const HParserVtable end_vt = {
.parse = parse_end,
.isValidRegular = h_true,
.isValidCF = h_true,
.desugar = desugar_end,
2012-05-26 16:00:43 +02:00
};
2012-10-10 15:58:03 +02:00
const HParser* h_end_p() {
return h_end_p__m(&system_allocator);
}
const HParser* h_end_p__m(HAllocator* mm__) {
HParser *ret = h_new(HParser, 1);
ret->vtable = &end_vt;
ret->env = NULL;
2012-05-26 16:00:43 +02:00
return (const HParser*)ret;
}