hammer/src/parsers/and.c

31 lines
925 B
C
Raw Normal View History

2012-05-26 16:00:43 +02:00
#include "parser_internal.h"
static HParseResult *parse_and(void* env, HParseState* state) {
HInputStream bak = state->input_stream;
HParseResult *res = h_do_parse((HParser*)env, state);
state->input_stream = bak;
if (res)
return make_result(state->arena, NULL);
2012-05-26 16:00:43 +02:00
return NULL;
}
static const HParserVtable and_vt = {
.parse = parse_and,
.isValidRegular = h_false, /* TODO: strictly speaking this should be regular,
but it will be a huge amount of work and difficult
to get right, so we're leaving it for a future
revision. --mlp, 18/12/12 */
.isValidCF = h_false, /* despite TODO above, this remains false. */
.compile_to_rvm = h_not_regular,
2012-05-26 16:00:43 +02:00
};
2012-10-10 15:58:03 +02:00
2013-04-26 20:36:54 -07:00
HParser* h_and(const HParser* p) {
2012-10-10 15:58:03 +02:00
return h_and__m(&system_allocator, p);
}
2013-04-26 20:36:54 -07:00
HParser* h_and__m(HAllocator* mm__, const HParser* p) {
2012-05-26 16:00:43 +02:00
// zero-width postive lookahead
2014-04-13 22:29:49 +00:00
void* env = (void*)p;
return h_new_parser(mm__, &and_vt, env);
2012-05-26 16:00:43 +02:00
}