|
Boost Users : |
Subject: Re: [Boost-users] Spirit Newbie (balanced parentheses)
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-04-17 20:45:23
On Sat, Apr 17, 2010 at 12:51 PM, EricB <eric.britz_at_[hidden]> wrote:
> I have 2 additional questions :
> 1)
> The for each statement produces the following AST. The nodes marked with
> XXX at end of lines are produced due to the "*boost::spirit::space_p "
> part of the for-each rule. Is there a way (a directive or something else
> in the grammar) to skip this content so that the marked nodes (XXX)
> would not appeared in the AST ?
> (i have tried discar_node_d, and other directives but nothing works)
> Â Â Â Â <parsenode rule="for_eachID">
> Â Â Â Â Â Â <parsenode> Â Â Â Â Â Â Â Â XXX
> Â Â Â Â Â Â Â Â <value> </value> Â Â Â Â XXX
> Â Â Â Â Â Â </parsenode> Â Â Â Â Â Â Â Â XXX
> Â Â Â Â Â Â <parsenode rule="queryID">
> Â Â Â Â Â Â Â Â <parsenode>
> Â Â Â Â Â Â Â Â Â Â ...
> Â Â Â Â Â Â Â Â </parsenode>
> Â Â Â Â Â Â </parsenode>
> Â Â Â Â Â Â <parsenode> Â Â Â Â Â Â Â Â XXX
> Â Â Â Â Â Â Â Â <value> </value> Â Â Â Â XXX
> Â Â Â Â Â Â </parsenode> Â Â Â Â Â Â Â Â XXX
> Â Â Â Â Â Â <parsenode> Â Â Â Â Â Â Â Â XXX
> Â Â Â Â Â Â Â Â <value>\n</value> Â Â Â XXX
> Â Â Â Â Â Â </parsenode> Â Â Â Â Â Â Â Â XXX
> Â Â Â Â Â Â <parsenode> Â Â Â Â Â Â Â Â XXX
> Â Â Â Â Â Â Â Â <value> </value> Â Â Â Â XXX
> Â Â Â Â Â Â </parsenode> Â Â Â Â Â Â Â Â XXX
> Â Â Â Â Â Â <parsenode rule="subscriptID">
> Â Â Â Â Â Â Â Â <parsenode>
> Â Â Â Â Â Â Â Â Â Â ...
> Â Â Â Â Â Â Â Â </parsenode>
> Â Â Â Â Â Â </parsenode>
> Â Â Â Â </parsenode>
It is extremely simple in a more recent Spirit version, the directive
skip(space)[] in my code above handled that fine. You *really* need
to update, the version you are using is far more difficult to use,
slower, and far less capable.
On Sat, Apr 17, 2010 at 12:51 PM, EricB <eric.britz_at_[hidden]> wrote:
> 2)The query rule handles inner balanced parentheses but it produces the
> following AST: =>input is b/c()/e
>
> I Would like the AST produced from the inner () to be flatten. I would
> like the node marked with XXX not to be generated. Is there a directive
> for this ?
> <parsenode>
> Â Â <value>b</value>
> </parsenode>
> <parsenode>
> Â Â <value>/</value>
> </parsenode>
> <parsenode>
> Â Â <value>c</value>
> </parsenode>
> <parsenode> Â Â Â Â Â Â XXX
> Â Â <parsenode>
> Â Â Â Â <value>(</value>
> Â Â </parsenode>
> Â Â <parsenode>
> Â Â Â Â <value>)</value>
> Â Â </parsenode>
> </parsenode> Â Â Â Â Â Â XXX
> <parsenode>
> Â Â <value>/</value>
> </parsenode>
> <parsenode>
> Â Â <value>e</value>
> </parsenode>
That is what the raw[] directives in my above code is for, you really
need to use the newer functionality rather then the old syntax that
you are currently using.
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