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)
|
2013-05-11 19:04:59 +02:00
|
|
|
return make_result(state->arena, NULL);
|
2012-05-26 16:00:43 +02:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const HParserVtable and_vt = {
|
|
|
|
|
.parse = parse_and,
|
2012-12-18 18:10:40 -05:00
|
|
|
.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. */
|
2013-04-22 18:06:17 -07:00
|
|
|
.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
|
|
|
}
|