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

static HParseResult* parse_nothing(void* x,HParseState* y) {
  (void)(x);
  (void)(y);
Dan Hirsch's avatar
Dan Hirsch committed
  // not a mistake, this parser always fails
  return NULL;
}

static void desugar_nothing(HAllocator *mm__, HCFStack *stk__, void *env) {
  HCFS_BEGIN_CHOICE() {
  } HCFS_END_CHOICE();
Rob Zinkov's avatar
Rob Zinkov committed
static bool nothing_ctrvm(HRVMProg *prog, void* env) {
Dan Hirsch's avatar
Dan Hirsch committed
  h_rvm_insert_insn(prog, RVM_MATCH, 0x0000);
  h_rvm_insert_insn(prog, RVM_MATCH, 0xFFFF);
Rob Zinkov's avatar
Rob Zinkov committed
  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,
Dan Hirsch's avatar
Dan Hirsch committed
HParser* h_nothing_p() {
  return h_nothing_p__m(&system_allocator);
}
Dan Hirsch's avatar
Dan Hirsch committed
HParser* h_nothing_p__m(HAllocator* mm__) { 
  return h_new_parser(mm__, &nothing_vt, NULL);
Dan Hirsch's avatar
Dan Hirsch committed
}