Ticket #2511: mini_xml.patch
File mini_xml.patch, 1.7 KB (added by , 14 years ago) |
---|
-
libs/spirit/doc/qi_and_karma/mini_xml.qbk
16 16 departments, corporations. Then we'll have an AST representation of it all. 17 17 18 18 In this example (actually two examples), we'll now explore parsers how to create 19 ASTs. We will parse a minimalistic XML 19 ASTs. We will parse a minimalistic XML-like language and compile the results 20 20 into our data structures in the form of a tree. 21 21 22 22 Along the way, we'll see new features: … … 61 61 62 62 node = (xml | text) [_val = _1]; 63 63 64 We'll see whata `mini_xml_node` structure later. Looking at the rule65 definition, we see some alternation goi ing on here. An xml `node` is64 We'll see a `mini_xml_node` structure later. Looking at the rule 65 definition, we see some alternation going on here. An xml `node` is 66 66 either an `xml` OR `text`. Hmmm... hold on to that thought... 67 67 68 68 rule<Iterator, std::string(), space_type> start_tag; … … 84 84 85 85 !p 86 86 87 It will try the parser, `p`. If it is successful, fail ,otherwise, pass. In87 It will try the parser, `p`. If it is successful, fail; otherwise, pass. In 88 88 other words, it negates the result of `p`. Like the `eps`, it does not consume 89 89 any input though. It will always rewind the iterator position to where it 90 90 was upon entry. So, the expression: … … 232 232 local variable. 233 233 234 234 There are no actions involved in stuffing data into our `xml` attribute. It's 235 all taken care d of thatnks to the auto-rule.235 all taken care of thanks to the auto-rule. 236 236 237 237 [endsect]