Skip to content
Snippets Groups Projects
nothing.c 651 B
Newer Older
Dan Hirsch's avatar
Dan Hirsch committed
#include "parser_internal.h"

static HParseResult* parse_nothing() {
  // not a mistake, this parser always fails
  return NULL;
}

Rob Zinkov's avatar
Rob Zinkov committed
static bool nothing_ctrvm(HRVMProg *prog, void* env) {
  h_rvm_insert_insn(prog, RVM_MATCH, 0x00FF);
  return true;
}

Dan Hirsch's avatar
Dan Hirsch committed
static const HParserVtable nothing_vt = {
  .parse = parse_nothing,
  .isValidRegular = h_true,
  .isValidCF = h_true,
Rob Zinkov's avatar
Rob Zinkov committed
  .compile_to_rvm = nothing_ctrvm,
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);
Dan Hirsch's avatar
Dan Hirsch committed
  ret->vtable = &nothing_vt; ret->env = NULL;
  return (const HParser*)ret;
}