Re: X3 employee example with semantic actions
Larry Evans <[email protected]> Sun, 3 Jun 2018 12:28:28 -0500
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
On 06/03/2018 09:54 AM, Maarten Verhage wrote: > Hi Larry, > >>> >>> The documentation page: "Annotations - Decorating the ASTs" makes use of >>> the >>> "position_tagged" base class for an ast. It claims to provide the >>> positions >>> into the input (with iterators) that corresponds to a given element in >>> the >>> AST. >> >> Could you provide a link to that page. I tried scanning the main topics >> here: >> >> https://www.boost.org/doc/libs/1_67_0/libs/spirit/doc/html/index.html >> >> and it's not obvious to me where this "Annotations - Decorating the ASTs" >> page might be. >> > > I didn't realize I was on some "developers" documentation area of the > boost.org website. I used google and that brought me here: > > https://www.boost.org/doc/libs/develop/libs/spirit/doc/x3/html/index.html > > I also tried the annotation.cpp file there but on my gcc 5.1.0 it did > compile fine but the printing after > "Here's the 2nd employee" is just empty. I think you will find that. I also > did a printf in the on_success function and that was called 10 times which > is correct I assume, so something else went wrong. > >>> >>> Maybe this does what I want. But I don't feel a need for an on_success >>> function. >>> >>> I'm going to write a fresh message asking about this position_tagged and >>> if >>> I can use it without that concept of annotation which I still fail to >>> understand what that means. >> >> Waiting for that. I'm unfamiliar with position_tagged and would >> appreciation some education ;) >> > > I'm glad you put ;) along with that because I do consider myself a novice in > Spirit. I posted it already with the title: > [Spirit-general] X3 iterators into the input for a matching rule Strange, I don't see it yet here: https://sourceforge.net/p/spirit/mailman/spirit-general/ Anyway, I tried a slight modification of the previous code where the ast::employee just contains begin/end iterators. The code is posted here: https://gist.github.com/cppljevans/0f4351f127c2e651d8094877a9510e5a It uses the semantic actions to simply store the input iterator into the non-terminal's attribute. I've no idea whether it's better than the position_iterator other than it's simpler to understand, it seems to me. > > 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