From 623fd6b0303ee390a5c38fe2b2ea2789edda660f Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Tue, 14 May 2013 11:54:43 +0200 Subject: [PATCH] add "reshape" action to HCFChoice --- src/backends/llk.c | 4 ++++ src/internal.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/backends/llk.c b/src/backends/llk.c index 13152c35..72b39bbb 100644 --- a/src/backends/llk.c +++ b/src/backends/llk.c @@ -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!) + // perform token reshape if indicated + if(x->reshape) + tok = (HParsedToken *)x->reshape(make_result(arena, tok)); + // call validation and semantic action, if present if(x->pred && !x->pred(make_result(tarena, tok))) goto no_parse; // validation failed -> no parse diff --git a/src/internal.h b/src/internal.h index 7592fed0..a48fb29e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -285,6 +285,8 @@ typedef struct HCFChoice_ { HCFSequence** seq; uint8_t chr; }; + HAction reshape; // take CFG parse tree to HParsedToken of expected form. + // to execute before action and pred are applied. HAction action; HPredicate pred; } HCFChoice; -- GitLab