Re: Spirit X3 employee.cpp compile error
Larry Evans <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
On 08/12/2016 09:19 AM, Vincent Virgilio wrote: > > >> On Aug 12, 2016, at 9:29 AM, Larry Evans <[email protected]> wrote: >> >>> On 08/12/2016 07:53 AM, Vincent Virgilio wrote: >>> >>> >>>> On Aug 12, 2016, at 08:27 AM, Larry Evans <[email protected]> wrote: >>>> >>>>> On 08/12/2016 06:40 AM, Larry Evans wrote: >>>>> [snip] >>>>> >>>>>> GitHub: [email protected] <mailto:[email protected]>:boostorg/spirit.git >>>>>> >>>>>> Use the develop branch. >>>>>> --}--cut here-- >>>>> The 2 template arg rule code is actually in the x3-devel branch instead >>>>> of the develop branch: >>>>> >>>>> https://github.com/boostorg/spirit/blob/x3-devel/include/boost/spirit/home/x3/nonterminal/rule.hpp#L80 >>>> [snip] >>>> However, if you decide to use x3-devel, then the employee.cpp code >>>> referenced in your OP needs to be modified so that the arguments >>>> to BOOST_SPIRIT_DEFINE contain assignments instead of just >>>> rule names. For example, see: >>>> >>>> https://github.com/boostorg/spirit/blob/x3-devel/example/x3/calc4.cpp#L218 >>>> >>>> HTH. >>>> >>>> -regards, >>>> Larry >>> >>> Hi Larry, >>> >>> Thanks for all the help so far. >>> >>> Why is BOOST_SPIRIT_DEFINE required if the rule declarations and >>> definitions are already associated via assignment? In another small >>> project, I was able to parse with an X3 grammar without that macro. In >>> that case, very schematically, I had "auto const rule_name = rule<...>() >>> = rule_def;" >> [snip] >> Hi Vincent, >> >> I can only guess that the grammar in this small project had no >> recursive rules like the calc4.cpp grammar I mentioned above. >> >> That's only a guess; however, I *think* the whole purpose of >> BOOST_SPIRIT_DEFINE is to allow mutually recursive rules, such as >> that in calc4.cpp, *and* to avoid massive template names. >> At least that's the conclusion I reach after reading >> [email protected] reply to me here: >> >> https://sourceforge.net/p/spirit/mailman/message/35271675/ >> >> HTH. >> >> -regards, >> Larry > > Yes, the grammar was tiny. > > I think I see what you're saying. Great! The following gist: https://gist.github.com/cppljevans/3d3bec54be8f3d0c4d8b94af84a6e529 hopefully will make things more clear. It shows a grammar without recursion and one with. There's also a macro, USE_DEFINE, which, if !defined(USE_DEFINE), causes a compile error something like: define.o toy_why_define.cpp:132:9: error: static_assert failed "BOOST_SPIRIT_DEFINE undefined for this rule." static_assert(!boost::is_same<get_type,undefined>::value,"BOOST_SPIRIT_DEFINE undefined for this rule."); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OTOH, when defined(USE_DEFINE), it runs without error. The comments above the #define USE_SPIRIT_DEFINE try to explain how it works. HTH. -regards, Larry ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://sdm.link/zohodev2dev