Re: How to adapt an AST involving forward declared meta data
Michael Powell <[email protected]> Fri, 2 Nov 2018 17:15:24 -0400
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <CAMEoF_FnQgBF+yBxg8YZDWSoSHR42Ph5qnHqOxBUFyWitF3uxA@mail.gmail.com> |
On Fri, Nov 2, 2018 at 11:30 AM Larry Evans <[email protected]> wrote: > > On 11/1/18 9:05 AM, Michael Powell wrote: > > On Wed, Oct 31, 2018 at 10:15 PM Michael Powell <[email protected]> wrote: > >> > >> Hello, > >> > >> Like the subject says, I've got some structs in my AST that have to be > >> forward declared. I'll consider that simplification, thanks for that suggestion. The chief block I am having right now is the forward declaration, however. I think whether I am specializing a template class versus the concrete class, I'm going to run into a forward declaration one way or another. > > Okay, I've worked through the basic AST concepts I think I need for > > this problem. However, the VS2017 C2079 error is not going away, not > > without modifying the approach: > > > > One possible way is to "introduce" pointers into the AST. Question > > along these lines, how good is Spirit Qi at working with AST, > > pointers, etc? Smart pointers preferred, I think, if possible. > > > > struct bool_t { > > std::string val; > > }; > > > > struct str_t { > > std::string quoted_text; > > }; > > > > struct full_id_t { > > std::string full_id; > > }; > > > > struct int_t { > > std::string val; > > }; > > > > struct float_t { > > std::string val; > > }; > > > IIRC, one problem with boost::variant and possible spirit::variant is > the ambiguity when types or duplicated. IOW: > > variant<T,T,T> v3t; > > doesn't work because assignment: > > v3t = T{}; > > doesn't know which of the 3 T's is meant. T, in your case, is > std::string. You've solved it by essentially repeated the > same value type (i.e. std::string) wrapped in a different class. > > A possible simplification is: > > enum types > { bool_t > , str_t > , full_id_t > , int_t > , float_t > }; > > template<types Type> > struct value_t > { std::string value_v > }; > > It would save a little typing. > > -regards, > Larry > > > > _______________________________________________ > Spirit-general mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/spirit-general