How to use functions in the semantic actions?

Juan Dent <[email protected]> Mon, 12 Oct 2020 23:50:54 +0000
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <BYAPR14MB3077DBC7A23C164265248CA89B070@BYAPR14MB3077.namprd14.prod.outlook.com>
--===============1338308850301280528==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_BYAPR14MB3077DBC7A23C164265248CA89B070BYAPR14MB3077namp_"

--_000_BYAPR14MB3077DBC7A23C164265248CA89B070BYAPR14MB3077namp_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

amount =3D uint3_p[_val =3D _1]
            >> *(','
                >> uint3_3_p)[_val *=3D 1000][_val +=3D _1]
            >> +('.'
                >> uint1_7_p)[_val +=3D _1/10000.0][_val =3D produce_decima=
l_value(_val)]
                ;
}
           template<typename T>
    constexpr T produce_decimal_value(T local)
    {
        if (local =3D=3D 0)     // error C2451: conditional expression of t=
ype 'const boost::phoenix::actor<Expr>' is illegal
        {}
                      // need to manipulate the value of _val which I captu=
re here using templates
                      //
        return local;
    }

How can I manipulate the value of   _val in a member function of the gramma=
r (i.e. produce_decimal_value)?
I need to check when local reaches 0 in order to calculate the digits after=
 the decimal point but it won=92t allow me from method of grammar class=85

Please some direction here=85
It=92s funny, I can manipulate the numeric vales or _val and _1 inside the =
constructor of the grammar but not from a user defined method of same gramm=
ar. When I try to use _val  as a number it throws errors=85

Regards,
Juan

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


--_000_BYAPR14MB3077DBC7A23C164265248CA89B070BYAPR14MB3077namp_
Content-Type: text/html; charset="Windows-1252"
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=3DWindows-1=
252">
<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">amount =3D uint3_p[_val =3D _1]</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; &gt;&gt; *(','</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&gt; uint3_3_p)[_val *=3D 1000][=
_val +=3D _1]</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; &gt;&gt; +('.'</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&gt; uint1_7_p)[_val +=3D _1/100=
00.0][_val =3D produce_decimal_value(_val)]</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;</p>
<p class=3D"MsoNormal">}</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; template&lt;typename T&gt;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp; constexpr T produce_decimal_value=
(T local)</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp; {</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (local=
 =3D=3D 0)&nbsp;&nbsp;&nbsp;&nbsp; // error C2451: conditional expression o=
f type 'const boost::phoenix::actor&lt;Expr&gt;' is illegal</p>
<p class=3D"MsoNormal">&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; =
// need to manipulate the value of _val which I capture here using template=
s</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;retu=
rn local;</p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp; }</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">How can I manipulate the value of&nbsp;&nbsp; _<i>va=
l in a member function of the grammar (i.e. produce</i>_decimal_value)?</p>
<p class=3D"MsoNormal">I need to check when local reaches 0 in order to cal=
culate the digits after the decimal point but it won=92t allow me from meth=
od of grammar class=85</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Please some direction here=85 <br>
It=92s funny, I can manipulate the numeric vales or _val and _1 inside the =
constructor of the grammar but not from a user defined method of same gramm=
ar. When I try to use _val &nbsp;as a number it throws errors=85</p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Regards,</p>
<p class=3D"MsoNormal">Juan</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_BYAPR14MB3077DBC7A23C164265248CA89B070BYAPR14MB3077namp_--


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


--===============1338308850301280528==
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

--===============1338308850301280528==--