Boost logo

Boost Users :

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


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.
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE parsetree SYSTEM "parsetree.dtd">
<!-- 5= 5 -->
<parsetree version="1.0">
    <parsenode>
        <parsenode>
            <value>5</value>
        </parsenode>
        <parsenode>
            <value is_root="1">=</value>
        </parsenode>
        <parsenode>
==> <value> 5</value>
        </parsenode>
    </parsenode>
</parsetree>

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.
 
Thanks!
 
 

Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. Sign up now.
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/171222986/direct/01/



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