Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::spirit] Help! Unexpected Leading spaces got injected into a parse tree node
From: HT4N - (ht4n_at_[hidden])
Date: 2009-10-18 15:19:04


It is confirmed that seems to work as expected, by swapping the lexeme_d with the node directive and it does really make sense.

 

Appreciate it Steven for the help.

 
> Date: Sun, 18 Oct 2009 11:53:11 -0700
> From: watanabesj_at_[hidden]
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] [boost::spirit] Help! Unexpected Leading spaces got injected into a parse tree node
>
> AMDG
>
> HT4N - wrote:
> > I have a question regarding unexpected leading spaces got injected into a parse tree node.
> >
> > Here is my grammar:
> >
> > Text = leaf_node_d[+digit_p] >> root_node_d[ch_p('=')] >> leaf_node_d[+digit_p];
> >
> > If I parse "5=5", as expected no extra leading spaces added to the resulting tree nodes.
> >
> > If I parse "5= 5" (read:5 followed by = followed by 4 spaces and followed by 5), given my grammar definition of leaf_node_d[+digit_p], I am expecting the parse tree node value should not contain any leading spaces.
> > Yet, I see that the extra 4 spaces is stored in the corresponding parse tree node as shown below.
> >
> > <snip>
> > ==> <value> 5</value>
> >
> > I am wondering if this is a by design or unexpected behavior. If it is a by design behavior, is there a way to trim leading/trailing spaces.
> >
>
> Perhaps you should use lexeme_d[leaf_node_d[+digit_p]]?
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
                                               
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/
--_fc085d35-6de4-45eb-99ac-30da2b7d3a4f_
Content-Type: text/html; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
It is confirmed that seems to work as expected, by swapping the lexeme_d with the node directive and it does really make sense.<BR>
&nbsp;<BR>
Appreciate it Steven for the help.<BR>
&nbsp;<BR>&gt; Date: Sun, 18 Oct 2009 11:53:11 -0700<BR>&gt; From: watanabesj_at_[hidden]<BR>&gt; To: boost-users_at_[hidden]<BR>&gt; Subject: Re: [Boost-users] [boost::spirit] Help! Unexpected Leading spaces got injected into a parse tree node<BR>&gt; <BR>&gt; AMDG<BR>&gt; <BR>&gt; HT4N - wrote:<BR>&gt; &gt; I have a question regarding unexpected leading spaces got injected into a parse tree node.<BR>&gt; &gt; <BR>&gt; &gt; Here is my grammar:<BR>&gt; &gt; <BR>&gt; &gt; Text = leaf_node_d[+digit_p] &gt;&gt; root_node_d[ch_p('=')] &gt;&gt; leaf_node_d[+digit_p];<BR>&gt; &gt; <BR>&gt; &gt; If I parse "5=5", as expected no extra leading spaces added to the resulting tree nodes.<BR>&gt; &gt; <BR>&gt; &gt; If I parse "5= 5" (read:5 followed by = followed by 4 spaces and followed by 5), given my grammar definition of leaf_node_d[+digit_p], I am expecting the parse tree node value should not contain any leading spaces.<BR>&gt; &gt; Yet, I see that the extra 4 spaces is stored in the corresponding parse tree node as shown below. <BR>&gt; &gt; <BR>&gt; &gt; &lt;snip&gt;<BR>&gt; &gt; ==&gt; &lt;value&gt; 5&lt;/value&gt;<BR>&gt; &gt;<BR>&gt; &gt; I am wondering if this is a by design or unexpected behavior. If it is a by design behavior, is there a way to trim leading/trailing spaces.<BR>&gt; &gt; <BR>&gt; <BR>&gt; Perhaps you should use lexeme_d[leaf_node_d[+digit_p]]?<BR>&gt; <BR>&gt; In Christ,<BR>&gt; Steven Watanabe<BR>&gt; <BR>&gt; _______________________________________________<BR>&gt; Boost-users mailing list<BR>&gt; Boost-users_at_[hidden]<BR>&gt; http://lists.boost.org/mailman/listinfo.cgi/boost-users> <br /><hr />Hotmail: Trusted email with Microsoft’s powerful SPAM protection. <a href='http://clk.atdmt.com/GBL/go/177141664/direct/01/' target='_new'>Sign up now.</a></body>
</html>
--_fc085d35-6de4-45eb-99ac-30da2b7d3a4f_--


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net