Re: Usage of auto keyword in X3 tutorials
Baptiste Wicht <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Stephan,
On Fri, Nov 11, 2016 at 04:04:53PM +0100, Stephan Menzel wrote:
> Indeed. This would not be very nice. And in fact, I like generic lambdas a
> lot. They are the prime reason I wanted to check out X3 since according to
> my knowledge Spirit2 doesn't allow native lambdas in semantic actions and
> forces me to use phoenix, which has a tendency to cause problems and longer
> compile times.
I think you're right about Spirit2 not allowing native lambdas in
semantic actions.
> Moreover, auto usage in Spirit is not only related to x3. In Qi, you
> > could already use auto rules in order to improve performance.
> >
>
> Are you sure about that? I use spirit almost exclusively by defining
> grammars. Both qi and karma, mostly symmetrical. So my general pattern is
> to have a rather large set of grammars like this:
>
>
> template <typename Iterator>
> struct username_parser : qi::grammar<Iterator, std::string()> {
> username_parser() : username_parser::base_type(m_start, "username") {
>
> m_start %= ... define my stuff ...
> }
>
> qi::rule<Iterator, std::string()> m_start;
> };
>
> which I then combine to the actual larger grammars that I really need
> (identical pattern).
>
> All those are kept hidden in a header that is only included by a compile
> unit which then exposes plain functions to do the parsing in order to keep
> compile times in check by not letting anything spirit out into the rest of
> the code.
>
> Which means I use the rule definitions a lot.
>
> Are you saying that above example would be better by using auto instead of
> the rule definition? Or are you referring to the "auto" parser which
> chooses a generic parser by attribute type? Because I am using this,
> although rarely.
I was actually to this kind of rule:
http://boost-spirit.com/home/articles/qi-example/zero-to-60-mph-in-2-seconds/
They are generally more efficient than qi::rule, but you cannot use them
everywhere though. For instance, you cannot have recursive auto rules,
but there are good candidates for small sub parts of the grammar.
Baptiste
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general
signature.asc
(application/pgp-signature, 801 B)
-----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJYJx88AAoJEMVWa2x/iEUybZoP/i2ttg/M4I6ork3MTuJTbcER er/DYqmNzRZ3q+3LuAkJ0rFd+xr64QZBSf2YruDqrC3Kbu6xk7qlBPPk0a6JU1uH rYfS2n0LNqXnofOv/5q9yanYGtKZVSZyClh4DM4/YQwzxFpSZOhDUYPdQXcWID5D nfSO5si4HM3CMIURL95+izq9oeI+O3MO8h54690k3WQqVOYHQPRsZdZQ5XSzAGdZ SZVmRd4zFj1q//vBxUbEvdkUhhMftYPpFPxYPuLoDll+PPoVvf7R09i3k7lQFRiH k7jwoRqNNZJi0v9Gks3q55jWmcQQavpSGjvGRU2qUigOHoaPMYwYZcpEFEyxt+OE x8lPxs2KIvCrz3e26h+G2mF+82CBUa5LjTnPnpdxDcUnr1TuBT6y+FOloLD6CqkX T3vktRZLa+rrxPCFdwEgAB0FakU1+YpSgdzWyEHl3m9X5L9Ac/h25YGR+Ttqh41H vllnxOI/7OGNm3Yj56KLfo15gAtKQ2am9MzL7tkXg94QVGbZ7f4DuIa5B6zv7f1F 5REmVK4DNkCzCgJBSX5mcL+65qQyCMmR1rBr9BlLgP+gI+J6E/9APIIl2SxUqrkJ fMT56IwDXs2MbeWxr+/rTio8EbrUkvDabi5qSg0IZXke70yZIAWFUY2U8/EWQomK q0P+vPlYjN9yypjVTC1U =jtMC -----END PGP SIGNATURE-----