Conflicts: src/Makefile src/backends/packrat.c src/compile.c src/hammer.h src/internal.h src/parsers/action.c src/parsers/and.c src/parsers/attr_bool.c src/parsers/bits.c src/parsers/butnot.c src/parsers/ch.c src/parsers/charset.c src/parsers/choice.c src/parsers/difference.c src/parsers/end.c src/parsers/epsilon.c src/parsers/ignore.c src/parsers/ignoreseq.c src/parsers/indirect.c src/parsers/int_range.c src/parsers/many.c src/parsers/not.c src/parsers/nothing.c src/parsers/optional.c src/parsers/sequence.c src/parsers/token.c src/parsers/unimplemented.c src/parsers/whitespace.c src/parsers/xor.c
39 lines
841 B
C
39 lines
841 B
C
#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 HCFChoice* desugar_end(HAllocator *mm__, void *env) {
|
|
static HCFChoice ret = {
|
|
.type = HCF_END
|
|
};
|
|
return &ret;
|
|
}
|
|
|
|
static bool end_ctrvm(HRVMProg *prog, void *env) {
|
|
h_rvm_insert_insn(prog, RVM_EOF, 0);
|
|
return true;
|
|
}
|
|
|
|
static const HParserVtable end_vt = {
|
|
.parse = parse_end,
|
|
.isValidRegular = h_true,
|
|
.isValidCF = h_true,
|
|
.desugar = desugar_end,
|
|
.compile_to_rvm = end_ctrvm,
|
|
};
|
|
|
|
HParser* h_end_p() {
|
|
return h_end_p__m(&system_allocator);
|
|
}
|
|
|
|
HParser* h_end_p__m(HAllocator* mm__) {
|
|
return h_new_parser(mm__, &end_vt, NULL);
|
|
}
|