Merge remote-tracking branch 'tq/master' into LL such that it compiles
Conflicts: src/Makefile src/backends/packrat.c src/compile.c src/hammer.h src/internal.h src/parsers/action.c src/parsers/and.c src/parsers/attr_bool.c src/parsers/bits.c src/parsers/butnot.c src/parsers/ch.c src/parsers/charset.c src/parsers/choice.c src/parsers/difference.c src/parsers/end.c src/parsers/epsilon.c src/parsers/ignore.c src/parsers/ignoreseq.c src/parsers/indirect.c src/parsers/int_range.c src/parsers/many.c src/parsers/not.c src/parsers/nothing.c src/parsers/optional.c src/parsers/sequence.c src/parsers/token.c src/parsers/unimplemented.c src/parsers/whitespace.c src/parsers/xor.c
This commit is contained in:
commit
c64a4e435e
46 changed files with 1289 additions and 263 deletions
|
|
@ -21,7 +21,7 @@ static HParseResult* parse_sequence(void *env, HParseState *state) {
|
|||
}
|
||||
HParsedToken *tok = a_new(HParsedToken, 1);
|
||||
tok->token_type = TT_SEQUENCE; tok->seq = seq;
|
||||
return make_result(state, tok);
|
||||
return make_result(state->arena, tok);
|
||||
}
|
||||
|
||||
static bool sequence_isValidRegular(void *env) {
|
||||
|
|
@ -59,34 +59,46 @@ static HCFChoice* desugar_sequence(HAllocator *mm__, void *env) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static bool sequence_ctrvm(HRVMProg *prog, void *env) {
|
||||
HSequence *s = (HSequence*)env;
|
||||
h_rvm_insert_insn(prog, RVM_PUSH, 0);
|
||||
for (size_t i=0; i<s->len; ++i) {
|
||||
if (!s->p_array[i]->vtable->compile_to_rvm(prog, s->p_array[i]->env))
|
||||
return false;
|
||||
}
|
||||
h_rvm_insert_insn(prog, RVM_ACTION, h_rvm_create_action(prog, h_svm_action_make_sequence, NULL));
|
||||
return true;
|
||||
}
|
||||
|
||||
static const HParserVtable sequence_vt = {
|
||||
.parse = parse_sequence,
|
||||
.isValidRegular = sequence_isValidRegular,
|
||||
.isValidCF = sequence_isValidCF,
|
||||
.desugar = desugar_sequence,
|
||||
.compile_to_rvm = sequence_ctrvm,
|
||||
};
|
||||
|
||||
const HParser* h_sequence(const HParser* p, ...) {
|
||||
HParser* h_sequence(const HParser* p, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, p);
|
||||
const HParser* ret = h_sequence__mv(&system_allocator, p, ap);
|
||||
HParser* ret = h_sequence__mv(&system_allocator, p, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const HParser* h_sequence__m(HAllocator* mm__, const HParser* p, ...) {
|
||||
HParser* h_sequence__m(HAllocator* mm__, const HParser* p, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, p);
|
||||
const HParser* ret = h_sequence__mv(mm__, p, ap);
|
||||
HParser* ret = h_sequence__mv(mm__, p, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const HParser* h_sequence__v(const HParser* p, va_list ap) {
|
||||
HParser* h_sequence__v(const HParser* p, va_list ap) {
|
||||
return h_sequence__mv(&system_allocator, p, ap);
|
||||
}
|
||||
|
||||
const HParser* h_sequence__mv(HAllocator* mm__, const HParser *p, va_list ap_) {
|
||||
HParser* h_sequence__mv(HAllocator* mm__, const HParser *p, va_list ap_) {
|
||||
va_list ap;
|
||||
size_t len = 0;
|
||||
const HParser *arg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue