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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-03 02:18:19 -05:00
|
|
|
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,
|
2012-12-18 18:10:40 -05:00
|
|
|
.isValidRegular = h_true,
|
|
|
|
|
.isValidCF = h_true,
|
2013-02-03 02:18:19 -05:00
|
|
|
.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 = ¬hing_vt; ret->env = NULL;
|
|
|
|
|
return (const HParser*)ret;
|
|
|
|
|
}
|