| 1 | /*============================================================================= |
|---|
| 2 | Copyright (c) 2004 Joao Abecasis |
|---|
| 3 | http://spirit.sourceforge.net/ |
|---|
| 4 | |
|---|
| 5 | Use, modification and distribution is subject to the Boost Software |
|---|
| 6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 7 | http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 8 | =============================================================================*/ |
|---|
| 9 | |
|---|
| 10 | #include <boost/spirit/core.hpp> |
|---|
| 11 | |
|---|
| 12 | #include <boost/spirit/attribute/closure.hpp> |
|---|
| 13 | |
|---|
| 14 | #include <boost/spirit/tree/ast.hpp> |
|---|
| 15 | #include <boost/spirit/tree/parse_tree.hpp> |
|---|
| 16 | |
|---|
| 17 | using namespace boost::spirit; |
|---|
| 18 | |
|---|
| 19 | struct test_closure : public closure<test_closure, int> |
|---|
| 20 | { |
|---|
| 21 | member1 value; |
|---|
| 22 | }; |
|---|
| 23 | |
|---|
| 24 | struct test_grammar : public grammar<test_grammar> |
|---|
| 25 | { |
|---|
| 26 | template <typename ScannerT> |
|---|
| 27 | struct definition |
|---|
| 28 | { |
|---|
| 29 | definition(const test_grammar&) |
|---|
| 30 | { |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | rule<ScannerT, test_closure::context_t> const & start() const |
|---|
| 34 | { |
|---|
| 35 | return first; |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | rule<ScannerT, test_closure::context_t> first; |
|---|
| 39 | }; |
|---|
| 40 | }; |
|---|
| 41 | |
|---|
| 42 | int main() |
|---|
| 43 | { |
|---|
| 44 | parse("abcd", test_grammar()); |
|---|
| 45 | pt_parse("abcd", test_grammar()); |
|---|
| 46 | ast_parse("abcd", test_grammar()); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | |
|---|