From: Joel de G. <jo...@bo...> - 2005-10-06 15:30:42
|
Carl Barron wrote: > > On Oct 6, 2005, at 9:10 AM, Joel de Guzman wrote: > > grammar works , needs three phoenix actions except to get rid > of an infinite loop there is one string of chars per tag, between tags > <A>xxx <B>aaa</B>yyy</A> does not parse yet:) > adding <xxx/> tags appears to be no real problem. > > struct tag > { > std::string tag; > std::string data; > std::map<std::string,std::string> attribs, > std::list<boost::shared_ptr<tag> > children; > // + ctors > }; I think the proper data structure is: struct tag { std::string name; std::map<std::string, std::string> attributes; std::list<variant<tag, std::string> > children; }; or if you wish to use shared_ptr: struct tag { std::string name; std::map<std::string, std::string> attributes; std::list<shared_ptr<variant<tag, std::string> > > children; }; There can be more than one string per tag, interspersed with child tags. Example: <p> text1 <b>text2</b> text3 <i>text4</i> text5 </p> which will have the pseudo-structure: tag p { " text1 ", tag b { "text2" }, " text3 ", tag i { "text4" }, " text5 " } What am I missing? Cheers, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net |