Still doesn't build, but desugaring is farther along
This commit is contained in:
parent
36e1f66de0
commit
156be7a559
16 changed files with 266 additions and 26 deletions
|
|
@ -28,10 +28,57 @@ static HParseResult* parse_int_range(void *env, HParseState *state) {
|
|||
}
|
||||
}
|
||||
|
||||
HCFChoice* gen_int_range(HAllocator *mm__, uint64_t low, uint64_t high, uint8_t bytes) {
|
||||
if (1 == bytes) {
|
||||
HCFChoice *cs = h_new(HCFChoice, 1);
|
||||
cs->type = HCF_CHARSET;
|
||||
cs->charset = new_charset(mm__);
|
||||
for (uint64_t i=low; i<=high; ++i) {
|
||||
charset_set(cs->charset, i, 1);
|
||||
}
|
||||
cs->action = NULL;
|
||||
return cs;
|
||||
}
|
||||
else if (1 < bytes) {
|
||||
HCFChoice *root = h_new(HCFChoice, 1);
|
||||
root->type = HCF_CHOICE;
|
||||
root->seq = h_new(HCFSequence*, 4);
|
||||
root->seq[0] = h_new(HCFSequence, 1);
|
||||
root->seq[0]->items = h_new(HCFChoice*, 2);
|
||||
root->seq[0]->items[0] = gen_int_range(mm__, low, high, FIXME);
|
||||
root->seq[0]->items[1] = NULL;
|
||||
root->seq[1] = h_new(HCFSequence, 1);
|
||||
root->seq[1]->items = h_new(HCFChoice*, 2);
|
||||
root->seq[1]->items[0] = h_new(HCFChoice, 1);
|
||||
/* do something with root->seq[1]->items[0] */
|
||||
root->seq[1]->items[1] = NULL;
|
||||
root->seq[2] = h_new(HCFSequence, 1);
|
||||
root->seq[2]->items = h_new(HCFChoice*, 2);
|
||||
root->seq[2]->items[0] = gen_int_range(mm__, low, high, FIXME);
|
||||
root->seq[2]->items[1] = NULL;
|
||||
root->seq[3] = NULL;
|
||||
root->action = NULL;
|
||||
return root;
|
||||
}
|
||||
else { // idk why this would ever be <1, but whatever
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static HCFChoice* desugar_int_range(HAllocator *mm__, void *env) {
|
||||
HRange *r = (HRange*)env;
|
||||
HCFChoice *ret = h_new(HCFChoice, 1);
|
||||
ret->type = HCF_CHOICE;
|
||||
uint8_t bytes = r->p->env->length / 8;
|
||||
HCFSequence *seq = h_new(HCFSequence, 1);
|
||||
|
||||
}
|
||||
|
||||
static const HParserVtable int_range_vt = {
|
||||
.parse = parse_int_range,
|
||||
.isValidRegular = h_true,
|
||||
.isValidCF = h_true,
|
||||
.desugar = desugar_int_range,
|
||||
};
|
||||
|
||||
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