All tests pass; lots of stuff is no longer const
This commit is contained in:
parent
b9a33f2c98
commit
d71215d494
24 changed files with 216 additions and 120 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#include <assert.h>
|
||||
#include "parser_internal.h"
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -48,9 +49,30 @@ static HCFChoice* desugar_ab(HAllocator *mm__, void *env) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static bool h_svm_action_attr_bool(HArena *arena, HSVMContext *ctx, void* arg) {
|
||||
HParseResult res;
|
||||
HPredicate pred = arg;
|
||||
assert(ctx->stack_count >= 1);
|
||||
if (ctx->stack[ctx->stack_count-1]->token_type != TT_MARK) {
|
||||
assert(ctx->stack_count >= 2 && ctx->stack[ctx->stack_count-2]->token_type == TT_MARK);
|
||||
ctx->stack_count--;
|
||||
res.ast = ctx->stack[ctx->stack_count-1] = ctx->stack[ctx->stack_count];
|
||||
// mark replaced.
|
||||
} else {
|
||||
ctx->stack_count--;
|
||||
res.ast = NULL;
|
||||
}
|
||||
res.arena = arena;
|
||||
return pred(&res);
|
||||
}
|
||||
|
||||
static bool ab_ctrvm(HRVMProg *prog, void *env) {
|
||||
HAttrBool *ab = (HAttrBool*)env;
|
||||
return h_compile_regex(prog, ab->p);
|
||||
h_rvm_insert_insn(prog, RVM_PUSH, 0);
|
||||
if (!h_compile_regex(prog, ab->p))
|
||||
return false;
|
||||
h_rvm_insert_insn(prog, RVM_ACTION, h_rvm_create_action(prog, h_svm_action_attr_bool, ab->pred));
|
||||
return true;
|
||||
}
|
||||
|
||||
static const HParserVtable attr_bool_vt = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue