Boost logo

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