Merge pull request #7 from zaxtax/regex

Adding epislon and nothing
This commit is contained in:
Meredith L. Patterson 2013-03-18 17:12:40 -07:00
commit a88c6c8a8a
2 changed files with 11 additions and 1 deletions

View file

@ -8,10 +8,15 @@ static HParseResult* parse_epsilon(void* env, HParseState* state) {
return res; return res;
} }
static bool episilon_ctrvm(HRVMProg *prog, void* env) {
return true;
}
static const HParserVtable epsilon_vt = { static const HParserVtable epsilon_vt = {
.parse = parse_epsilon, .parse = parse_epsilon,
.isValidRegular = h_true, .isValidRegular = h_true,
.isValidCF = h_true, .isValidCF = h_true,
.compile_to_rvm = episilon_ctrvm,
}; };
static const HParser epsilon_p = { static const HParser epsilon_p = {

View file

@ -1,15 +1,20 @@
#include "parser_internal.h" #include "parser_internal.h"
static HParseResult* parse_nothing() { static HParseResult* parse_nothing() {
// not a mistake, this parser always fails // not a mistake, this parser always fails
return NULL; return NULL;
} }
static bool nothing_ctrvm(HRVMProg *prog, void* env) {
h_rvm_insert_insn(prog, RVM_MATCH, 0x00FF);
return true;
}
static const HParserVtable nothing_vt = { static const HParserVtable nothing_vt = {
.parse = parse_nothing, .parse = parse_nothing,
.isValidRegular = h_true, .isValidRegular = h_true,
.isValidCF = h_true, .isValidCF = h_true,
.compile_to_rvm = nothing_ctrvm,
}; };
const HParser* h_nothing_p() { const HParser* h_nothing_p() {