Refactored all of the desugaring code to no longer depend on memory being initialized to 0. Everything is about 12% faster now.
This commit is contained in:
parent
d71215d494
commit
ec404ca8fe
36 changed files with 411 additions and 417 deletions
|
|
@ -44,25 +44,15 @@ static HParsedToken *reshape_token(const HParseResult *p) {
|
|||
return tok;
|
||||
}
|
||||
|
||||
static HCFChoice* desugar_token(HAllocator *mm__, void *env) {
|
||||
static void desugar_token(HAllocator *mm__, HCFStack *stk__, void *env) {
|
||||
HToken *tok = (HToken*)env;
|
||||
HCFSequence *seq = h_new(HCFSequence, 1);
|
||||
seq->items = h_new(HCFChoice*, 1+tok->len);
|
||||
for (size_t i=0; i<tok->len; ++i) {
|
||||
seq->items[i] = h_new(HCFChoice, 1);
|
||||
seq->items[i]->type = HCF_CHAR;
|
||||
seq->items[i]->chr = tok->str[i];
|
||||
}
|
||||
seq->items[tok->len] = NULL;
|
||||
HCFChoice *ret = h_new(HCFChoice, 1);
|
||||
ret->type = HCF_CHOICE;
|
||||
ret->seq = h_new(HCFSequence*, 2);
|
||||
ret->seq[0] = seq;
|
||||
ret->seq[1] = NULL;
|
||||
ret->action = NULL;
|
||||
ret->pred = NULL;
|
||||
ret->reshape = reshape_token;
|
||||
return ret;
|
||||
HCFS_BEGIN_CHOICE() {
|
||||
HCFS_BEGIN_SEQ() {
|
||||
for (size_t i = 0; i < tok->len; i++)
|
||||
HCFS_ADD_CHAR(tok->str[i]);
|
||||
} HCFS_END_SEQ();
|
||||
HCFS_THIS_CHOICE->reshape = reshape_token;
|
||||
} HCFS_END_CHOICE();
|
||||
}
|
||||
|
||||
static bool token_ctrvm(HRVMProg *prog, void *env) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue