Supposing deku had the deku_parent thing (which can probably be done already, albeit verbosely, with ctx), something tells me that this wouldn't sit well with the borrow checker. The parent struct is still being parsed and therefore needs to be mutable, but we are making immutable references to it.
skipping foo_ref also requires &Foo to have a Default, which makes no sense. Maybe you'd have to use raw pointers to allow a NULL pointer...
Another option is to not to the conversion during parsing, but to post-process it, or generate some kind of "index to reference" map after the fact.
But anyway, I'm wondering, Is there an idiom for doing this kind of thing with deku?
Hi,
We have a parser for a compiler IR where we use indices for the (immutable) on-disk serialisation format, and we read it in with Deku.
We'd like to be able to convert the indices to immutable references for ease of use once parsing is complete.
I mocked this up:
Is there a way to convert the
foo_idx
into a reference tofoos[0]
during parsing?I can imagine an API that perhaps looks like this (or similar):
Supposing deku had the
deku_parent
thing (which can probably be done already, albeit verbosely, withctx
), something tells me that this wouldn't sit well with the borrow checker. The parent struct is still being parsed and therefore needs to be mutable, but we are making immutable references to it.skip
pingfoo_ref
also requires&Foo
to have aDefault
, which makes no sense. Maybe you'd have to use raw pointers to allow a NULL pointer...Another option is to not to the conversion during parsing, but to post-process it, or generate some kind of "index to reference" map after the fact.
But anyway, I'm wondering, Is there an idiom for doing this kind of thing with deku?
Thanks