Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-22 13:43:34


  Attaching closures

  Closures can be applied to rules, subrules and grammars. The closure
  has a special parser context that can be used with these non
  terminals. The closure's context is its means to hook into the rule,
  subrule or grammar. Given the example my_closure above, we can create
  a rule with a closure by declaring it as:

      rule<ScannerT, my_closure::context_t> r;

  where ScannerT is the actual type of the scanner that we wish to
  use. Similarly for subrules:

      subrule<ID, my_closure::context_t> sr;

  And if you wish to attach a grammar:

      struct my_grammar : grammar<my_grammar, my_closure::context_t>
      {
          /*...*/
      };

      my_grammar g;

It would be more consistent to say "And if you wish to attach the
closure to a grammar". Or do you actually mean something different?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk