how to get all the attributes out of a parser

Juan Dent <[email protected]> Wed, 21 Oct 2020 17:47:34 +0000
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <PH0PR10MB45828A4A4128F172D824071F9B1C0@PH0PR10MB4582.namprd10.prod.outlook.com>
--===============2597531158711794418==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_PH0PR10MB45828A4A4128F172D824071F9B1C0PH0PR10MB4582namp_"

--_000_PH0PR10MB45828A4A4128F172D824071F9B1C0PH0PR10MB4582namp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I am trying to use a boost::tuple to retrieve the attributes of a parser. S=
ee this snippet of code:



                      using qi::double_;
                      using qi::int_;
                      using qi::phrase_parse;
                      using qi::_1;
                      using ascii::space;

                      std::string s =3D "50 43.3 77.44";
                      first =3D s.begin();
                      last =3D s.end();
boost::tuple<boost::optional<double>, boost::optional<int>> to;

bool r =3D phrase_parse(first, last,
(
double_ || int_
),
space, to);                  // r =3D=3D true

auto a =3D to.get<0>(); // this works catches the 50 from the input
auto aa =3D *a;
auto b =3D to.get<1>();      // this does not work even though 43 is parsed=
 correctly
auto bb =3D *b;             // EXCEPTION


Please can you try this in your system? Any ideas where am I going wrong?

Juan Dent

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=3D550986> for Window=
s 10


--_000_PH0PR10MB45828A4A4128F172D824071F9B1C0PH0PR10MB4582namp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:sc=
hemas-microsoft-com:office:word" xmlns:m=3D"http://schemas.microsoft.com/of=
fice/2004/12/omml" xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style>
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">I am trying to use a boost::tuple to retrieve the at=
tributes of a parser. See this snippet of code:</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
using qi::double_;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
using qi::int_;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
using qi::phrase_parse;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
using qi::_1;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
using ascii::space;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
std::string s =3D &quot;50 43.3 77.44&quot;;&nbsp;&nbsp; </p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
first =3D s.begin();</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
last =3D s.end();</p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">boost::t=
uple&lt;boost::optional&lt;double&gt;, boost::optional&lt;int&gt;&gt; to;</=
p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in"><o:p>&nb=
sp;</o:p></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">bool r =
=3D phrase_parse(first, last,</p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">(</p>
<p class=3D"MsoNormal" style=3D"margin-left:1.0in;text-indent:.5in">double_=
 || int_</p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">),</p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">space, t=
o);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // r =3D=3D true</p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in"><o:p>&nb=
sp;</o:p></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">auto a =
=3D to.get&lt;0&gt;(); // this works catches the 50 from the input</p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">auto aa =
=3D *a;</p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">auto b =
=3D to.get&lt;1&gt;();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // this does not work =
even though 43 is parsed correctly</p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in">auto bb =
=3D *b;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; // EXCEPTION</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Please can you try this in your system? Any ideas wh=
ere am I going wrong?</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Juan Dent</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Sent from <a href=3D"https://go.microsoft.com/fwlink=
/?LinkId=3D550986">
Mail</a> for Windows 10</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_PH0PR10MB45828A4A4128F172D824071F9B1C0PH0PR10MB4582namp_--


--===============2597531158711794418==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============2597531158711794418==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general

--===============2597531158711794418==--