Re: X3 employee example with semantic actions

Larry Evans <[email protected]> Tue, 5 Jun 2018 13:54:54 -0500
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 06/05/2018 01:38 PM, Maarten Verhage wrote:
> 
> ----- Original Message -----
> From: "Larry Evans" <[email protected]>
> To: <[email protected]>
> Sent: Tuesday, June 05, 2018 18:43
> Subject: Re: [Spirit-general] X3 employee example with semantic actions
> 
> 
>> On 06/03/2018 09:03 PM, Joel de Guzman wrote:
>>> On 04/06/2018 5:41 AM, Seth wrote:
>>>> On 03-06-18 23:34, Maarten Verhage wrote:
>>>>> Sure I'm willing to learn. But where can I find the compiler examples
>>>>> you
>>>>> mentioned?
>>>>
>>>> look for `position_tagged` and `annotate_on_success` in e.g.
>>>> https://github.com/boostorg/spirit/blob/develop/example/x3/rexpr/rexpr_full/rexpr/rexpr_def.hpp
>>>
>>> Also check out the new examples (in devel) and the updated docs!
>>>
>>> Regards,
>> Joel,
>>
>> I was able to build the docs, but only after I'd built quickbook.
>> Couldn't there be specified a dependency of spirit docs on quickbook.
>>
>> After reading the docs briefly, I attempted an
>> as-close-as-possible ast annotation version of:
>>
>> https://gist.github.com/cppljevans/0f4351f127c2e651d8094877a9510e5a#file-x3-employee-beg_end_attr_actions-cpp
>>
>> That ast annotation implementation is here:
>>
>> https://gist.github.com/cppljevans/0f4351f127c2e651d8094877a9510e5a#file-x3-employee-annot_attr-cpp
>>
>> when run, it shows the attributes includes *both* the delimiters to the
>> input but also the actual employee::{age,first_name,last_name,salary}
>> attributes. I thought Maarten was wanting to avoid that,
>>
>> Maarten, is that right?
>>
>> -regards,
>> Larry
> 
> Hi Larry,
> 
> In an earlier message I explained I wasn't able to run the annotation
> example properly as it did not print the specific employee indicated with
> ast[1] I believe. 

Well, initially, I got:

-------------------------
Parsing succeeded
got:
***struct output***
{ age=23
, first_name=Amanda
, last_name=Stefanski
, salary=1000.99
}
***string output***

-------------------------
.
.
.

But then I thought about what Joel said about develop; so, I
added that to the -I flags to the compiler, and viola:

-------------------------
Parsing succeeded
got:
***struct output***
{ age=23
, first_name=Amanda
, last_name=Stefanski
, salary=1000.99
}
***string output***
{
     23,
     "Amanda",
     "Stefanski",
     1000.99
}
-------------------------

HTH.

> I'm unsure if your terms of delimiters to the input is the
> same as my wording of two interators into the input of a parsed result. 
Yes, I did mean 2 iterators (which delimit the input).
> If
> so them yes I'm only after that. And then for some other rules I would like
> to have an actual parsed value in Context _attr.
> 
> In the meantime I've learned by fortunate accident that the parser directive
> **raw** will provide me the iterator range I'm after. 
Ah, thanks.  I wasn't aware of that.
> 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.

I agree, mostly.  I've asked what initially I thought were good 
questions, then had to think some more before I guessed the answer.
Witness how many of subject of my posts begin with "OOPS" :(
The key word there is "guessed".  I guess you don't think there
should be as much "guessing", which seems reasonable to me.  The
hard part is **how** to document clearly enough to minimize the
guessing.  That's hard and it's understandable that maybe the
docs could be improved.  I'm anticipating that the next response
will be "PR demonstrating such improvement welcome" ;)

> 
> Regards, Maarten
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> 



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot