add "reshape" action to HCFChoice

This commit is contained in:
Sven M. Hallberg 2013-05-14 11:54:43 +02:00
parent 0431528065
commit 623fd6b030
2 changed files with 6 additions and 0 deletions

View file

@ -297,6 +297,10 @@ HParseResult *h_llk_parse(HAllocator* mm__, const HParser* parser, HInputStream*
// XXX set tok->index and tok->bit_offset (don't take directly from stream, cuz peek!) // XXX set tok->index and tok->bit_offset (don't take directly from stream, cuz peek!)
// perform token reshape if indicated
if(x->reshape)
tok = (HParsedToken *)x->reshape(make_result(arena, tok));
// call validation and semantic action, if present // call validation and semantic action, if present
if(x->pred && !x->pred(make_result(tarena, tok))) if(x->pred && !x->pred(make_result(tarena, tok)))
goto no_parse; // validation failed -> no parse goto no_parse; // validation failed -> no parse

View file

@ -285,6 +285,8 @@ typedef struct HCFChoice_ {
HCFSequence** seq; HCFSequence** seq;
uint8_t chr; uint8_t chr;
}; };
HAction reshape; // take CFG parse tree to HParsedToken of expected form.
// to execute before action and pred are applied.
HAction action; HAction action;
HPredicate pred; HPredicate pred;
} HCFChoice; } HCFChoice;