Most of RVM desugaring done in first draft, for TQ to check.
This commit is contained in:
parent
a88c6c8a8a
commit
07d35c72ff
23 changed files with 182 additions and 4 deletions
|
|
@ -28,10 +28,31 @@ static HParseResult* parse_int_range(void *env, HParseState *state) {
|
|||
}
|
||||
}
|
||||
|
||||
bool h_svm_action_validate_int_range(HArena *arena, HSVMContext *ctx, void* env) {
|
||||
HRange *r_env = (*HRange)env;
|
||||
HParsedToken *head = ctx->stack[ctx->stack_count-1];
|
||||
switch (head-> token_type) {
|
||||
case TT_SINT:
|
||||
return head->sint >= r_env->lower && head->sint <= r_env->upper;
|
||||
case TT_UINT:
|
||||
return head->uint >= (uint64_t)r_env->lower && head->uint <= (uint64_t)r_env->upper;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
static bool ir_ctrvm(HRVMProg *prog, void *env) {
|
||||
HRange *r_env = (*HRange)env;
|
||||
|
||||
h_compile_regex(prog, r_env->p);
|
||||
h_rvm_insert_insn(prog, RVM_ACTION, h_rvm_create_action(prog, h_svm_action_validate_int_range, env));
|
||||
return false;
|
||||
}
|
||||
|
||||
static const HParserVtable int_range_vt = {
|
||||
.parse = parse_int_range,
|
||||
.isValidRegular = h_true,
|
||||
.isValidCF = h_true,
|
||||
.compile_to_rvm = ir_ctrvm,
|
||||
};
|
||||
|
||||
const HParser* h_int_range(const HParser *p, const int64_t lower, const int64_t upper) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue