Boost logo

Boost Users :

Subject: [Boost-users] Overcoming AST forward declaration (includes online example)
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2018-11-02 21:16:44


Please find the example posted here:

The couple of concerns I have in question at the moment are:

* How to best handle variants throughout the grammar. Can I use
std::variant? Do I need to use boost::variant? Are there additional
Spirit features that make this doable?

* Embedded in that question is what to do with "nil" or "empty
statements" which occurs throughout the grammar at times. I wondered
if "empty statement" could synthesize "nothing", literally, not
contribute to a variant alternative, for instance. Other AST examples
seemed to inject a "struct nil {}" pattern, so I figured maybe this
was the better approach?

* The real kerfuffle for me at the moment is the AST forward
declaration. From what I gather in the protocol, this is an absolute
must have. It most occur before Group, and is also used by Message.

Thoughts? Suggestions?

And, please, before you suggest there are "proto compilers" already
available: yes, I know, I've been down that road. I am not looking to
parse the proto itself, per se, but rather do some code generation for
target language artifacts other than the proto itself.

Toward which end, I am also investigating a protoc compiler plugin
approach. But I figured, I'd pursue this as a viable path to solving
the problem as well, notwithstanding the above challenges.

Thanks in advance!


Michael Powell

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at