Re: X3 employee example with semantic actions

Larry Evans <[email protected]> Sat, 2 Jun 2018 07:13:56 -0500
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 06/01/2018 10:43 PM, Larry Evans wrote:
> On 06/01/2018 10:19 PM, Larry Evans wrote:
>> On 06/01/2018 05:54 PM, Larry Evans wrote:
>>> On 06/01/2018 05:09 PM, Larry Evans wrote:
>> [snip]
>>>> OOPS :(
>>>> I failed to notice the printout of the attribute after parse
>>>> did not reflect the input to the parse.
>>>>
>>>> I'm now trying to figure out why that's so.
>>>>
>>>> I guess that was your main concern.
>>>> [snip]
>>>
>>> Specifying the rule default attribute, force_attribute=true, changed 
>>> the output so that it reflected the input for me.  IOW:
>>>
>>>          x3::rule<employee_id, ast::employee, true> const
>>>         employee = "employee";
>>>
>>> See if that doesn't get you better results.
>>>
>>
>> Although making force_attribute=true gets correct result, I don't
>> understand why.  In addition, when the semantic actions are removed,
>> then it works when force_attribute=false.
>>
>> That seems very counter-intuitive.  Is it a bug?
> 
> OOPS.  No.  Searching mailing list turns up mentions of it.
> See post with headings:
> 
> From: Seth <[email protected]>
> Newsgroups: gmane.comp.parsers.spirit.general
> Subject: Re: How to force attribute propagation in x3 when
>   using semantic actions
> Date: Fri, 15 Dec 2017 15:53:09 +0100
> 
The following coilru run:

http://coliru.stacked-crooked.com/a/4fbf701040fd3498

illustrates why the force_attribute is needed.  It
explicitly propagates 3 parts of the employee, but
leaves the other, age, alone; hence, output for the
age does not reflect the input.

I guess spirit x3's assumption is that if you
have semantic actions, then you want to do the attribute
propagation and don't want spirit to do it for you.

Sounds reasonable to me.

-regards,
Larry



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general