Boost logo

Boost Users :

Subject: Re: [Boost-users] Overcoming AST forward declaration (includes online example)
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2018-11-05 06:01:53


On Mon, Nov 5, 2018 at 12:01 AM Gavin Lambert via Boost-users
<boost-users_at_[hidden]> wrote:
>
> On 3/11/2018 11:34, Michael Powell wrote:
> > The forward declaration errors now the top most errors:
> >
> > https://wandbox.org/permlink/WeRqkmDR93Wqu8BI
>
> Fundamentally you have a cyclic recursion problem.

You're telling me. ;-)

> You're trying to declare that ast_msg_body_t contains by value a variant
> which can contain a ast_group_t which can contain an ast_msg_body_t (and
> similarly for the other possible variant types).
>
> There is no possible way this could compile, as this requires the type
> to be infinite size.
>
> You will need to restructure things; in some cases you can rewrite
> things to use lists, although that's probably not appropriate here. In
> this case you probably need to introduce an indirection and kick
> something onto the heap rather than the stack.
>
> For example, you could make the body members into unique_ptrs. This
> would also let you make the body type use inheritance-based polymorphism
> rather than using a variant (which one is better depends on taste and on
> intended usage).

Effectively, "rewriting" the AST in strategic places is what I did. I
had some help, learned a couple of new tricks, and applications to a
couple of old tricks, circa C++11 bits, at any rate, so far as I can
determine.

http://stackoverflow.com/questions/53120135/how-to-overcome-a-boost-spirit-ast-snafu/

And with several follow up posts.

> (Also, while I'm not familiar with Spirit: there should be a way to make
> it output actual int values rather than strings, unless you need to
> preserve the input format.)
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net