Re: X3 employee example with semantic actions
Maarten Verhage <[email protected]> Wed, 6 Jun 2018 00:56:32 +0000
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <HE1P192MB013702D6F93A3C4ABA5DA51CBA650@HE1P192MB0137.EURP192.PROD.OUTLOOK.COM> |
----- Original Message ----- From: "Larry Evans" <[email protected]> To: <[email protected]> Sent: Wednesday, June 06, 2018 02:44 Subject: Re: [Spirit-general] X3 employee example with semantic actions > On 06/05/2018 07:26 PM, Maarten Verhage wrote: >> >> ----- Original Message ----- >> From: "Larry Evans" <[email protected]> >> To: <[email protected]> >> Sent: Wednesday, June 06, 2018 01:58 >> Subject: Re: [Spirit-general] X3 employee example with semantic actions >> >> >>> On 06/05/2018 01:38 PM, Maarten Verhage wrote: >>> [snip] >>>> In the meantime I've learned by fortunate accident that the parser >>>> directive >>>> **raw** will provide me the iterator range I'm after. As a general >>>> remark >>>> on >>>> this. It is nice if you can immediately understand the facilities >>>> provided >>>> in a documentation page like the Parser Directives. If you don't little >>>> effort is made to properly present the ideas behind these facilities. >>>> Maybe >>>> the Spirit developers are annoyed by what they might consider as naive >>>> questions about obvious things in this mailing list. While I believe >>>> that >>>> if >>>> you improve the documentation and explain for with purpose you provide >>>> facilities people can much faster understand it, and the amount of >>>> "stupid" >>>> questions can be heavily reduced. >>>> >>> To supply a real life use case for what's described in the above >>> paragraph, I've looked at the doc for raw as expressed in the xml >>> generated from: >>> >>> https://github.com/boostorg/spirit/tree/develop/doc/x3 >>> >>> That contains: >>> >>> raw[a] >>> >>> boost::iterator_range<I> >>> >>> Presents the transduction of a as an iterator range >>> >>> From this I infer that an interator_range<I> is produced >>> where I is the Iterator to the parsers. >>> >>> But how do I use this. Grep'ing for raw shows: >>> >>> -*- mode: compilation; default-directory: >>> "~/prog_dev/boost/releases/ro/boost_1_67_0/sandbox/lje/spirit-experiments/include/boost/spirit/home/x3/" >>> -*- >>> Compilation started at Tue Jun 5 18:43:54 >>> >>> find . -name \*.hpp -exec grep -e '\<raw\>' {} \; -ls >>> auto const raw = raw_gen{}; >>> 9109799 12 -rw-rw-r-- 1 evansl evansl 2534 Jan 19 14:59 >>> ./directive/raw.hpp >>> // attr==raw_attribute_type, action wants iterator_range (see >>> raw.hpp) >>> 9049853 16 -rw-rw-r-- 1 evansl evansl 4718 Jun 4 22:09 >>> ./core/action.hpp >>> #include <boost/spirit/home/x3/directive/raw.hpp> >>> 9109791 12 -rw-rw-r-- 1 evansl evansl 1286 Jan 19 14:59 >>> ./directive.hpp >>> >>> Compilation finished at Tue Jun 5 18:43:54 >>> >>> so, a brief look at that code still didn't clear things up; so, >>> Please, Maarten, could you post the code where you make use >>> of raw so I wouldn't have to further guess how to do it? >>> >>> -hopefully, >>> Larry >> >> Hi Larry, >> >> I'm not yet familiar with grep. I assume you do look into the Spirit X3 >> source code to learn how to use it? > > Yep. Tried, but that didn't help. Now that I understand what raw does, > the docs make perfect sense. > >> I have just added the raw directive into >> the employee example code. And it did want I was after. In the attached >> source code you can see exactly how. >> >> I've some facility to print a type by the name of utility::type2string. >> This >> is not needed for the example but I can provide that if you are >> interested. >> >> Regards, Maarten >> > > Hmmm. So you surround the quoted_string with raw. I thought you'd > surround the whole employee with raw. That's why example code > is ***so*** much better than trying to describe what someone is trying > to do! > > -regards, > Larry Hi Larry, Anyway I'm glad the example code was useful to you. But as we wanted to learn how the raw directive has to be used I do not see a difference if you apply it to quoted_string or the whole employee. Regards, Maarten ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot