How to adapt an AST involving forward declared meta data

Michael Powell <[email protected]> Wed, 31 Oct 2018 22:15:23 -0400
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <CAMEoF_E0VRKrNBcgZY2OTk-ydpmapAJ788_FsfuW=Kjb7ZpP8w@mail.gmail.com>
Hello,

Like the subject says, I've got some structs in my AST that have to be
forward declared.

// Must forward declare for Group to be happy as a struct.
struct msg_body_t;

struct group_t {
    label_t label;
    std::string name;
    int number;
    msg_body_t body;
};

struct msg_body_t {
    // TODO: TBD: ...
};

Specifically, Group can contain a Message Body.

group = label "group" groupName "=" fieldNumber messageBody

However, Message Body can also reference a Group.

messageBody = "{" { field | enum | message | extend | extensions | group
    | option | oneof | mapField | reserved | emptyStatement } "}"

In terms of the C++ AST itself, I do not know of a way to model this
and at least <messageBody/> not be forward declared.

However, Spirit struct adaptation is balking at this. Literally,

1>g:\source\kingdom
software\kingdom.ortools\standard\src\kingdom.ortools.sat.params.generator\proto_ast.h(100):
error C2079: 'kingdom::google::protobuf::proto2::ast::group_t::body'
uses undefined struct
'kingdom::google::protobuf::proto2::ast::msg_body_t'

I have not completely worked through the AST, but I am getting close.
So I am cautiously optimistic that once I cross the <messageBody/>
bridge, this error will go away.

However, in the meantime, I thought I'd present the question, whether
forward declared AST posed any difficulties to Spirit Qi struct
adaptation to anyone's knowledge.

Best regards,

Michael Powell

https://developers.google.com/protocol-buffers/docs/reference/proto2-spec