[Spirit] Semantic Actions and function objects

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Spirit] Semantic Actions and function objects

Martin Braun
Hi there,

I'm slowly starting to get the hang of the Lexer capabilities of
Boost.Spirit. Before I start asking stuff, I'd like to compliment on the
massive amount of documentation -- a great place to start.

Something I'm still struggling with is attaching semantic actions to
tokens, and I was wondering if someone can give a legs-up here.

I butchered the 'Quickstart 3' tutorial to add a method into the grammar:

http://pastebin.com/udJ0abDg

Now, in the new method idany_sem_action() I'd like more access to the
lexer state / token as explained here:
http://www.boost.org/doc/libs/1_58_0/libs/spirit/doc/html/spirit/lex/abstracts/lexer_semantic_actions.html

...to be honest, I'm not sure how to proceed. A couple of things are
throwing me off guard:

- According to the manual, we need an actor_lexer<> to do this. Aren't
the "++ref(c), ++ref(l)" primitives considered semantic actions? Because
this isn't an actor_lexer<> AFAICT
- Wouldn't my iterator type for the function object simply be 'Iterator'
(the template argument I'm using)? This gives me tons of compiler warnings.

I realize I might be lacking some fundamentals here -- but I'm not sure
what they are. Any kind of pointer is appreciated.

Note that I'm using boost::bind() because I use that all the time --
there might be other ways to go ahead, and I'd be interested to hear
them (I read the comments on Phoenix and Boost.Lambda). In the long run,
I'll need access to other objects to set up stuff, though, so I believe
this is the right way to go.

Cheers,
Martin

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general