2012-05-26 16:00:43 +02:00
|
|
|
#include "parser_internal.h"
|
|
|
|
|
|
|
|
|
|
static HParseResult* parse_not(void* env, HParseState* state) {
|
|
|
|
|
HInputStream bak = state->input_stream;
|
|
|
|
|
if (h_do_parse((HParser*)env, state))
|
|
|
|
|
return NULL;
|
|
|
|
|
else {
|
|
|
|
|
state->input_stream = bak;
|
2013-05-11 19:04:59 +02:00
|
|
|
return make_result(state->arena, NULL);
|
2012-05-26 16:00:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const HParserVtable not_vt = {
|
|
|
|
|
.parse = parse_not,
|
2012-12-18 18:10:40 -05:00
|
|
|
.isValidRegular = h_false, /* see and.c for why */
|
2013-05-25 03:35:42 +02:00
|
|
|
.isValidCF = h_false,
|
2013-04-26 20:36:54 -07:00
|
|
|
.compile_to_rvm = h_not_regular, // Is actually regular, but the generation step is currently unable to handle it. TODO: fix this.
|
2012-05-26 16:00:43 +02:00
|
|
|
};
|
|
|
|
|
|
2013-04-26 20:36:54 -07:00
|
|
|
HParser* h_not(const HParser* p) {
|
2012-10-10 15:58:03 +02:00
|
|
|
return h_not__m(&system_allocator, p);
|
|
|
|
|
}
|
2013-04-26 20:36:54 -07:00
|
|
|
HParser* h_not__m(HAllocator* mm__, const HParser* p) {
|
2013-04-27 04:17:47 +02:00
|
|
|
return h_new_parser(mm__, ¬_vt, (void *)p);
|
2012-05-26 16:00:43 +02:00
|
|
|
}
|