$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2006-01-26 10:54:09
 
Elviin wrote:
> I'd like to use non-ast tree. I'm also using the tree_to_xml 
> function to generate xml code.
> Plus my own grammar. The problem is with the token_node_d 
> directive. I assumed that this directive  merge the parsed 
> code to an one node. At this time my parser works for me very 
> fine except the tree because there are missing value objects 
> in xml structure. So it seems that the whole tree is empty:/
> 
> I can reproduce that state with the example file parse_tree_calc1.cpp:
IIRC, the token_node_d or leaf_node_d cannot be used with a rule inside the
[]. But I'm not sure anymore about the rationale behind this. I'm CC'ing to
Dan Nuffer, he's the original author of this code, perhaps he has some
additional information.
Regards Hartmut
> 
> The correct output from the tree_to_xml function is following 
> when parsing "1":
> 
> <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE 
> parsetree SYSTEM "parsetree.dtd">
> <!-- 1 -->
> <parsetree version="1.0">
>     <parsenode rule="expression">
>         <parsenode rule="term">
>             <parsenode rule="factor">
>                 <parsenode rule="integer">
>                     <parsenode rule="integer">
>                         <value>1</value> <<<<======== it's OK here
>                     </parsenode>
>                 </parsenode>
>             </parsenode>
>         </parsenode>
>     </parsenode>
> </parsetree>
> parsing succeeded
> 
> ... and the corresponfing code/rules:
> 
>     integer     =   lexeme_d[ token_node_d[ (!ch_p('-') >> 
> +digit_p) ] ];
>     factor      =   integer
>                 |   '(' >> expression >> ')'
>                 |   ('-' >> factor);
>     term        =   factor >>
>                     *(  ('*' >> factor)
>                       | ('/' >> factor)
>                     );
>     expression  =   term >>
>                     *(  ('+' >> term)
>                       | ('-' >> term)
>                     );
> 
> 
> 
> 
> But if I move the token_node_d directive to another position, 
> so that is similar to the problem with my grammar:
> 
>     integer     =   lexeme_d[  (!ch_p('-') >> +digit_p) ];
>     factor      =   token_node_d[integer]
>                 |   '(' >> expression >> ')'
>                 |   ('-' >> factor);
>     term        =   factor >>
>                     *(  ('*' >> factor)
>                       | ('/' >> factor)
>                     );
>     expression  =   term >>
>                     *(  ('+' >> term)
>                       | ('-' >> term)
>                     );
> 
> 
> ... then the XML structure looks like this. The "value" 
> object are missing:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE 
> parsetree SYSTEM "parsetree.dtd">
> <!-- 1 -->
> <parsetree version="1.0">
>     <parsenode rule="expression">
>         <parsenode rule="term">
>             <parsenode rule="factor">
>                 <parsenode rule="integer">
>                                                     
> <<<<======== it is not OK here
>                 </parsenode>
>             </parsenode>
>         </parsenode>
>     </parsenode>
> </parsetree>
> parsing succeeded
> 
> 
> Can anyone explain me why it is not possible to use  the 
> directive token_node_d like this token_node_d[integer]? I 
> just want to group all the parsed text (integer) in one node. 
> May I have to change the policy or to create proper typedefs.
> 
> The problem is with hierarchy, that I want to group the 
> parsed text only in the higher levels of parsing process.
> 
> Thank you.
> 
> Elviin
> 
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://listarchives.boost.org/mailman/listinfo.cgi/boost-users