Ticket #2511: mini_xml.patch

File mini_xml.patch, 1.7 KB (added by Charles Brockman <cmbrockman@…>, 14 years ago)
  • libs/spirit/doc/qi_and_karma/mini_xml.qbk

     
    1616departments, corporations. Then we'll have an AST representation of it all.
    1717
    1818In this example (actually two examples), we'll now explore parsers how to create
    19 ASTs. We will parse a minimalistic XML like language and compile the results
     19ASTs. We will parse a minimalistic XML-like language and compile the results
    2020into our data structures in the form of a tree.
    2121
    2222Along the way, we'll see new features:
     
    6161
    6262    node = (xml | text)                 [_val = _1];
    6363
    64 We'll see what a `mini_xml_node` structure later. Looking at the rule
    65 definition, we see some alternation goiing on here. An xml `node` is
     64We'll see a `mini_xml_node` structure later. Looking at the rule
     65definition, we see some alternation going on here. An xml `node` is
    6666either an `xml` OR `text`. Hmmm... hold on to that thought...
    6767
    6868    rule<Iterator, std::string(), space_type> start_tag;
     
    8484
    8585    !p
    8686
    87 It will try the parser, `p`. If it is successful, fail, otherwise, pass. In
     87It will try the parser, `p`. If it is successful, fail; otherwise, pass. In
    8888other words, it negates the result of `p`. Like the `eps`, it does not consume
    8989any input though. It will always rewind the iterator position to where it
    9090was upon entry. So, the expression:
     
    232232  local variable.
    233233
    234234There are no actions involved in stuffing data into our `xml` attribute. It's
    235 all taken cared of thatnks to the auto-rule.
     235all taken care of thanks to the auto-rule.
    236236
    237237[endsect]