Re: X3 employee example with semantic actions

Maarten Verhage <[email protected]> Sat, 2 Jun 2018 16:46:37 +0000
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <AM5P192MB01312F895A0C38D4C49F2ABBBA610@AM5P192MB0131.EURP192.PROD.OUTLOOK.COM>
[snip]
> >
> > I'm also experimenting with the _where iterator range attribute of
> Context.
> > But I've a problem with this. Maybe I did something wrong but what I
> get is
> > an iterator range from the end of the match to the end of input stream
> > (std::string storage). The program output is my attachment result.txt. 
> > Is
> > this intended behavior, a bug or did I something wrong?
>
> It looks like the intended behaviour to me.  The iterator
> begin and end are to the **remaining** input.  The attribute
> for the just parsed input is accessed with _attr as shown in
> the attached modification to the code you posted.
>
> The windows #include has been deleted, and printf of the
> iterators has been removed since it failed to compile.
> Also, the current attribute has been printed out.
>
> HTH.
>
> -regards,
> Larry

Thanks Larry. I didn't expect that the Context _where member function works 
this way intentionally. I also think the documentation could be better is 
this regard. That it works like you said by giving two iterators to the 
**remaining** input. I hope Mr. Joel de Guzman himself would be willing to 
comment on this.

Instead I'm aiming to have two iterators to the input where Spirit has 
determined to rule to match. Would there be a customization on the client 
side be possible to get that? I was playing a bit around with printing the 
address of _attr but that seems to be a copy rather than a pointer/iterator 
into the input.

For my application where I would like to 1) Parse a file 2) Modify a few 
things and 3) write it back. I still think it is valueable to have the 
option to get the two iterators of a rule match. So I can just std::copy a 
portion (described by a rule) of the file representation in memory, rather 
than having Spirit to interpret it. That will be higher performance does it?

Best regards,
Maarten Verhage

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