Re: Extracting parsed value from a local variable

Michele De Stefano <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <CAJ7vBf3ehPT5YC4+cDXs4d5===hfMhK+oAiiet7BGxDHeh1zNA@mail.gmail.com>
Thanks ... I've found the solution myself ...

I actually need to use phoenix lazy actions ...
Here I wanted to create a rule that synthetized directly an
std::complex<double> ... so I was storing the real part into qi::_a and the
imaginary part into qi::_b ... and then I would have liked to write
something like

qi::_val = std::complex(qi::_a,qi::_b)

and the compiler complained ...

Actuall, using

qi::_val = boost::phoenix::construct< std::complex<double> >(qi::_a,qi::_b)

fixed the issue.

Best regards to all,
Michele

2016-10-23 19:23 GMT+02:00 Jens Kallup <[email protected]>:

> Hello Michele,
>
> try to use qi::_1 ... qi::_9  where _1 till _9 are placeholders
> for your input like double.
> The placeholder _1 is the first match, _2 the second, and so on...
>
> Jens
>
>
> On 10/23/2016 06:59 PM, Michele De Stefano wrote:
> > Dear all,
> >
> > here is my issue. I am creating a rule that happens to parse (amongst
> > several things) a double value into the qi::_a local variable. Now,
> > while staying into the same semantic action, I need to use that parsed
> > double value into another C++ instruction that requires a double value
> > as input.
> >
> > Think to this instruction as a generic
> >
> > ouput_type f(double x)
> >
> > The issue is that when I call (within the semantic action)
> >
> > f(qi::_a)
> >
> > the compiler complains that it cannot convert qi::_a into a double.
> >
> > Is there a way to extract the double value from qi::_a (or anyway from
> > any placeholder)?
> >
> > Thanks in advance.
> >
> > Best regards,
> > Michele
> >
> > --
> > Michele De Stefano
> > Linked In <http://it.linkedin.com/in/micheledestefano>
> > mds-utils: a general purpose Open Source library
> > <http://sourceforge.net/projects/mds-utils/>
> > Personal Web Site <https://sites.google.com/site/micdestefano/>
> >
> >
> > ------------------------------------------------------------
> ------------------
> > 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
>
>
> ------------------------------------------------------------
> ------------------
> 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
>



-- 
Michele De Stefano
Linked In <http://it.linkedin.com/in/micheledestefano>
mds-utils: a general purpose Open Source library
<http://sourceforge.net/projects/mds-utils/>
Personal Web Site <https://sites.google.com/site/micdestefano/>

------------------------------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.