hammer/src/parsers/nothing.c

33 lines
757 B
C
Raw Normal View History

2012-05-26 16:00:43 +02:00
#include "parser_internal.h"
static HParseResult* parse_nothing() {
// not a mistake, this parser always fails
return NULL;
}
static HCFChoice *desugar_nothing(HAllocator *mm__, void *env) {
HCFChoice *ret = h_new(HCFChoice, 1);
ret->type = HCF_CHOICE;
ret->seq = h_new(HCFSequence*, 1);
ret->seq[0] = NULL;
ret->action = NULL;
return ret;
}
2012-05-26 16:00:43 +02:00
static const HParserVtable nothing_vt = {
.parse = parse_nothing,
.isValidRegular = h_true,
.isValidCF = h_true,
.desugar = desugar_nothing,
2012-05-26 16:00:43 +02:00
};
2012-10-10 15:58:03 +02:00
const HParser* h_nothing_p() {
return h_nothing_p__m(&system_allocator);
}
const HParser* h_nothing_p__m(HAllocator* mm__) {
HParser *ret = h_new(HParser, 1);
2012-05-26 16:00:43 +02:00
ret->vtable = &nothing_vt; ret->env = NULL;
return (const HParser*)ret;
}