move the h_act_* functions to src/actions.c
This commit is contained in:
parent
31256ba867
commit
29cee318f9
6 changed files with 9 additions and 60 deletions
|
|
@ -31,18 +31,6 @@ static HParseResult* parse_ignoreseq(void* env, HParseState *state) {
|
|||
return res;
|
||||
}
|
||||
|
||||
extern const HParsedToken *h_act_first(const HParseResult *p);
|
||||
extern const HParsedToken *h_act_last(const HParseResult *p);
|
||||
|
||||
// XXX to be consolidated with glue.c when merged upstream
|
||||
const HParsedToken *h_act_second(const HParseResult *p) {
|
||||
assert(p->ast);
|
||||
assert(p->ast->token_type == TT_SEQUENCE);
|
||||
assert(p->ast->seq->used > 0);
|
||||
|
||||
return p->ast->seq->elements[1];
|
||||
}
|
||||
|
||||
static HCFChoice* desugar_ignoreseq(HAllocator *mm__, void *env) {
|
||||
HIgnoreSeq *seq = (HIgnoreSeq*)env;
|
||||
HCFSequence *hseq = h_new(HCFSequence, 1);
|
||||
|
|
|
|||
|
|
@ -56,35 +56,6 @@ static bool many_isValidCF(void *env) {
|
|||
repeat->sep->vtable->isValidCF(repeat->sep->env));
|
||||
}
|
||||
|
||||
static void act_flatten_(HCountedArray *seq, const HParsedToken *tok) {
|
||||
if(tok == NULL) {
|
||||
return;
|
||||
} else if(tok->token_type == TT_SEQUENCE) {
|
||||
size_t i;
|
||||
for(i=0; i<tok->seq->used; i++)
|
||||
act_flatten_(seq, tok->seq->elements[i]);
|
||||
} else {
|
||||
h_carray_append(seq, (HParsedToken *)tok);
|
||||
}
|
||||
}
|
||||
|
||||
const HParsedToken *h_act_flatten(const HParseResult *p) {
|
||||
HCountedArray *seq = h_carray_new(p->arena);
|
||||
|
||||
act_flatten_(seq, p->ast);
|
||||
|
||||
HParsedToken *res = a_new_(p->arena, HParsedToken, 1);
|
||||
res->token_type = TT_SEQUENCE;
|
||||
res->seq = seq;
|
||||
res->index = p->ast->index;
|
||||
res->bit_offset = p->ast->bit_offset;
|
||||
return res;
|
||||
}
|
||||
|
||||
const HParsedToken *h_act_ignore(const HParseResult *p) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static HCFChoice* desugar_many(HAllocator *mm__, void *env) {
|
||||
HRepeat *repeat = (HRepeat*)env;
|
||||
if(repeat->count > 1) {
|
||||
|
|
|
|||
|
|
@ -17,15 +17,6 @@ static HParseResult* parse_whitespace(void* env, HParseState *state) {
|
|||
|
||||
static const char SPACE_CHRS[6] = {' ', '\f', '\n', '\r', '\t', '\v'};
|
||||
|
||||
// XXX to be consolidated with glue.c when merged upstream
|
||||
const HParsedToken *h_act_last(const HParseResult *p) {
|
||||
assert(p->ast);
|
||||
assert(p->ast->token_type == TT_SEQUENCE);
|
||||
assert(p->ast->seq->used > 0);
|
||||
|
||||
return p->ast->seq->elements[p->ast->seq->used-1];
|
||||
}
|
||||
|
||||
static HCFChoice* desugar_whitespace(HAllocator *mm__, void *env) {
|
||||
HCFChoice *ws = h_new(HCFChoice, 1);
|
||||
ws->type = HCF_CHOICE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue