Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63633 - in branches/release: . boost boost/algorithm/string boost/archive boost/bimap boost/detail boost/filesystem boost/functional/hash boost/fusion boost/gil boost/graph boost/integer boost/interprocess boost/intrusive boost/msm boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/karma/auxiliary boost/spirit/home/karma/binary boost/spirit/home/karma/char boost/spirit/home/karma/detail boost/spirit/home/karma/nonterminal boost/spirit/home/karma/numeric boost/spirit/home/karma/operator boost/spirit/home/karma/stream boost/spirit/home/karma/string boost/spirit/home/qi/auxiliary boost/spirit/home/qi/char boost/spirit/home/qi/detail boost/spirit/home/qi/nonterminal boost/spirit/home/support boost/spirit/repository/home/qi/nonterminal boost/system boost/thread boost/utility boost/uuid boost/variant boost/wave libs libs/array/test libs/bimap libs/filesystem libs/functional/hash libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/msm libs/numeric/ublas libs/numeric/ublas/doc libs/property_tree libs/python libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/doc/advanced libs/spirit/example libs/spirit/example/karma libs/spirit/example/qi libs/spirit/example/scheme libs/spirit/example/scheme/detail libs/spirit/example/scheme/example libs/spirit/example/scheme/example/generate_qiexpr libs/spirit/example/scheme/example/parse_qiexpr libs/spirit/example/scheme/example/scheme libs/spirit/example/scheme/example/sexpr libs/spirit/example/scheme/input libs/spirit/example/scheme/output libs/spirit/example/scheme/qi libs/spirit/example/scheme/scheme libs/spirit/example/scheme/scheme/detail libs/spirit/example/scheme/support libs/spirit/example/scheme/test libs/spirit/example/scheme/test/generate_qiexpr libs/spirit/example/scheme/test/parse_qiexpr libs/spirit/example/scheme/test/scheme libs/spirit/example/scheme/test/sexpr libs/spirit/example/scheme/test/utree libs/spirit/example/scheme/utree libs/spirit/example/scheme/utree/detail libs/spirit/phoenix libs/spirit/test libs/spirit/test/karma libs/spirit/test/qi libs/static_assert libs/system libs/thread libs/timer libs/utility libs/utility/swap/test libs/uuid libs/wave status tools tools/bcp tools/jam tools/regression tools/release tools/wave
From: hartmut.kaiser_at_[hidden]
Date: 2010-07-04 17:04:47


Author: hkaiser
Date: 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
New Revision: 63633
URL: http://svn.boost.org/trac/boost/changeset/63633

Log:
Spirit: merging from trunk upto rev. 61347
Added:
   branches/release/libs/spirit/example/scheme/example/
      - copied from r61312, /trunk/libs/spirit/example/scheme/example/
   branches/release/libs/spirit/example/scheme/example/Jamfile
      - copied, changed from r61312, /trunk/libs/spirit/example/scheme/example/Jamfile
   branches/release/libs/spirit/example/scheme/example/generate_qiexpr/
      - copied from r61312, /trunk/libs/spirit/example/scheme/example/generate_qiexpr/
   branches/release/libs/spirit/example/scheme/example/generate_qiexpr/generate_qi_test.cpp
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/generate_qiexpr/generate_qi_test.cpp
   branches/release/libs/spirit/example/scheme/example/generate_qiexpr/generate_qiexpr.cpp
      - copied, changed from r61312, /trunk/libs/spirit/example/scheme/example/generate_qiexpr/generate_qiexpr.cpp
   branches/release/libs/spirit/example/scheme/example/generate_qiexpr/input.txt
      - copied unchanged from r61347, /trunk/libs/spirit/example/scheme/example/generate_qiexpr/input.txt
   branches/release/libs/spirit/example/scheme/example/parse_qiexpr/
      - copied from r61312, /trunk/libs/spirit/example/scheme/example/parse_qiexpr/
   branches/release/libs/spirit/example/scheme/example/parse_qiexpr/generate_sexpr_to_ostream.cpp
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/parse_qiexpr/generate_sexpr_to_ostream.cpp
   branches/release/libs/spirit/example/scheme/example/parse_qiexpr/input.txt
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/parse_qiexpr/input.txt
   branches/release/libs/spirit/example/scheme/example/parse_qiexpr/parse_qi_test.cpp
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/parse_qiexpr/parse_qi_test.cpp
   branches/release/libs/spirit/example/scheme/example/parse_qiexpr/parse_qiexpr.cpp
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/parse_qiexpr/parse_qiexpr.cpp
   branches/release/libs/spirit/example/scheme/example/scheme/
      - copied from r61312, /trunk/libs/spirit/example/scheme/example/scheme/
   branches/release/libs/spirit/example/scheme/example/scheme/factorial.scm
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/scheme/factorial.scm
   branches/release/libs/spirit/example/scheme/example/scheme/factorial1.cpp
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/scheme/factorial1.cpp
   branches/release/libs/spirit/example/scheme/example/scheme/factorial2.cpp
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/scheme/factorial2.cpp
   branches/release/libs/spirit/example/scheme/example/sexpr/
      - copied from r61312, /trunk/libs/spirit/example/scheme/example/sexpr/
   branches/release/libs/spirit/example/scheme/example/sexpr/out.txt
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/sexpr/out.txt
   branches/release/libs/spirit/example/scheme/example/sexpr/sexpr_error_test.cpp
      - copied unchanged from r61340, /trunk/libs/spirit/example/scheme/example/sexpr/sexpr_error_test.cpp
   branches/release/libs/spirit/example/scheme/example/sexpr/sexpr_input_test.cpp
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/sexpr/sexpr_input_test.cpp
   branches/release/libs/spirit/example/scheme/example/sexpr/sexpr_output_test.cpp
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/sexpr/sexpr_output_test.cpp
   branches/release/libs/spirit/example/scheme/example/sexpr/sexpr_test.txt
      - copied unchanged from r61312, /trunk/libs/spirit/example/scheme/example/sexpr/sexpr_test.txt
   branches/release/libs/spirit/example/scheme/input/error_handler.hpp
      - copied, changed from r61331, /trunk/libs/spirit/example/scheme/input/error_handler.hpp
   branches/release/libs/spirit/example/scheme/output/utree_traits.hpp
      - copied unchanged from r61347, /trunk/libs/spirit/example/scheme/output/utree_traits.hpp
   branches/release/libs/spirit/example/scheme/qi/component_names.hpp
      - copied, changed from r61303, /trunk/libs/spirit/example/scheme/qi/component_names.hpp
   branches/release/libs/spirit/example/scheme/qi/generate_qiexpr.hpp
      - copied unchanged from r61303, /trunk/libs/spirit/example/scheme/qi/generate_qiexpr.hpp
   branches/release/libs/spirit/example/scheme/qi/generate_qiexpr_impl.hpp
      - copied unchanged from r61303, /trunk/libs/spirit/example/scheme/qi/generate_qiexpr_impl.hpp
   branches/release/libs/spirit/example/scheme/qi/qiexpr_generator.hpp
      - copied, changed from r61303, /trunk/libs/spirit/example/scheme/qi/qiexpr_generator.hpp
   branches/release/libs/spirit/example/scheme/scheme/
      - copied from r61299, /trunk/libs/spirit/example/scheme/scheme/
   branches/release/libs/spirit/example/scheme/scheme/compiler.hpp
      - copied, changed from r61299, /trunk/libs/spirit/example/scheme/scheme/compiler.hpp
   branches/release/libs/spirit/example/scheme/scheme/detail/
      - copied from r61299, /trunk/libs/spirit/example/scheme/scheme/detail/
   branches/release/libs/spirit/example/scheme/scheme/detail/composite_call.hpp
      - copied unchanged from r61299, /trunk/libs/spirit/example/scheme/scheme/detail/composite_call.hpp
   branches/release/libs/spirit/example/scheme/scheme/detail/function_call.hpp
      - copied unchanged from r61299, /trunk/libs/spirit/example/scheme/scheme/detail/function_call.hpp
   branches/release/libs/spirit/example/scheme/scheme/interpreter.hpp
      - copied unchanged from r61299, /trunk/libs/spirit/example/scheme/scheme/interpreter.hpp
   branches/release/libs/spirit/example/scheme/scheme/intrinsics.hpp
      - copied unchanged from r61299, /trunk/libs/spirit/example/scheme/scheme/intrinsics.hpp
   branches/release/libs/spirit/example/scheme/support/
      - copied from r61331, /trunk/libs/spirit/example/scheme/support/
   branches/release/libs/spirit/example/scheme/support/line_pos_iterator.hpp
      - copied, changed from r61331, /trunk/libs/spirit/example/scheme/support/line_pos_iterator.hpp
   branches/release/libs/spirit/example/scheme/test/Jamfile
      - copied, changed from r61292, /trunk/libs/spirit/example/scheme/test/Jamfile
   branches/release/libs/spirit/example/scheme/test/generate_qiexpr/
      - copied from r61303, /trunk/libs/spirit/example/scheme/test/generate_qiexpr/
   branches/release/libs/spirit/example/scheme/test/generate_qiexpr/generate_qi_test.cpp
      - copied unchanged from r61303, /trunk/libs/spirit/example/scheme/test/generate_qiexpr/generate_qi_test.cpp
   branches/release/libs/spirit/example/scheme/test/generate_qiexpr/generate_qiexpr.cpp
      - copied unchanged from r61303, /trunk/libs/spirit/example/scheme/test/generate_qiexpr/generate_qiexpr.cpp
   branches/release/libs/spirit/example/scheme/test/scheme/
      - copied from r61285, /trunk/libs/spirit/example/scheme/test/scheme/
   branches/release/libs/spirit/example/scheme/test/scheme/factorial.scm
      - copied unchanged from r61285, /trunk/libs/spirit/example/scheme/test/scheme/factorial.scm
   branches/release/libs/spirit/example/scheme/test/scheme/scheme_test1.cpp
      - copied, changed from r61285, /trunk/libs/spirit/example/scheme/test/scheme/scheme_test1.cpp
   branches/release/libs/spirit/example/scheme/test/scheme/scheme_test1.scm
      - copied unchanged from r61285, /trunk/libs/spirit/example/scheme/test/scheme/scheme_test1.scm
   branches/release/libs/spirit/example/scheme/test/scheme/scheme_test2.cpp
      - copied, changed from r61285, /trunk/libs/spirit/example/scheme/test/scheme/scheme_test2.cpp
   branches/release/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp
      - copied, changed from r61285, /trunk/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp
   branches/release/libs/spirit/example/scheme/test/sexpr/
      - copied from r61285, /trunk/libs/spirit/example/scheme/test/sexpr/
   branches/release/libs/spirit/example/scheme/test/sexpr/out.txt
      - copied unchanged from r61285, /trunk/libs/spirit/example/scheme/test/sexpr/out.txt
   branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_input_test.cpp
      - copied, changed from r61285, /trunk/libs/spirit/example/scheme/test/sexpr/sexpr_input_test.cpp
   branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_output_test.cpp
      - copied, changed from r61285, /trunk/libs/spirit/example/scheme/test/sexpr/sexpr_output_test.cpp
   branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_test.txt
      - copied unchanged from r61285, /trunk/libs/spirit/example/scheme/test/sexpr/sexpr_test.txt
   branches/release/libs/spirit/example/scheme/test/utree/
      - copied from r61299, /trunk/libs/spirit/example/scheme/test/utree/
   branches/release/libs/spirit/example/scheme/test/utree/utree_test.cpp
      - copied, changed from r61299, /trunk/libs/spirit/example/scheme/test/utree/utree_test.cpp
   branches/release/libs/spirit/example/scheme/utree/
      - copied from r61299, /trunk/libs/spirit/example/scheme/utree/
   branches/release/libs/spirit/example/scheme/utree/detail/
      - copied from r61299, /trunk/libs/spirit/example/scheme/utree/detail/
   branches/release/libs/spirit/example/scheme/utree/detail/utree_detail1.hpp
      - copied unchanged from r61299, /trunk/libs/spirit/example/scheme/utree/detail/utree_detail1.hpp
   branches/release/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp
      - copied, changed from r61299, /trunk/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp
   branches/release/libs/spirit/example/scheme/utree/detail/utree_detail3.hpp
      - copied, changed from r61299, /trunk/libs/spirit/example/scheme/utree/detail/utree_detail3.hpp
   branches/release/libs/spirit/example/scheme/utree/io.hpp
      - copied unchanged from r61299, /trunk/libs/spirit/example/scheme/utree/io.hpp
   branches/release/libs/spirit/example/scheme/utree/operators.hpp
      - copied unchanged from r61299, /trunk/libs/spirit/example/scheme/utree/operators.hpp
   branches/release/libs/spirit/example/scheme/utree/utree.hpp
      - copied, changed from r61299, /trunk/libs/spirit/example/scheme/utree/utree.hpp
   branches/release/libs/spirit/test/karma/karma_optional_double.cpp
      - copied unchanged from r61328, /trunk/libs/spirit/test/karma/karma_optional_double.cpp
Removed:
   branches/release/libs/spirit/example/scheme/scheme_compiler.hpp
   branches/release/libs/spirit/example/scheme/scheme_interpreter.hpp
   branches/release/libs/spirit/example/scheme/scheme_intrinsics.hpp
   branches/release/libs/spirit/example/scheme/test/out.txt
   branches/release/libs/spirit/example/scheme/test/scheme.cpp
   branches/release/libs/spirit/example/scheme/test/scheme_test.scm
   branches/release/libs/spirit/example/scheme/test/sexpr_input_test.cpp
   branches/release/libs/spirit/example/scheme/test/sexpr_output_test.cpp
   branches/release/libs/spirit/example/scheme/test/sexpr_test.txt
   branches/release/libs/spirit/example/scheme/test/utree_test.cpp
   branches/release/libs/spirit/example/scheme/utree.hpp
   branches/release/libs/spirit/example/scheme/utree_io.hpp
   branches/release/libs/spirit/example/scheme/utree_operators.hpp
Properties modified:
   branches/release/ (props changed)
   branches/release/INSTALL (props changed)
   branches/release/LICENSE_1_0.txt (props changed)
   branches/release/boost/ (props changed)
   branches/release/boost-build.jam (props changed)
   branches/release/boost.css (props changed)
   branches/release/boost.png (props changed)
   branches/release/boost/algorithm/string/ (props changed)
   branches/release/boost/archive/ (props changed)
   branches/release/boost/bimap/ (props changed)
   branches/release/boost/detail/ (props changed)
   branches/release/boost/filesystem/ (props changed)
   branches/release/boost/functional/hash/ (props changed)
   branches/release/boost/fusion/ (props changed)
   branches/release/boost/gil/ (props changed)
   branches/release/boost/graph/ (props changed)
   branches/release/boost/integer/ (props changed)
   branches/release/boost/interprocess/ (props changed)
   branches/release/boost/intrusive/ (props changed)
   branches/release/boost/msm/ (props changed)
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/program_options/ (props changed)
   branches/release/boost/property_tree/ (props changed)
   branches/release/boost/python/ (props changed)
   branches/release/boost/serialization/ (props changed)
   branches/release/boost/serialization/factory.hpp (props changed)
   branches/release/boost/signals/ (props changed)
   branches/release/boost/signals2/ (props changed)
   branches/release/boost/spirit/ (props changed)
   branches/release/boost/spirit/home/ (props changed)
   branches/release/boost/spirit/home/karma/ (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp (contents, props changed)
   branches/release/boost/system/ (props changed)
   branches/release/boost/thread/ (props changed)
   branches/release/boost/thread.hpp (props changed)
   branches/release/boost/utility/ (props changed)
   branches/release/boost/utility/value_init.hpp (props changed)
   branches/release/boost/uuid/ (props changed)
   branches/release/boost/variant/ (props changed)
   branches/release/boost/wave/ (props changed)
   branches/release/bootstrap.bat (props changed)
   branches/release/bootstrap.sh (props changed)
   branches/release/index.htm (props changed)
   branches/release/libs/ (props changed)
   branches/release/libs/array/test/array0.cpp (props changed)
   branches/release/libs/bimap/ (props changed)
   branches/release/libs/filesystem/ (props changed)
   branches/release/libs/functional/hash/ (props changed)
   branches/release/libs/graph_parallel/ (props changed)
   branches/release/libs/integer/ (props changed)
   branches/release/libs/interprocess/ (props changed)
   branches/release/libs/intrusive/ (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
   branches/release/libs/msm/ (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/numeric/ublas/doc/ (props changed)
   branches/release/libs/property_tree/ (props changed)
   branches/release/libs/python/ (props changed)
   branches/release/libs/serialization/ (props changed)
   branches/release/libs/signals/ (props changed)
   branches/release/libs/signals2/ (props changed)
   branches/release/libs/spirit/ (props changed)
   branches/release/libs/spirit/classic/example/ (props changed)
   branches/release/libs/spirit/doc/ (props changed)
   branches/release/libs/spirit/example/ (props changed)
   branches/release/libs/spirit/phoenix/ (props changed)
   branches/release/libs/spirit/test/ (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp (props changed)
   branches/release/libs/static_assert/ (props changed)
   branches/release/libs/system/ (props changed)
   branches/release/libs/thread/ (props changed)
   branches/release/libs/timer/ (props changed)
   branches/release/libs/utility/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
   branches/release/libs/utility/value_init.htm (props changed)
   branches/release/libs/utility/value_init_test.cpp (props changed)
   branches/release/libs/uuid/ (props changed)
   branches/release/libs/wave/ (props changed)
   branches/release/rst.css (props changed)
   branches/release/status/ (props changed)
   branches/release/status/Jamfile.v2 (props changed)
   branches/release/tools/ (props changed)
   branches/release/tools/bcp/ (props changed)
   branches/release/tools/jam/ (props changed)
   branches/release/tools/regression/ (props changed)
   branches/release/tools/release/ (props changed)
   branches/release/tools/wave/ (props changed)
Text files modified:
   branches/release/boost/spirit/home/karma/auxiliary/attr_cast.hpp | 3
   branches/release/boost/spirit/home/karma/binary/binary.hpp | 3
   branches/release/boost/spirit/home/karma/char/char.hpp | 26 +++++
   branches/release/boost/spirit/home/karma/char/char_generator.hpp | 2
   branches/release/boost/spirit/home/karma/detail/extract_from.hpp | 95 +++++++++++++-----
   branches/release/boost/spirit/home/karma/detail/pass_container.hpp | 2
   branches/release/boost/spirit/home/karma/detail/string_generate.hpp | 4
   branches/release/boost/spirit/home/karma/nonterminal/rule.hpp | 20 +++
   branches/release/boost/spirit/home/karma/numeric/bool.hpp | 7
   branches/release/boost/spirit/home/karma/numeric/bool_policies.hpp | 2
   branches/release/boost/spirit/home/karma/numeric/int.hpp | 7
   branches/release/boost/spirit/home/karma/numeric/real.hpp | 7
   branches/release/boost/spirit/home/karma/numeric/uint.hpp | 7
   branches/release/boost/spirit/home/karma/operator/alternative.hpp | 1
   branches/release/boost/spirit/home/karma/phoenix_attributes.hpp | 4
   branches/release/boost/spirit/home/karma/stream/stream.hpp | 11 +
   branches/release/boost/spirit/home/karma/string/lit.hpp | 12 +
   branches/release/boost/spirit/home/karma/string/symbols.hpp | 164 +++++++++++++++++++++++++++++++-
   branches/release/boost/spirit/home/qi/auxiliary/attr_cast.hpp | 3
   branches/release/boost/spirit/home/qi/char/char.hpp | 27 +++++
   branches/release/boost/spirit/home/qi/detail/assign_to.hpp | 38 ++++++
   branches/release/boost/spirit/home/qi/nonterminal/rule.hpp | 6
   branches/release/boost/spirit/home/support/adapt_class_attributes.hpp | 8
   branches/release/boost/spirit/home/support/attributes.hpp | 197 +++++++++++++++++++++++++++------------
   branches/release/boost/spirit/home/support/attributes_fwd.hpp | 60 +++++++-----
   branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp | 6
   branches/release/libs/spirit/doc/advanced/customization_points.qbk | 20 +++-
   branches/release/libs/spirit/example/karma/reference.cpp | 2
   branches/release/libs/spirit/example/qi/reference.cpp | 2
   branches/release/libs/spirit/example/scheme/detail/scheme_composite_call.hpp | 2
   branches/release/libs/spirit/example/scheme/detail/scheme_function_call.hpp | 2
   branches/release/libs/spirit/example/scheme/detail/utree_detail2.hpp | 2
   branches/release/libs/spirit/example/scheme/detail/utree_detail3.hpp | 11 ++
   branches/release/libs/spirit/example/scheme/example/Jamfile | 1
   branches/release/libs/spirit/example/scheme/example/generate_qiexpr/generate_qiexpr.cpp | 4
   branches/release/libs/spirit/example/scheme/input/error_handler.hpp | 60 +++++------
   branches/release/libs/spirit/example/scheme/input/parse_sexpr.hpp | 50 ++++++++--
   branches/release/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp | 103 ++++++++++++++++----
   branches/release/libs/spirit/example/scheme/input/sexpr.hpp | 47 +++++++--
   branches/release/libs/spirit/example/scheme/input/string.hpp | 30 +++--
   branches/release/libs/spirit/example/scheme/output/generate_sexpr.hpp | 8
   branches/release/libs/spirit/example/scheme/output/generate_sexpr_impl.hpp | 4
   branches/release/libs/spirit/example/scheme/output/sexpr.hpp | 128 +------------------------
   branches/release/libs/spirit/example/scheme/qi/component_names.hpp | 7 +
   branches/release/libs/spirit/example/scheme/qi/parse_qiexpr.hpp | 2
   branches/release/libs/spirit/example/scheme/qi/parse_qiexpr_impl.hpp | 8
   branches/release/libs/spirit/example/scheme/qi/qiexpr_generator.hpp | 95 +++++++++++-------
   branches/release/libs/spirit/example/scheme/qi/qiexpr_parser.hpp | 120 ++++++-----------------
   branches/release/libs/spirit/example/scheme/scheme/compiler.hpp | 7 +
   branches/release/libs/spirit/example/scheme/support/line_pos_iterator.hpp | 57 +++++++++-
   branches/release/libs/spirit/example/scheme/test/Jamfile | 29 +++++
   branches/release/libs/spirit/example/scheme/test/parse_qiexpr/generate_sexpr_to_ostream.cpp | 4
   branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qi_test.cpp | 6
   branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qiexpr.cpp | 8
   branches/release/libs/spirit/example/scheme/test/scheme/scheme_test1.cpp | 15 --
   branches/release/libs/spirit/example/scheme/test/scheme/scheme_test2.cpp | 4
   branches/release/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp | 7
   branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_input_test.cpp | 6
   branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_output_test.cpp | 4
   branches/release/libs/spirit/example/scheme/test/utree/utree_test.cpp | 19 +++
   branches/release/libs/spirit/example/scheme/todo.txt | 3
   branches/release/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp | 99 +++++++++++++++++++
   branches/release/libs/spirit/example/scheme/utree/detail/utree_detail3.hpp | 20 +++
   branches/release/libs/spirit/example/scheme/utree/utree.hpp | 10 ++
   branches/release/libs/spirit/test/Jamfile | 1
   branches/release/libs/spirit/test/karma/attribute.cpp | 4
   branches/release/libs/spirit/test/karma/char.cpp | 3
   branches/release/libs/spirit/test/karma/pattern2.cpp | 17 +++
   branches/release/libs/spirit/test/karma/sequence.cpp | 12 ++
   branches/release/libs/spirit/test/karma/symbols.cpp | 174 +++++++++++++++++++++++++++++++++++
   branches/release/libs/spirit/test/qi/attribute.cpp | 4
   branches/release/libs/spirit/test/qi/char.cpp | 3
   branches/release/libs/spirit/test/qi/rule.cpp | 23 ++++
   branches/release/libs/spirit/test/qi/sequence.cpp | 7 +
   74 files changed, 1394 insertions(+), 582 deletions(-)

Modified: branches/release/boost/spirit/home/karma/auxiliary/attr_cast.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/attr_cast.hpp (original)
+++ branches/release/boost/spirit/home/karma/auxiliary/attr_cast.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -76,7 +76,8 @@
           , Attribute const& attr) const
         {
             typedef traits::transform_attribute<
- Attribute const, transformed_attribute_type> transform;
+ Attribute const, transformed_attribute_type, domain>
+ transform;
 
             return compile<karma::domain>(subject).generate(
                 sink, ctx, d, transform::pre(attr));

Modified: branches/release/boost/spirit/home/karma/binary/binary.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/binary/binary.hpp (original)
+++ branches/release/boost/spirit/home/karma/binary/binary.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -199,7 +199,8 @@
 #pragma warning(push)
 #pragma warning(disable: 4244)
 #endif
- p = traits::extract_from(attr, context);
+ typedef typename karma::detail::integer<bits>::type attribute_type;
+ p = traits::extract_from<attribute_type>(attr, context);
 #if defined(BOOST_MSVC)
 #pragma warning(pop)
 #endif

Modified: branches/release/boost/spirit/home/karma/char/char.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/char/char.hpp (original)
+++ branches/release/boost/spirit/home/karma/char/char.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -478,6 +478,32 @@
         }
     };
 
+ template <typename CharEncoding, typename Modifiers, typename Char>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::char_, CharEncoding>
+ , fusion::vector2<Char(&)[2], Char(&)[2]> // For single char strings
+ >
+ , Modifiers>
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef char_range<
+ typename spirit::detail::get_encoding_with_case<
+ Modifiers, CharEncoding, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ > result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args)[0]
+ , fusion::at_c<1>(term.args)[0]);
+ }
+ };
 }}} // namespace boost::spirit::karma
 
 #endif

Modified: branches/release/boost/spirit/home/karma/char/char_generator.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/char/char_generator.hpp (original)
+++ branches/release/boost/spirit/home/karma/char/char_generator.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -75,7 +75,7 @@
                 return false;
 
             Attr ch = Attr();
- if (!this->derived().test(traits::extract_from(attr, context), ch, context))
+ if (!this->derived().test(traits::extract_from<Attr>(attr, context), ch, context))
                 return false;
 
             return karma::detail::generate_to(sink, ch, char_encoding(), tag()) &&

Modified: branches/release/boost/spirit/home/karma/detail/extract_from.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/extract_from.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/extract_from.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -27,89 +27,130 @@
     // optimization will easily strip these away.
     ///////////////////////////////////////////////////////////////////////////
 
+ namespace detail
+ {
+ ///////////////////////////////////////////////////////////////////////
+ // extract first and second element of a fusion sequence
+ template <typename T>
+ struct add_const_ref
+ : add_reference<typename add_const<T>::type>
+ {};
+
+ template <typename T, int N>
+ struct value_at_c
+ : add_const_ref<typename fusion::result_of::value_at_c<T, N>::type>
+ {};
+ }
+
+ // forward declaration only
+ template <typename Exposed, typename Attribute, typename Context>
+ typename spirit::result_of::extract_from<Exposed, Attribute>::type
+ extract_from(Attribute const& attr, Context& ctx);
+
     // This is the default case: the plain attribute values
- template <typename Attribute, typename Enable/* = void*/>
+ template <typename Attribute, typename Exposed, typename Enable/*= void*/>
     struct extract_from_attribute
     {
- typedef Attribute const& type;
+ typedef typename traits::one_element_sequence<Attribute>::type
+ is_one_element_sequence;
+
+ typedef typename mpl::eval_if<
+ is_one_element_sequence
+ , detail::value_at_c<Attribute, 0>
+ , mpl::identity<Attribute const&>
+ >::type type;
 
         template <typename Context>
- static type call(Attribute const& attr, Context&)
+ static type call(Attribute const& attr, Context&, mpl::false_)
         {
             return attr;
         }
+
+ // This handles the case where the attribute is a single element fusion
+ // sequence. We silently extract the only element and treat it as the
+ // attribute to generate output from.
+ template <typename Context>
+ static type call(Attribute const& attr, Context& ctx, mpl::true_)
+ {
+ return extract_from<Exposed>(fusion::at_c<0>(attr), ctx);
+ }
+
+ template <typename Context>
+ static type call(Attribute const& attr, Context& ctx)
+ {
+ return call(attr, ctx, is_one_element_sequence());
+ }
     };
 
     // This handles optional attributes.
- template <typename Attribute>
- struct extract_from_attribute<optional<Attribute> >
+ template <typename Attribute, typename Exposed>
+ struct extract_from_attribute<optional<Attribute>, Exposed>
     {
         typedef Attribute const& type;
 
         template <typename Context>
- static type call(optional<Attribute> const& attr, Context&)
+ static type call(optional<Attribute> const& attr, Context& ctx)
         {
- return boost::get<Attribute>(attr);
+ return extract_from<Exposed>(boost::get<Attribute>(attr), ctx);
         }
     };
 
- template <typename Attribute>
- struct extract_from_attribute<optional<Attribute const> >
+ template <typename Attribute, typename Exposed>
+ struct extract_from_attribute<optional<Attribute const>, Exposed>
     {
         typedef Attribute const& type;
 
         template <typename Context>
- static type call(optional<Attribute const> const& attr, Context&)
+ static type call(optional<Attribute const> const& attr, Context& ctx)
         {
- return boost::get<Attribute const>(attr);
+ return extract_from<Exposed>(boost::get<Attribute const>(attr), ctx);
         }
     };
 
     // This handles attributes wrapped inside a boost::ref().
- template <typename Attribute>
- struct extract_from_attribute<reference_wrapper<Attribute> >
+ template <typename Attribute, typename Exposed>
+ struct extract_from_attribute<reference_wrapper<Attribute>, Exposed>
     {
         typedef Attribute const& type;
 
         template <typename Context>
- static type call(reference_wrapper<Attribute> const& attr, Context&)
+ static type call(reference_wrapper<Attribute> const& attr, Context& ctx)
         {
- return attr.get();
+ return extract_from<Exposed>(attr.get(), ctx);
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename Attribute, typename Context>
- typename spirit::result_of::extract_from<Attribute>::type
- extract_from(Attribute const& attr, Context& context)
+ template <typename Exposed, typename Attribute, typename Context>
+ typename spirit::result_of::extract_from<Exposed, Attribute>::type
+ extract_from(Attribute const& attr, Context& ctx)
     {
- return extract_from_attribute<Attribute>::call(attr, context);
+ return extract_from_attribute<Attribute, Exposed>::call(attr, ctx);
     }
 
- template <typename Context>
+ template <typename Exposed, typename Context>
     unused_type extract_from(unused_type, Context&)
     {
         return unused;
     }
-
 }}}
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace result_of
 {
- template <typename Attribute>
+ template <typename Exposed, typename Attribute>
     struct extract_from
- : traits::extract_from_attribute<Attribute>
+ : traits::extract_from_attribute<Attribute, Exposed>
     {};
 
- template <>
- struct extract_from<unused_type>
+ template <typename Exposed>
+ struct extract_from<Exposed, unused_type>
     {
         typedef unused_type type;
     };
 
- template <>
- struct extract_from<unused_type const>
+ template <typename Exposed>
+ struct extract_from<Exposed, unused_type const>
     {
         typedef unused_type type;
     };

Modified: branches/release/boost/spirit/home/karma/detail/pass_container.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/pass_container.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/pass_container.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -36,7 +36,7 @@
     template <typename RHS, typename LHSAttribute>
     struct has_same_elements<RHS, LHSAttribute, true>
       : mpl::or_<
- is_convertible<typename LHSAttribute::value_type, RHS>
+ is_convertible<RHS, typename LHSAttribute::value_type>
           , is_same<typename LHSAttribute::value_type, hold_any>
> {};
 

Modified: branches/release/boost/spirit/home/karma/detail/string_generate.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/string_generate.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/string_generate.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -56,7 +56,9 @@
     inline bool string_generate(OutputIterator& sink
       , Container const& c, Filter filter)
     {
- typedef typename traits::container_iterator<Container>::type iterator;
+ typedef typename traits::container_iterator<Container const>::type
+ iterator;
+
         iterator end = boost::end(c);
         for (iterator it = boost::begin(c); it != end; ++it)
         {

Modified: branches/release/boost/spirit/home/karma/nonterminal/rule.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/rule.hpp (original)
+++ branches/release/boost/spirit/home/karma/nonterminal/rule.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -247,12 +247,18 @@
                 // Create an attribute if none is supplied.
                 typedef traits::make_attribute<attr_type, Attribute>
                     make_attribute;
+ typedef traits::transform_attribute<
+ typename make_attribute::type, attr_type, domain>
+ transform;
+
+ typename transform::type attr_ =
+ traits::pre_transform<domain, attr_type>(
+ make_attribute::call(attr));
 
                 // If you are seeing a compilation error here, you are probably
                 // trying to use a rule or a grammar which has inherited
                 // attributes, without passing values for them.
- context_type context(traits::pre_transform<attr_type>(
- make_attribute::call(attr)));
+ context_type context(attr_);
 
                 // If you are seeing a compilation error here stating that the
                 // third parameter can't be converted to a karma::reference
@@ -281,12 +287,18 @@
                 // Create an attribute if none is supplied.
                 typedef traits::make_attribute<attr_type, Attribute>
                     make_attribute;
+ typedef traits::transform_attribute<
+ typename make_attribute::type, attr_type, domain>
+ transform;
+
+ typename transform::type attr_ =
+ traits::pre_transform<domain, attr_type>(
+ make_attribute::call(attr));
 
                 // If you are seeing a compilation error here, you are probably
                 // trying to use a rule or a grammar which has inherited
                 // attributes, passing values of incompatible types for them.
- context_type context(traits::pre_transform<attr_type>(
- make_attribute::call(attr)), params, caller_context);
+ context_type context(attr_, params, caller_context);
 
                 // If you are seeing a compilation error here stating that the
                 // third parameter can't be converted to a karma::reference

Modified: branches/release/boost/spirit/home/karma/numeric/bool.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/bool.hpp (original)
+++ branches/release/boost/spirit/home/karma/numeric/bool.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -144,7 +144,7 @@
                 return false; // fail if it's an uninitialized optional
 
             return bool_inserter<T, Policies, CharEncoding, Tag>::call(
- sink, traits::extract_from(attr, context), p_) &&
+ sink, traits::extract_from<T>(attr, context), p_) &&
                    delimit_out(sink, d); // always do post-delimiting
         }
 
@@ -184,7 +184,7 @@
     public:
         typedef typename Policies::properties properties;
 
- template <typename Context, typename Unused>
+ template <typename Context, typename Unused = unused_type>
         struct attribute
           : mpl::if_c<no_attribute, unused_type, T>
         {};
@@ -201,8 +201,9 @@
         bool generate(OutputIterator& sink, Context& context
           , Delimiter const& d, Attribute const& attr) const
         {
+ typedef typename attribute<Context>::type attribute_type;
             if (!traits::has_optional_value(attr) ||
- bool(n_) != bool(traits::extract_from(attr, context)))
+ bool(n_) != bool(traits::extract_from<attribute_type>(attr, context)))
             {
                 return false;
             }

Modified: branches/release/boost/spirit/home/karma/numeric/bool_policies.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/bool_policies.hpp (original)
+++ branches/release/boost/spirit/home/karma/numeric/bool_policies.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -28,7 +28,7 @@
     // // we want to spell the names of false as eurt (true backwards)
     // template <typename CharEncoding, typename Tag
     // , typename OutputIterator>
- // static bool generate_flase(OutputIterator& sink, bool)
+ // static bool generate_false(OutputIterator& sink, bool)
     // {
     // return string_inserter<CharEncoding, Tag>::call(sink, "eurt");
     // }

Modified: branches/release/boost/spirit/home/karma/numeric/int.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/int.hpp (original)
+++ branches/release/boost/spirit/home/karma/numeric/int.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -216,7 +216,7 @@
             if (!traits::has_optional_value(attr))
                 return false; // fail if it's an uninitialized optional
 
- return insert_int(sink, traits::extract_from(attr, context)) &&
+ return insert_int(sink, traits::extract_from<T>(attr, context)) &&
                    delimit_out(sink, d); // always do post-delimiting
         }
 
@@ -263,7 +263,7 @@
         }
 
     public:
- template <typename Context, typename Unused>
+ template <typename Context, typename Unused = unused_type>
         struct attribute
           : mpl::if_c<no_attribute, unused_type, T>
         {};
@@ -287,8 +287,9 @@
         bool generate(OutputIterator& sink, Context& context
           , Delimiter const& d, Attribute const& attr) const
         {
+ typedef typename attribute<Context>::type attribute_type;
             if (!traits::has_optional_value(attr) ||
- n_ != traits::extract_from(attr, context))
+ n_ != traits::extract_from<attribute_type>(attr, context))
             {
                 return false;
             }

Modified: branches/release/boost/spirit/home/karma/numeric/real.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/real.hpp (original)
+++ branches/release/boost/spirit/home/karma/numeric/real.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -175,7 +175,7 @@
                 return false; // fail if it's an uninitialized optional
 
             typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
- return inserter_type::call(sink, traits::extract_from(attr, context), p_) &&
+ return inserter_type::call(sink, traits::extract_from<T>(attr, context), p_) &&
                    karma::delimit_out(sink, d); // always do post-delimiting
         }
 
@@ -214,7 +214,7 @@
     {
         typedef typename Policies::properties properties;
 
- template <typename Context, typename Unused>
+ template <typename Context, typename Unused = unused_type>
         struct attribute
           : mpl::if_c<no_attribute, unused_type, T>
         {};
@@ -231,8 +231,9 @@
         bool generate(OutputIterator& sink, Context& context
           , Delimiter const& d, Attribute const& attr) const
         {
+ typedef typename attribute<Context>::type attribute_type;
             if (!traits::has_optional_value(attr) ||
- n_ != traits::extract_from(attr, context))
+ n_ != traits::extract_from<attribute_type>(attr, context))
             {
                 return false;
             }

Modified: branches/release/boost/spirit/home/karma/numeric/uint.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/uint.hpp (original)
+++ branches/release/boost/spirit/home/karma/numeric/uint.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -250,7 +250,7 @@
                 return false; // fail if it's an uninitialized optional
 
             return uint_inserter<Radix, CharEncoding, Tag>::
- call(sink, traits::extract_from(attr, context)) &&
+ call(sink, traits::extract_from<T>(attr, context)) &&
                    delimit_out(sink, d); // always do post-delimiting
         }
 
@@ -286,7 +286,7 @@
       : primitive_generator<literal_uint_generator<T, CharEncoding, Tag, Radix
           , no_attribute> >
     {
- template <typename Context, typename Unused>
+ template <typename Context, typename Unused = unused_type>
         struct attribute
           : mpl::if_c<no_attribute, unused_type, T>
         {};
@@ -310,8 +310,9 @@
         bool generate(OutputIterator& sink, Context& context
           , Delimiter const& d, Attribute const& attr) const
         {
+ typedef typename attribute<Context>::type attribute_type;
             if (!traits::has_optional_value(attr) ||
- n_ != traits::extract_from(attr, context))
+ n_ != traits::extract_from<attribute_type>(attr, context))
             {
                 return false;
             }

Modified: branches/release/boost/spirit/home/karma/operator/alternative.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/alternative.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator/alternative.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -12,7 +12,6 @@
 #endif
 
 #include <boost/spirit/home/karma/detail/alternative_function.hpp>
-#include <boost/spirit/home/karma/detail/extract_from.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
 #include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/meta_compiler.hpp>

Modified: branches/release/boost/spirit/home/karma/phoenix_attributes.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/phoenix_attributes.hpp (original)
+++ branches/release/boost/spirit/home/karma/phoenix_attributes.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -94,8 +94,8 @@
     // Handle Phoenix actors as attributes, just invoke the function object
     // and deal with the result as the attribute.
     ///////////////////////////////////////////////////////////////////////////
- template <typename Eval>
- struct extract_from_attribute<phoenix::actor<Eval> >
+ template <typename Eval, typename Exposed>
+ struct extract_from_attribute<phoenix::actor<Eval>, Exposed>
     {
         typedef typename boost::result_of<phoenix::actor<Eval>()>::type type;
 

Modified: branches/release/boost/spirit/home/karma/stream/stream.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/stream/stream.hpp (original)
+++ branches/release/boost/spirit/home/karma/stream/stream.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -110,7 +110,7 @@
     struct any_stream_generator
       : primitive_generator<any_stream_generator<Char, CharEncoding, Tag> >
     {
- template <typename Context, typename Unused>
+ template <typename Context, typename Unused = unused_type>
         struct attribute
         {
             typedef spirit::hold_any type;
@@ -132,8 +132,10 @@
                 return false;
 
             // use existing operator<<()
+ typedef typename attribute<Context>::type attribute_type;
+
             boost::iostreams::stream<sink_device> ostr(sink);
- ostr << traits::extract_from(attr, context) << std::flush;
+ ostr << traits::extract_from<attribute_type>(attr, context) << std::flush;
 
             if (ostr.good())
                 return karma::delimit_out(sink, d); // always do post-delimiting
@@ -163,9 +165,12 @@
                 return false;
 
             // use existing operator<<()
+ typedef typename attribute<Context>::type attribute_type;
+
             boost::iostreams::stream<sink_device> ostr(sink);
             ostr.imbue(sink.get_ostream().getloc());
- ostr << traits::extract_from(attr, context) << std::flush;
+ ostr << traits::extract_from<attribute_type>(attr, context)
+ << std::flush;
 
             if (ostr.good())
                 return karma::delimit_out(sink, d); // always do post-delimiting

Modified: branches/release/boost/spirit/home/karma/string/lit.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/string/lit.hpp (original)
+++ branches/release/boost/spirit/home/karma/string/lit.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -78,7 +78,7 @@
         typedef typename CharEncoding::char_type char_type;
         typedef CharEncoding char_encoding;
 
- template <typename Context, typename Unused>
+ template <typename Context, typename Unused = unused_type>
         struct attribute
         {
             typedef std::basic_string<char_type> type;
@@ -94,9 +94,11 @@
             if (!traits::has_optional_value(attr))
                 return false;
 
+ typedef typename attribute<Context>::type attribute_type;
             return
                 karma::detail::string_generate(sink
- , traits::extract_from(attr, context), char_encoding(), Tag()) &&
+ , traits::extract_from<attribute_type>(attr, context)
+ , char_encoding(), Tag()) &&
                 karma::delimit_out(sink, d); // always do post-delimiting
         }
 
@@ -134,7 +136,7 @@
         char_type;
         typedef std::basic_string<char_type> string_type;
 
- template <typename Context, typename Unused>
+ template <typename Context, typename Unused = unused_type>
         struct attribute
           : mpl::if_c<no_attribute, unused_type, string_type>
         {};
@@ -156,9 +158,11 @@
                 return false;
 
             // fail if attribute isn't matched by immediate literal
+ typedef typename attribute<Context>::type attribute_type;
+
             using spirit::traits::get_c_string;
             if (!detail::string_compare(
- get_c_string(traits::extract_from(attr, context))
+ get_c_string(traits::extract_from<attribute_type>(attr, context))
                   , get_c_string(str_), char_encoding(), Tag()))
             {
                 return false;

Modified: branches/release/boost/spirit/home/karma/string/symbols.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/string/symbols.hpp (original)
+++ branches/release/boost/spirit/home/karma/string/symbols.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -13,6 +13,7 @@
 #include <boost/spirit/home/karma/domain.hpp>
 #include <boost/spirit/home/karma/meta_compiler.hpp>
 #include <boost/spirit/home/karma/reference.hpp>
+#include <boost/spirit/home/karma/generate.hpp>
 #include <boost/spirit/home/karma/delimit_out.hpp>
 #include <boost/spirit/home/karma/detail/get_casetag.hpp>
 #include <boost/spirit/home/karma/detail/string_generate.hpp>
@@ -28,8 +29,119 @@
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace traits
+{
+ template <typename Attribute, typename T, typename Enable = void>
+ struct symbols_lookup
+ {
+ typedef
+ mpl::eval_if<fusion::traits::is_sequence<T>
+ , detail::value_at_c<T, 0>
+ , detail::add_const_ref<T> > sequence_type;
+ typedef typename
+ mpl::eval_if<traits::is_container<T>
+ , traits::container_value<T>
+ , sequence_type>::type type;
+
+ // fusion sequence
+ template <typename T_>
+ static type call(T_ const& t, mpl::false_, mpl::true_)
+ {
+ return fusion::at_c<0>(t);
+ }
+
+ // container
+ template <typename T_, typename IsSequence>
+ static type call(T_ const& t, mpl::true_, IsSequence)
+ {
+ return t[0];
+ }
+
+ // not a container and not a fusion sequence
+ template <typename T_>
+ static type call(T_ const& t, mpl::false_, mpl::false_)
+ {
+ return t;
+ }
+
+ static type call(T const& t)
+ {
+ typedef typename traits::is_container<T>::type is_container;
+ typedef typename fusion::traits::is_sequence<T>::type is_sequence;
+
+ return call(t, is_container(), is_sequence());
+ }
+ };
+
+ template <typename Attribute>
+ struct symbols_lookup<Attribute, Attribute>
+ {
+ typedef Attribute const& type;
+
+ static type call(Attribute const& t)
+ {
+ return t;
+ }
+ };
+
+ template <typename Attribute, typename T, typename Enable = void>
+ struct symbols_value
+ {
+ typedef
+ mpl::eval_if<fusion::traits::is_sequence<T>
+ , detail::value_at_c<T, 1>
+ , mpl::identity<unused_type> > sequence_type;
+ typedef typename
+ mpl::eval_if<traits::is_container<T>
+ , traits::container_value<T>
+ , sequence_type>::type type;
+
+ // fusion sequence
+ template <typename T_>
+ static type call(T_ const& t, mpl::false_, mpl::true_)
+ {
+ return fusion::at_c<1>(t);
+ }
+
+ // container
+ template <typename T_, typename IsSequence>
+ static type call(T_ const& t, mpl::true_, IsSequence)
+ {
+ return t[1];
+ }
+
+ // not a container nor a fusion sequence
+ template <typename T_>
+ static type call(T_ const& t, mpl::false_, mpl::false_)
+ {
+ return unused;
+ }
+
+ static type call(T const& t)
+ {
+ typedef typename traits::is_container<T>::type is_container;
+ typedef typename fusion::traits::is_sequence<T>::type is_sequence;
+
+ return call(t, is_container(), is_sequence());
+ }
+ };
+
+ template <typename Attribute>
+ struct symbols_value<Attribute, Attribute>
+ {
+ typedef unused_type type;
+
+ static type call(Attribute const&)
+ {
+ return unused;
+ }
+ };
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
+ ///////////////////////////////////////////////////////////////////////////
     template <typename Attribute, typename T>
     struct symbols_lookup
       : mpl::if_<
@@ -40,6 +152,37 @@
     {};
 
     ///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ ///////////////////////////////////////////////////////////////////////
+ template <typename CharEncoding, typename Tag>
+ struct generate_encoded
+ {
+ typedef typename
+ proto::terminal<tag::char_code<Tag, CharEncoding> >::type
+ encoding_type;
+
+ template <typename OutputIterator, typename Expr, typename Attribute>
+ static bool call(OutputIterator& sink, Expr const& expr
+ , Attribute const& attr)
+ {
+ encoding_type const encoding = encoding_type();
+ return karma::generate(sink, encoding[expr], attr);
+ }
+ };
+
+ template <>
+ struct generate_encoded<unused_type, unused_type>
+ {
+ template <typename OutputIterator, typename Expr, typename Attribute>
+ static bool call(OutputIterator& sink, Expr const& expr
+ , Attribute const& attr)
+ {
+ return karma::generate(sink, expr, attr);
+ }
+ };
+ }
+
     template <
         typename Attribute = char, typename T = unused_type
       , typename Lookup = typename symbols_lookup<Attribute, T>::type
@@ -186,13 +329,15 @@
         bool generate(OutputIterator& sink, Context&, Delimiter const& d
           , Attr const& attr) const
         {
- typename Lookup::iterator it = lookup->find(attr);
+ typename Lookup::iterator it = lookup->find(
+ traits::symbols_lookup<Attribute, Attr>::call(attr));
             if (it == lookup->end())
                 return false;
 
- return spirit::karma::detail::string_generate(
- sink, (*it).second, CharEncoding(), Tag()) &&
- spirit::karma::delimit_out(sink, d);
+ return karma::detail::generate_encoded<CharEncoding, Tag>::call(
+ sink, (*it).second
+ , traits::symbols_value<Attribute, Attr>::call(attr)) &&
+ karma::delimit_out(sink, d);
         }
 
         template <typename Context>
@@ -425,13 +570,16 @@
         bool generate(OutputIterator& sink, Context&, Delimiter const& d
           , Attr const& attr) const
         {
- typename Lookup::iterator it = lookup->find(attr);
+ typename Lookup::iterator it = lookup->find(
+ traits::symbols_lookup<Attribute, Attr>::call(attr));
             if (it == lookup->end())
                 return false;
 
- return spirit::karma::detail::string_generate(
- sink, attr, CharEncoding(), Tag()) &&
- spirit::karma::delimit_out(sink, d);
+ return karma::detail::generate_encoded<CharEncoding, Tag>::
+ call(sink
+ , traits::symbols_lookup<Attribute, Attr>::call(attr)
+ , unused) &&
+ karma::delimit_out(sink, d);
         }
 
         template <typename Context>

Modified: branches/release/boost/spirit/home/qi/auxiliary/attr_cast.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/auxiliary/attr_cast.hpp (original)
+++ branches/release/boost/spirit/home/qi/auxiliary/attr_cast.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -87,7 +87,8 @@
             // do down-stream transformation, provides attribute for embedded
             // parser
             typedef traits::transform_attribute<
- exposed_attribute_type, transformed_attribute_type> transform;
+ exposed_attribute_type, transformed_attribute_type, domain>
+ transform;
 
             typename transform::type attr_ = transform::pre(attr);
 

Modified: branches/release/boost/spirit/home/qi/char/char.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/char/char.hpp (original)
+++ branches/release/boost/spirit/home/qi/char/char.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -534,6 +534,33 @@
             );
         }
     };
+
+ template <typename CharEncoding, typename Modifiers, typename Char>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::char_, CharEncoding>
+ , fusion::vector2<Char(&)[2], Char(&)[2]> // For single char strings
+ >
+ , Modifiers>
+ {
+ static bool const no_case =
+ has_modifier<Modifiers, tag::char_code_base<tag::no_case> >::value;
+
+ typedef typename
+ spirit::detail::get_encoding<Modifiers, CharEncoding>::type
+ char_encoding;
+
+ typedef char_range<char_encoding, no_case> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(
+ fusion::at_c<0>(term.args)[0]
+ , fusion::at_c<1>(term.args)[0]
+ );
+ }
+ };
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/qi/detail/assign_to.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/detail/assign_to.hpp (original)
+++ branches/release/boost/spirit/home/qi/detail/assign_to.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -15,7 +15,7 @@
 
 #include <boost/spirit/home/qi/detail/construct.hpp>
 #include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/attributes_fwd.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
 #include <boost/spirit/home/support/container.hpp>
 #include <boost/spirit/home/phoenix/core/actor.hpp>
 #include <boost/ref.hpp>
@@ -87,14 +87,45 @@
     }
 
     ///////////////////////////////////////////////////////////////////////////
+ template <typename T, typename Attribute>
+ void assign_to(T const& val, Attribute& attr);
+
     template <typename Attribute, typename T, typename Enable>
     struct assign_to_attribute_from_value
     {
+ typedef typename traits::one_element_sequence<Attribute>::type
+ is_one_element_sequence;
+
+ typedef typename mpl::eval_if<
+ is_one_element_sequence
+ , fusion::result_of::at_c<Attribute, 0>
+ , mpl::identity<Attribute&>
+ >::type type;
+
+ template <typename T_>
         static void
- call(T const& val, Attribute& attr)
+ call(T_ const& val, Attribute& attr, mpl::false_)
         {
             attr = static_cast<Attribute>(val);
         }
+
+ // This handles the case where the attribute is a single element fusion
+ // sequence. We silently assign to the only element and treat it as the
+ // attribute to parse the results into.
+ template <typename T_>
+ static void
+ call(T_ const& val, Attribute& attr, mpl::true_)
+ {
+ typedef typename fusion::result_of::value_at_c<Attribute, 0>::type
+ element_type;
+ fusion::at_c<0>(attr) = static_cast<element_type>(val);
+ }
+
+ static void
+ call(T const& val, Attribute& attr)
+ {
+ call(val, attr, is_one_element_sequence());
+ }
     };
 
     template <typename Attribute, typename T>
@@ -103,7 +134,7 @@
         static void
         call(T const& val, reference_wrapper<Attribute> attr)
         {
- attr = static_cast<Attribute>(val.get());
+ assign_to(val.get(), attr);
         }
     };
 
@@ -128,7 +159,6 @@
     assign_to(T const&, unused_type)
     {
     }
-
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/qi/nonterminal/rule.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/nonterminal/rule.hpp (original)
+++ branches/release/boost/spirit/home/qi/nonterminal/rule.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -246,7 +246,8 @@
                 // do down-stream transformation, provides attribute for
                 // rhs parser
                 typedef traits::transform_attribute<
- typename make_attribute::type, attr_type> transform;
+ typename make_attribute::type, attr_type, domain>
+ transform;
 
                 typename make_attribute::type made_attr = make_attribute::call(attr);
                 typename transform::type attr_ = transform::pre(made_attr);
@@ -291,7 +292,8 @@
                 // do down-stream transformation, provides attribute for
                 // rhs parser
                 typedef traits::transform_attribute<
- typename make_attribute::type, attr_type> transform;
+ typename make_attribute::type, attr_type, domain>
+ transform;
 
                 typename make_attribute::type made_attr = make_attribute::call(attr);
                 typename transform::type attr_ = transform::pre(made_attr);

Modified: branches/release/boost/spirit/home/support/adapt_class_attributes.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/adapt_class_attributes.hpp (original)
+++ branches/release/boost/spirit/home/support/adapt_class_attributes.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -74,9 +74,9 @@
     {};
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename T, int N, typename Attribute>
+ template <typename T, int N, typename Attribute, typename Domain>
     struct transform_attribute<
- fusion::extension::class_member_proxy<T, N>, Attribute
+ fusion::extension::class_member_proxy<T, N>, Attribute, Domain
       , typename disable_if<
             is_reference<typename fusion::extension::class_member_proxy<T, N>::lvalue>
>::type>
@@ -100,9 +100,9 @@
         }
     };
 
- template <typename T, int N, typename Attribute>
+ template <typename T, int N, typename Attribute, typename Domain>
     struct transform_attribute<
- fusion::extension::class_member_proxy<T, N>, Attribute
+ fusion::extension::class_member_proxy<T, N>, Attribute, Domain
       , typename enable_if<
             is_reference<typename fusion::extension::class_member_proxy<T, N>::lvalue>
>::type>

Modified: branches/release/boost/spirit/home/support/attributes.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/attributes.hpp (original)
+++ branches/release/boost/spirit/home/support/attributes.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -17,6 +17,8 @@
 #include <boost/spirit/home/support/attributes_fwd.hpp>
 #include <boost/spirit/home/support/detail/hold_any.hpp>
 #include <boost/spirit/home/support/detail/as_variant.hpp>
+#include <boost/spirit/home/qi/domain.hpp>
+#include <boost/spirit/home/karma/domain.hpp>
 #include <boost/optional/optional.hpp>
 #include <boost/fusion/include/transform.hpp>
 #include <boost/fusion/include/filter_if.hpp>
@@ -38,6 +40,7 @@
 #include <boost/mpl/deref.hpp>
 #include <boost/mpl/distance.hpp>
 #include <boost/mpl/or.hpp>
+#include <boost/mpl/has_xxx.hpp>
 #include <boost/proto/proto_fwd.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/variant.hpp>
@@ -49,7 +52,7 @@
 namespace boost { namespace spirit { namespace traits
 {
     ///////////////////////////////////////////////////////////////////////////
- // This file deals with attribute related functions and metafunctions
+ // This file deals with attribute related functions and meta-functions
     // including generalized attribute transformation utilities for Spirit
     // components.
     ///////////////////////////////////////////////////////////////////////////
@@ -100,7 +103,8 @@
     namespace detail
     {
         // A component is compatible to a given Attribute type if the
- // Attribute is the same as the expected type of the component
+ // Attribute is the same as the expected type of the component or if
+ // it is convertible to the expected type.
         template <typename Expected, typename Attribute>
         struct attribute_is_compatible
           : is_convertible<Attribute, Expected>
@@ -117,7 +121,8 @@
         {};
     }
 
- template <typename Expected, typename Attribute, typename IsNotVariant = mpl::false_>
+ template <typename Expected, typename Attribute
+ , typename IsNotVariant = mpl::false_, typename Enable = void>
     struct compute_compatible_component_variant
       : mpl::or_<
             traits::detail::attribute_is_compatible<Expected, Attribute>
@@ -128,8 +133,14 @@
               , mpl::false_> >
     {};
 
+ namespace detail
+ {
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(types)
+ }
+
     template <typename Expected, typename Variant>
- struct compute_compatible_component_variant<Expected, Variant, mpl::false_>
+ struct compute_compatible_component_variant<Expected, Variant, mpl::false_
+ , typename enable_if<detail::has_types<Variant> >::type>
     {
         typedef typename traits::variant_type<Variant>::type variant_type;
         typedef typename variant_type::types types;
@@ -197,7 +208,7 @@
     ///////////////////////////////////////////////////////////////////////////
     // attribute_not_unused
     //
- // An mpl metafunction class that determines whether a component's
+ // An mpl meta-function class that determines whether a component's
     // attribute is not unused.
     ///////////////////////////////////////////////////////////////////////////
     template <typename Context, typename Iterator = unused_type>
@@ -552,32 +563,22 @@
         static void fail(Attribute&) {}
     };
 
- template <typename Exposed, typename Transformed, typename Enable/* = void*/>
- struct transform_attribute
- : default_transform_attribute<Exposed, Transformed> {};
-
+ // main specialization for Qi
     template <typename Exposed, typename Transformed>
- struct transform_attribute<Exposed, Transformed,
- typename enable_if<
- mpl::and_<
- mpl::not_<is_const<Exposed> >,
- mpl::not_<is_reference<Exposed> >,
- is_proxy<Transformed>
- >
- >::type>
- : proxy_transform_attribute<Exposed, Transformed> {};
-
- template <typename Exposed, typename Transformed>
- struct transform_attribute<Exposed const, Transformed>
- {
- typedef Transformed type;
- static Transformed pre(Exposed const& val) { return Transformed(val); }
- // Karma only, no post() and no fail() required
- };
+ struct transform_attribute<Exposed, Transformed, qi::domain>
+ : mpl::if_<
+ mpl::and_<
+ mpl::not_<is_const<Exposed> >
+ , mpl::not_<is_reference<Exposed> >
+ , is_proxy<Transformed> >
+ , proxy_transform_attribute<Exposed, Transformed>
+ , default_transform_attribute<Exposed, Transformed>
+ >::type
+ {};
 
     template <typename Exposed, typename Transformed>
- struct transform_attribute<optional<Exposed>, Transformed,
- typename disable_if<is_same<optional<Exposed>, Transformed> >::type>
+ struct transform_attribute<optional<Exposed>, Transformed, qi::domain
+ , typename disable_if<is_same<optional<Exposed>, Transformed> >::type>
     {
         typedef Transformed& type;
         static Transformed& pre(optional<Exposed>& val)
@@ -593,22 +594,14 @@
         }
     };
 
- template <typename Attribute>
- struct transform_attribute<Attribute const, Attribute>
- {
- typedef Attribute const& type;
- static Attribute const& pre(Attribute const& val) { return val; }
- // Karma only, no post() and no fail() required
- };
-
     // reference types need special handling
     template <typename Exposed, typename Transformed>
- struct transform_attribute<Exposed&, Transformed>
- : transform_attribute<Exposed, Transformed>
+ struct transform_attribute<Exposed&, Transformed, qi::domain>
+ : transform_attribute<Exposed, Transformed, qi::domain>
     {};
 
     template <typename Attribute>
- struct transform_attribute<Attribute&, Attribute>
+ struct transform_attribute<Attribute&, Attribute, qi::domain>
     {
         typedef Attribute& type;
         static Attribute& pre(Attribute& val) { return val; }
@@ -616,73 +609,148 @@
         static void fail(Attribute&) {}
     };
 
+ // unused_type needs some special handling as well
+ template <>
+ struct transform_attribute<unused_type, unused_type, qi::domain>
+ {
+ typedef unused_type type;
+ static unused_type pre(unused_type) { return unused; }
+ static void post(unused_type, unused_type) {}
+ static void fail(unused_type) {}
+ };
+
+ template <>
+ struct transform_attribute<unused_type const, unused_type, qi::domain>
+ : transform_attribute<unused_type, unused_type, qi::domain>
+ {};
+
+ template <typename Attribute>
+ struct transform_attribute<unused_type, Attribute, qi::domain>
+ : transform_attribute<unused_type, unused_type, qi::domain>
+ {};
+
+ template <typename Attribute>
+ struct transform_attribute<unused_type const, Attribute, qi::domain>
+ : transform_attribute<unused_type, unused_type, qi::domain>
+ {};
+
     template <typename Attribute>
- struct transform_attribute<Attribute const&, Attribute>
- : transform_attribute<Attribute const, Attribute>
+ struct transform_attribute<Attribute, unused_type, qi::domain>
+ : transform_attribute<unused_type, unused_type, qi::domain>
+ {};
+
+ template <typename Attribute>
+ struct transform_attribute<Attribute const, unused_type, qi::domain>
+ : transform_attribute<unused_type, unused_type, qi::domain>
+ {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Exposed, typename Transformed>
+ struct transform_attribute<Exposed, Transformed, karma::domain>
+ {
+ typedef Transformed type;
+ static Transformed pre(Exposed& val)
+ {
+ return Transformed(extract_from<Exposed>(val, unused));
+ }
+ // Karma only, no post() and no fail() required
+ };
+
+ template <typename Exposed, typename Transformed>
+ struct transform_attribute<Exposed const, Transformed, karma::domain>
+ {
+ typedef Transformed type;
+ static Transformed pre(Exposed const& val)
+ {
+ return Transformed(extract_from<Exposed>(val, unused));
+ }
+ // Karma only, no post() and no fail() required
+ };
+
+ template <typename Attribute>
+ struct transform_attribute<Attribute const, Attribute, karma::domain>
+ {
+ typedef Attribute const& type;
+ static Attribute const& pre(Attribute const& val) { return val; }
+ // Karma only, no post() and no fail() required
+ };
+
+ // reference types need special handling
+ template <typename Exposed, typename Transformed>
+ struct transform_attribute<Exposed&, Transformed, karma::domain>
+ : transform_attribute<Exposed, Transformed, karma::domain>
+ {};
+
+ template <typename Exposed, typename Transformed>
+ struct transform_attribute<Exposed const&, Transformed, karma::domain>
+ : transform_attribute<Exposed const, Transformed, karma::domain>
+ {};
+
+ template <typename Attribute>
+ struct transform_attribute<Attribute const&, Attribute, karma::domain>
+ : transform_attribute<Attribute const, Attribute, karma::domain>
     {};
 
     // unused_type needs some special handling as well
     template <>
- struct transform_attribute<unused_type, unused_type>
+ struct transform_attribute<unused_type, unused_type, karma::domain>
     {
         typedef unused_type type;
         static unused_type pre(unused_type) { return unused; }
- static void post(unused_type, unused_type) {}
- static void fail(unused_type) {}
     };
 
     template <>
- struct transform_attribute<unused_type const, unused_type>
- : transform_attribute<unused_type, unused_type>
+ struct transform_attribute<unused_type const, unused_type, karma::domain>
+ : transform_attribute<unused_type, unused_type, karma::domain>
     {};
 
     template <typename Attribute>
- struct transform_attribute<unused_type, Attribute>
- : transform_attribute<unused_type, unused_type>
+ struct transform_attribute<unused_type, Attribute, karma::domain>
+ : transform_attribute<unused_type, unused_type, karma::domain>
     {};
 
     template <typename Attribute>
- struct transform_attribute<unused_type const, Attribute>
- : transform_attribute<unused_type, unused_type>
+ struct transform_attribute<unused_type const, Attribute, karma::domain>
+ : transform_attribute<unused_type, unused_type, karma::domain>
     {};
 
     template <typename Attribute>
- struct transform_attribute<Attribute, unused_type>
- : transform_attribute<unused_type, unused_type>
+ struct transform_attribute<Attribute, unused_type, karma::domain>
+ : transform_attribute<unused_type, unused_type, karma::domain>
     {};
 
     template <typename Attribute>
- struct transform_attribute<Attribute const, unused_type>
- : transform_attribute<unused_type, unused_type>
+ struct transform_attribute<Attribute const, unused_type, karma::domain>
+ : transform_attribute<unused_type, unused_type, karma::domain>
     {};
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename Transformed, typename Exposed>
- typename spirit::result_of::pre_transform<Exposed, Transformed>::type
+ template <typename Domain, typename Transformed, typename Exposed>
+ typename spirit::result_of::pre_transform<Exposed, Transformed, Domain>::type
     pre_transform(Exposed& attr BOOST_PROTO_DISABLE_IF_IS_CONST(Exposed))
     {
- return transform_attribute<Exposed, Transformed>::pre(attr);
+ return transform_attribute<Exposed, Transformed, Domain>::pre(attr);
     }
 
- template <typename Transformed, typename Exposed>
- typename spirit::result_of::pre_transform<Exposed const, Transformed>::type
+ template <typename Domain, typename Transformed, typename Exposed>
+ typename spirit::result_of::pre_transform<Exposed const, Transformed, Domain>::type
     pre_transform(Exposed const& attr)
     {
- return transform_attribute<Exposed const, Transformed>::pre(attr);
+ return transform_attribute<Exposed const, Transformed, Domain>::pre(attr);
     }
 
     ///////////////////////////////////////////////////////////////////////////
     template <typename Exposed, typename Transformed>
     void post_transform(Exposed& dest, Transformed const& attr)
     {
- return transform_attribute<Exposed, Transformed>::post(dest, attr);
+ return transform_attribute<Exposed, Transformed, qi::domain>::post(dest, attr);
     }
 
     ///////////////////////////////////////////////////////////////////////////
     template <typename Exposed, typename Transformed>
     void fail_transform(Exposed& dest, Transformed const&)
     {
- return transform_attribute<Exposed, Transformed>::fail(dest);
+ return transform_attribute<Exposed, Transformed, qi::domain>::fail(dest);
     }
 
     ///////////////////////////////////////////////////////////////////////////
@@ -918,6 +986,7 @@
     {
     }
 
+ ///////////////////////////////////////////////////////////////////////////
     template <typename Out, typename T>
     void print_attribute(Out& out, T const& val);
 
@@ -997,9 +1066,9 @@
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace result_of
 {
- template <typename Exposed, typename Transformed>
+ template <typename Exposed, typename Transformed, typename Domain>
     struct pre_transform
- : traits::transform_attribute<Exposed, Transformed>
+ : traits::transform_attribute<Exposed, Transformed, Domain>
     {};
 }}}
 

Modified: branches/release/boost/spirit/home/support/attributes_fwd.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/attributes_fwd.hpp (original)
+++ branches/release/boost/spirit/home/support/attributes_fwd.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -12,6 +12,30 @@
 #pragma once
 #endif
 
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace result_of
+{
+ // forward declaration only
+ template <typename Exposed, typename Attribute>
+ struct extract_from;
+
+ template <typename Exposed, typename Transformed, typename Domain>
+ struct pre_transform;
+
+ template <typename T>
+ struct optional_value;
+
+ template <typename Container>
+ struct begin;
+
+ template <typename Container>
+ struct end;
+
+ template <typename Iterator>
+ struct deref;
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace traits
 {
     ///////////////////////////////////////////////////////////////////////////
@@ -49,10 +73,12 @@
     // the user is able specify specific transformation rules for any attribute
     // type.
     ///////////////////////////////////////////////////////////////////////////
- template <typename Exposed, typename Transformed, typename Enable = void>
+ template <typename Exposed, typename Transformed, typename Domain
+ , typename Enable = void>
     struct transform_attribute;
 
     ///////////////////////////////////////////////////////////////////////////
+ // Qi only
     template <typename Attribute, typename Iterator, typename Enable = void>
     struct assign_to_attribute_from_iterators;
 
@@ -60,9 +86,14 @@
     struct assign_to_attribute_from_value;
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename Attribute, typename Enable = void>
+ // Karma only
+ template <typename Attribute, typename Exposed, typename Enable = void>
     struct extract_from_attribute;
 
+ template <typename Exposed, typename Attribute, typename Context>
+ typename spirit::result_of::extract_from<Exposed, Attribute>::type
+ extract_from(Attribute const& attr, Context& ctx);
+
     ///////////////////////////////////////////////////////////////////////////
     // Clear data efficiently
     ///////////////////////////////////////////////////////////////////////////
@@ -82,6 +113,7 @@
     struct is_container;
 
     ///////////////////////////////////////////////////////////////////////////
+ // Qi only
     template <typename Container, typename T, typename Enable = void>
     struct push_back_container;
 
@@ -90,6 +122,7 @@
 
     ///////////////////////////////////////////////////////////////////////
     // Determine the iterator type of the given container type
+ // Karma only
     ///////////////////////////////////////////////////////////////////////
     template <typename Container, typename Enable = void>
     struct begin_container;
@@ -107,28 +140,5 @@
     struct compare_iterators;
 }}}
 
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace result_of
-{
- // forward declaration only
- template <typename Attribute>
- struct extract_from;
-
- template <typename Exposed, typename Transformed>
- struct pre_transform;
-
- template <typename T>
- struct optional_value;
-
- template <typename Container>
- struct begin;
-
- template <typename Container>
- struct end;
-
- template <typename Iterator>
- struct deref;
-}}}
-
 #endif
 

Modified: branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp
==============================================================================
--- branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp (original)
+++ branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -202,7 +202,8 @@
             // do down-stream transformation, provides attribute for
             // rhs parser
             typedef traits::transform_attribute<
- typename make_attribute::type, subrule_attr_type> transform;
+ typename make_attribute::type, subrule_attr_type, domain>
+ transform;
 
             typename make_attribute::type made_attr = make_attribute::call(attr);
             typename transform::type attr_ = transform::pre(made_attr);
@@ -255,7 +256,8 @@
             // do down-stream transformation, provides attribute for
             // rhs parser
             typedef traits::transform_attribute<
- typename make_attribute::type, subrule_attr_type> transform;
+ typename make_attribute::type, subrule_attr_type, domain>
+ transform;
 
             typename make_attribute::type made_attr = make_attribute::call(attr);
             typename transform::type attr_ = transform::pre(made_attr);

Modified: branches/release/libs/spirit/doc/advanced/customization_points.qbk
==============================================================================
--- branches/release/libs/spirit/doc/advanced/customization_points.qbk (original)
+++ branches/release/libs/spirit/doc/advanced/customization_points.qbk 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -217,6 +217,10 @@
 provided attribute to the attribute type expected by the right hand side
 component (for `rule`) or the embedded component (for `attr_cast`).
 
+[note The interface of this customization point has been changed with Boost
+ V1.44. We added the `Domain` template parameter to allow for more fine
+ grained specializations for __qi__ and __karma__.]
+
 [heading Module Headers]
 
     #include <boost/spirit/home/support/attributes.hpp>
@@ -236,7 +240,7 @@
 
 [heading Synopsis]
 
- template <typename Exposed, typename Transformed, typename Enable>
+ template <typename Exposed, typename Transformed, typename Domain, typename Enable>
     struct transform_attribute
     {
         typedef <unspecified> type;
@@ -253,6 +257,9 @@
                              which needs to be transformed.] [none]]
     [[`Transformed`] [The attribute type expected by the component
                              to be provided as the result of the transformation.] [none]]
+ [[`Domain`] [The domain of the sub library the template is
+ instantiated in. Typically this is either `qi::domain`
+ or `karma::domain`.] [none]]
     [[`Enable`] [Helper template parameter usable to selectively
                              enable or disable certain specializations
                              of `transform_attribute` utilizing SFINAE (i.e.
@@ -267,6 +274,9 @@
     [[`Transformed`] [The type, `Transformed` is the type of the attribute
                            as passed along to the right hand side of the `rule`
                            (embedded component of `attr_cast`).]]
+ [[`Domain`] [The domain of the sub library the template is
+ instantiated in. Typically this is either `qi::domain`
+ or `karma::domain`.]]
     [[`exposed`] [An instance of type `Exposed`.]]
     [[`transformed`] [An instance of type `Transformed`.]]
 ]
@@ -275,7 +285,7 @@
 
 [table
     [[Expression] [Semantics]]
- [[`transform_attribute<Exposed, Transformed>::type`]
+ [[`transform_attribute<Exposed, Transformed, Domain>::type`]
                         [Evaluates to the type to be used as the result of the
                          transformation (to be passed to the right hand side of
                          the `rule` or to the embedded component of the
@@ -284,7 +294,7 @@
                          `Transformed&` instead avoiding superfluous object
                          creation.]]
     [[
-``type transform_attribute<Exposed, Transformed>::pre(exposed)``]
+``type transform_attribute<Exposed, Transformed, Domain>::pre(exposed)``]
                         [Do `pre`-transformation before invoking the right hand
                          side component for `rule` (or the embedded component
                          for `attr_cast`). This takes the attribute supplied as by
@@ -293,7 +303,7 @@
                          as exposed by the metafunction `type`). This function
                          will be called in /Qi/ and for /Karma/.]]
     [[
-``void transform_attribute<Exposed, Transformed>::post(exposed, transformed)``]
+``void transform_attribute<Exposed, Transformed, Domain>::post(exposed, transformed)``]
                         [Do `post`-transformation after the invocation of the
                          right hand side component for `rule` (or the embedded
                          component for `attr_cast`). This takes the original
@@ -303,7 +313,7 @@
                          into the supplied attribute instance. This function
                          will be called in /Qi/ only.]]
     [[
-``void transform_attribute<Exposed, Transformed>::fail(exposed)``]
+``void transform_attribute<Exposed, Transformed, Domain>::fail(exposed)``]
                         [Handling failing parse operations of the
                          right hand side component for `rule` (or the embedded
                          component for `attr_cast`). This function

Modified: branches/release/libs/spirit/example/karma/reference.cpp
==============================================================================
--- branches/release/libs/spirit/example/karma/reference.cpp (original)
+++ branches/release/libs/spirit/example/karma/reference.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -183,7 +183,7 @@
 namespace boost { namespace spirit { namespace traits
 {
     template <>
- struct transform_attribute<int_data const, int>
+ struct transform_attribute<int_data const, int, karma::domain>
     {
         typedef int type;
         static int pre(int_data const& d) { return d.i; }

Modified: branches/release/libs/spirit/example/qi/reference.cpp
==============================================================================
--- branches/release/libs/spirit/example/qi/reference.cpp (original)
+++ branches/release/libs/spirit/example/qi/reference.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -281,7 +281,7 @@
     // in this case we just expose the embedded 'int' as the attribute instance
     // to use, allowing to leave the function 'post()' empty
     template <>
- struct transform_attribute<int_data, int>
+ struct transform_attribute<int_data, int, qi::domain>
     {
         typedef int& type;
         static int& pre(int_data& d) { return d.i; }

Modified: branches/release/libs/spirit/example/scheme/detail/scheme_composite_call.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/detail/scheme_composite_call.hpp (original)
+++ branches/release/libs/spirit/example/scheme/detail/scheme_composite_call.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -34,7 +34,7 @@
 #define N BOOST_PP_ITERATION()
 
     template <BOOST_PP_ENUM_PARAMS(N, typename A)>
- actor operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) const
+ function operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) const
     {
         actor_list elements;
         BOOST_PP_REPEAT(N, SCHEME_PUSH_ELEMENT, _);

Modified: branches/release/libs/spirit/example/scheme/detail/scheme_function_call.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/detail/scheme_function_call.hpp (original)
+++ branches/release/libs/spirit/example/scheme/detail/scheme_function_call.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -38,7 +38,7 @@
     {
         boost::array<utree, N> elements;
         BOOST_PP_REPEAT(N, SCHEME_PUSH_ELEMENT, _);
- return f(get_range(elements));
+ return derived()(get_range(elements));
     }
 
 #undef N

Modified: branches/release/libs/spirit/example/scheme/detail/utree_detail2.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/detail/utree_detail2.hpp (original)
+++ branches/release/libs/spirit/example/scheme/detail/utree_detail2.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -65,7 +65,7 @@
             // if it fits, store it in-situ; small_string_size minus the length
             // of the string is placed in buff[small_string_size - 1]
             str = buff;
- buff[small_string_size - 1] = max_string_len - size;
+ buff[small_string_size - 1] = static_cast<char>(max_string_len - size);
             info() &= ~0x1;
         }
         else

Modified: branches/release/libs/spirit/example/scheme/detail/utree_detail3.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/detail/utree_detail3.hpp (original)
+++ branches/release/libs/spirit/example/scheme/detail/utree_detail3.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -34,6 +34,7 @@
             utree_type::list_type);
         SCHEME_GET_UTREE_TYPE(boost::iterator_range<utree::const_iterator>,
             utree_type::list_type);
+ SCHEME_GET_UTREE_TYPE(utree, utree_type::reference_type);
 
 #undef SCHEME_GET_UTREE_TYPE
 
@@ -140,6 +141,16 @@
                 return type(x.s.str(), x.s.size());
             }
         };
+
+ template <>
+ struct get_impl<utree>
+ {
+ typedef utree const& type;
+ static type call(utree const& x)
+ {
+ return x.which() == utree_type::reference_type ? *x.p : x;
+ }
+ };
     }
 }
 

Copied: branches/release/libs/spirit/example/scheme/example/Jamfile (from r61312, /trunk/libs/spirit/example/scheme/example/Jamfile)
==============================================================================
--- /trunk/libs/spirit/example/scheme/example/Jamfile (original)
+++ branches/release/libs/spirit/example/scheme/example/Jamfile 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -14,6 +14,7 @@
 
 exe sexpr_input_test : sexpr/sexpr_input_test.cpp ;
 exe sexpr_output_test : sexpr/sexpr_output_test.cpp ;
+exe sexpr_error_test : sexpr_error_test.cpp ;
 
 exe parse_qi_test
    : parse_qiexpr/generate_sexpr_to_ostream.cpp

Copied: branches/release/libs/spirit/example/scheme/example/generate_qiexpr/generate_qiexpr.cpp (from r61312, /trunk/libs/spirit/example/scheme/example/generate_qiexpr/generate_qiexpr.cpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/example/generate_qiexpr/generate_qiexpr.cpp (original)
+++ branches/release/libs/spirit/example/scheme/example/generate_qiexpr/generate_qiexpr.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -3,8 +3,8 @@
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#include "../../qi/generate_qiexpr.hpp"
-#include "../../qi/generate_qiexpr_impl.hpp"
+#include <qi/generate_qiexpr.hpp>
+#include <qi/generate_qiexpr_impl.hpp>
 
 // explicit template instantiation for the function generate_qiexpr
 namespace scheme { namespace output

Copied: branches/release/libs/spirit/example/scheme/input/error_handler.hpp (from r61331, /trunk/libs/spirit/example/scheme/input/error_handler.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/input/error_handler.hpp (original)
+++ branches/release/libs/spirit/example/scheme/input/error_handler.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -9,7 +9,8 @@
 
 #include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/function.hpp>
+#include <support/line_pos_iterator.hpp>
+#include <string>
 #include <iostream>
 
 namespace scheme { namespace input
@@ -17,46 +18,41 @@
     template <typename Iterator>
     struct error_handler
     {
- typedef
- boost::function<
- void(
- Iterator, Iterator, Iterator,
- boost::spirit::info const&
- )>
- errorf_type;
-
- errorf_type errorf;
- error_handler(errorf_type errorf)
- : errorf(errorf) {}
-
         template <typename, typename, typename, typename>
         struct result { typedef void type; };
 
+ std::string source_file;
+ error_handler(std::string const& source_file = "")
+ : source_file(source_file) {}
+
         void operator()(
             Iterator first, Iterator last,
             Iterator err_pos, boost::spirit::info const& what) const
         {
- if (!errorf.empty())
- {
- // "Overridden"
- errorf(first, last, err_pos, what);
- }
- else
+ Iterator eol = err_pos;
+ int line = get_line(err_pos);
+
+ if (source_file != "")
+ std::cerr << source_file;
+
+ if (line != -1)
             {
- // Default handler
- Iterator eol = err_pos;
- while (eol != last && *eol != '\n' && *eol != '\r')
- ++eol;
-
- std::cerr
- << "Error! Expecting "
- << what
- << " here: \""
- << std::string(err_pos, eol)
- << "\""
- << std::endl
- ;
+ if (source_file != "")
+ std::cerr << '(' << line << ')';
+ else
+ std::cerr << '(' << line << ')';
             }
+
+ std::cerr << " : Error! Expecting " << what;
+ //~ if (line != -1)
+ //~ {
+ //~ std::size_t col = get_column(first, err_pos, 4);
+ //~ std::cerr << " near column " << col << std::endl;
+ //~ }
+ //~ else
+ //~ {
+ std::cerr << std::endl;
+ //~ }
         }
     };
 }}

Modified: branches/release/libs/spirit/example/scheme/input/parse_sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/parse_sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/input/parse_sexpr.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,13 +1,16 @@
 // Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// Copyright (c) 2001-2010 Joel de Guzman
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #if !defined(BOOST_SPIRIT_PARSE_SEXPR)
 #define BOOST_SPIRIT_PARSE_SEXPR
 
-#include "../utree.hpp"
-#include "../input/sexpr.hpp"
+#include <utree/utree.hpp>
+#include <input/sexpr.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_base_of.hpp>
 #include <iosfwd>
 #include <string>
 
@@ -15,17 +18,44 @@
 {
     ///////////////////////////////////////////////////////////////////////////
     template <typename Char>
- bool parse_sexpr(std::basic_istream<Char>& is, utree& result);
+ bool parse_sexpr(
+ std::basic_istream<Char>& is,
+ utree& result,
+ std::string const& source_file = "");
 
     template <typename Char>
- bool parse_sexpr_list(std::basic_istream<Char>& is, utree& result);
+ bool parse_sexpr_list(
+ std::basic_istream<Char>& is,
+ utree& result,
+ std::string const& source_file = "");
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
- bool parse_sexpr(std::basic_string<Char>& str, utree& result);
+ template <typename Range>
+ typename boost::disable_if<
+ boost::is_base_of<std::ios_base, Range>, bool>::type
+ parse_sexpr(
+ Range const& rng,
+ utree& result,
+ std::string const& source_file = "");
+
+ template <typename Range>
+ typename boost::disable_if<
+ boost::is_base_of<std::ios_base, Range>, bool>::type
+ parse_sexpr_list(
+ Range const& rng,
+ utree& result,
+ std::string const& source_file = "");
 
- template <typename Char>
- bool parse_sexpr_list(std::basic_string<Char>& str, utree& result);
+ ///////////////////////////////////////////////////////////////////////////
+ bool parse_sexpr(
+ utree const& in,
+ utree& result,
+ std::string const& source_file = "");
+
+ bool parse_sexpr_list(
+ utree const& in,
+ utree& result,
+ std::string const& source_file = "");
 }}
 
 #endif

Modified: branches/release/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp (original)
+++ branches/release/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,6 +1,7 @@
 // Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// Copyright (c) 2001-2010 Joel de Guzman
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #if !defined(BOOST_SPIRIT_PARSE_SEXPR_IMPL)
@@ -11,23 +12,33 @@
 #include <boost/spirit/include/support_istream_iterator.hpp>
 #include <boost/spirit/include/qi_parse.hpp>
 
-#include "../input/sexpr.hpp"
-#include "../input/parse_sexpr.hpp"
+#include <input/sexpr.hpp>
+#include <input/parse_sexpr.hpp>
+#include <support/line_pos_iterator.hpp>
 
 namespace scheme { namespace input
 {
     ///////////////////////////////////////////////////////////////////////////
     template <typename Char>
- bool parse_sexpr(std::basic_istream<Char>& is, utree& result)
+ bool parse_sexpr(
+ std::basic_istream<Char>& is,
+ utree& result,
+ std::string const& source_file)
     {
         // no white space skipping in the stream!
         is.unsetf(std::ios::skipws);
 
- typedef boost::spirit::basic_istream_iterator<Char> iterator_type;
- iterator_type first(is);
- iterator_type last;
+ typedef
+ boost::spirit::basic_istream_iterator<Char>
+ stream_iterator_type;
+ stream_iterator_type sfirst(is);
+ stream_iterator_type slast;
+
+ typedef line_pos_iterator<stream_iterator_type> iterator_type;
+ iterator_type first(sfirst);
+ iterator_type last(slast);
 
- scheme::input::sexpr<iterator_type> p;
+ scheme::input::sexpr<iterator_type> p(source_file);
         scheme::input::sexpr_white_space<iterator_type> ws;
 
         using boost::spirit::qi::phrase_parse;
@@ -36,16 +47,25 @@
 
     ///////////////////////////////////////////////////////////////////////////
     template <typename Char>
- bool parse_sexpr_list(std::basic_istream<Char>& is, utree& result)
+ bool parse_sexpr_list(
+ std::basic_istream<Char>& is,
+ utree& result,
+ std::string const& source_file)
     {
         // no white space skipping in the stream!
         is.unsetf(std::ios::skipws);
 
- typedef boost::spirit::basic_istream_iterator<Char> iterator_type;
- iterator_type first(is);
- iterator_type last;
+ typedef
+ boost::spirit::basic_istream_iterator<Char>
+ stream_iterator_type;
+ stream_iterator_type sfirst(is);
+ stream_iterator_type slast;
+
+ typedef line_pos_iterator<stream_iterator_type> iterator_type;
+ iterator_type first(sfirst);
+ iterator_type last(slast);
 
- scheme::input::sexpr<iterator_type> p;
+ scheme::input::sexpr<iterator_type> p(source_file);
         scheme::input::sexpr_white_space<iterator_type> ws;
 
         using boost::spirit::qi::phrase_parse;
@@ -53,28 +73,63 @@
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
- bool parse_sexpr(std::basic_string<Char>& str, utree& result)
+ template <typename Range>
+ typename boost::disable_if<boost::is_base_of<std::ios_base, Range>, bool>::type
+ parse_sexpr(
+ Range const& rng,
+ utree& result,
+ std::string const& source_file)
     {
- typedef typename std::basic_string<Char>::const_iterator iterator_type;
+ typedef
+ line_pos_iterator<typename Range::const_iterator>
+ iterator_type;
 
- scheme::input::sexpr<iterator_type> p;
+ scheme::input::sexpr<iterator_type> p(source_file);
         scheme::input::sexpr_white_space<iterator_type> ws;
 
+ iterator_type first(rng.begin());
+ iterator_type last(rng.end());
+
         using boost::spirit::qi::phrase_parse;
- return phrase_parse(str.begin(), str.end(), p, ws, result);
+ return phrase_parse(first, last, p, ws, result);
     }
 
- template <typename Char>
- bool parse_sexpr_list(std::basic_string<Char>& str, utree& result)
+ template <typename Range>
+ typename boost::disable_if<boost::is_base_of<std::ios_base, Range>, bool>::type
+ parse_sexpr_list(
+ Range const& rng,
+ utree& result,
+ std::string const& source_file)
     {
- typedef typename std::basic_string<Char>::const_iterator iterator_type;
+ typedef
+ line_pos_iterator<typename Range::const_iterator>
+ iterator_type;
 
- scheme::input::sexpr<iterator_type> p;
+ scheme::input::sexpr<iterator_type> p(source_file);
         scheme::input::sexpr_white_space<iterator_type> ws;
 
+ iterator_type first(rng.begin());
+ iterator_type last(rng.end());
+
         using boost::spirit::qi::phrase_parse;
- return phrase_parse(str.begin(), str.end(), +p, ws, result);
+ return phrase_parse(first, last, +p, ws, result);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ bool parse_sexpr(
+ utree const& in,
+ utree& result,
+ std::string const& source_file)
+ {
+ return parse_sexpr(in.as<utf8_string_range>(), result, source_file);
+ }
+
+ bool parse_sexpr_list(
+ utree const& in,
+ utree& result,
+ std::string const& source_file)
+ {
+ return parse_sexpr_list(in.as<utf8_string_range>(), result, source_file);
     }
 }}
 

Modified: branches/release/libs/spirit/example/scheme/input/sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/input/sexpr.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -17,13 +17,15 @@
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/regex/pending/unicode_iterator.hpp>
 
-#include "../utree.hpp"
-#include "string.hpp"
+#include <utree/utree.hpp>
+#include <utree/operators.hpp>
+#include <input/string.hpp>
+#include <input/error_handler.hpp>
 
 namespace scheme { namespace input
 {
- using boost::spirit::ascii::char_;
- using boost::spirit::ascii::space;
+ using boost::spirit::standard::char_;
+ using boost::spirit::standard::space;
     using boost::spirit::qi::grammar;
     using boost::spirit::qi::rule;
     using boost::spirit::qi::eol;
@@ -36,7 +38,13 @@
     using boost::spirit::qi::bool_;
     using boost::spirit::qi::no_case;
     using boost::spirit::qi::lexeme;
- using boost::phoenix::function;
+ using boost::spirit::qi::on_error;
+ using boost::spirit::qi::fail;
+ using boost::spirit::qi::_1;
+ using boost::spirit::qi::_2;
+ using boost::spirit::qi::_3;
+ using boost::spirit::qi::_4;
+ using boost::spirit::info;
 
     typedef boost::uint32_t uchar; // a unicode code point
 
@@ -54,17 +62,20 @@
         rule<Iterator> start;
     };
 
- template <typename Iterator>
+ template <typename Iterator,
+ typename ErrorHandler = input::error_handler<Iterator> >
     struct sexpr : grammar<Iterator, sexpr_white_space<Iterator>, utree()>
     {
- sexpr() : sexpr::base_type(start)
+ sexpr(std::string const& source_file = "")
+ : sexpr::base_type(start), error_handler(ErrorHandler(source_file))
         {
             real_parser<double, strict_real_policies<double> > strict_double;
             uint_parser<unsigned char, 16, 2, 2> hex2;
 
- start = atom | list;
+ start = element.alias();
+ element = atom | list;
 
- list = '(' >> *start >> ')';
+ list = '(' > *element > ')';
 
             atom = strict_double
                     | integer
@@ -77,20 +88,32 @@
             std::string exclude = std::string(" ();\"\x01-\x1f\x7f") + '\0';
             symbol = lexeme[+(~char_(exclude))];
 
- integer = lexeme[no_case["0x"] >> hex]
+ integer = lexeme[no_case["0x"] > hex]
                     | lexeme['0' >> oct]
                     | int_
                     ;
 
- byte_str = lexeme[no_case['b'] >> +hex2];
+ byte_str = lexeme[no_case['b'] > +hex2];
+
+ start.name("sexpr");
+ start.name("sexpr");
+ list.name("list");
+ atom.name("atom");
+ symbol.name("symbol");
+ integer.name("integer");
+ byte_str.name("byte_str");
+ on_error<fail>(start, error_handler(_1, _2, _3, _4));
         }
 
- rule<Iterator, sexpr_white_space<Iterator>, utree()> start, list;
+ rule<Iterator, sexpr_white_space<Iterator>, utree()>
+ start, list, element;
         rule<Iterator, int()> integer;
         rule<Iterator, utree()> atom;
         rule<Iterator, utf8_symbol()> symbol;
         rule<Iterator, binary_string()> byte_str;
         scheme::input::string<Iterator> string;
+
+ function<ErrorHandler> const error_handler;
     };
 }}
 

Modified: branches/release/libs/spirit/example/scheme/input/string.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/string.hpp (original)
+++ branches/release/libs/spirit/example/scheme/input/string.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -17,12 +17,12 @@
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/regex/pending/unicode_iterator.hpp>
 
-#include "../utree.hpp"
-#include "../utree_operators.hpp"
+#include <utree/utree.hpp>
+#include <utree/operators.hpp>
 
 namespace scheme { namespace input
 {
- using boost::spirit::ascii::char_;
+ using boost::spirit::standard::char_;
     using boost::spirit::qi::grammar;
     using boost::spirit::qi::rule;
     using boost::spirit::qi::_val;
@@ -81,24 +81,28 @@
             function<detail::push_esc> push_esc;
 
             char_esc
- = '\\'
- >> ( ('u' >> hex4) [push_utf8(_r1, _1)]
- | ('U' >> hex8) [push_utf8(_r1, _1)]
- | char_("btnfr\\\"'") [push_esc(_r1, _1)]
- )
+ = '\\'
+ > ( ('u' > hex4) [push_utf8(_r1, _1)]
+ | ('U' > hex8) [push_utf8(_r1, _1)]
+ | char_("btnfr\\\"'") [push_esc(_r1, _1)]
+ )
                 ;
 
             char_lit
- = '\''
- >> (char_esc(_val) | (~char_('\'')) [_val += _1])
- >> '\''
+ = '\''
+ > (char_esc(_val) | (~char_('\'')) [_val += _1])
+ > '\''
                 ;
 
             start
                 = '"'
- >> *(char_esc(_val) | (~char_('"')) [_val += _1])
- >> '"'
+ > *(char_esc(_val) | (~char_('"')) [_val += _1])
+ > '"'
                 ;
+
+ char_esc.name("char_esc");
+ char_lit.name("char_lit");
+ start.name("string");
         }
 
         rule<Iterator, void(std::string&)> char_esc;

Modified: branches/release/libs/spirit/example/scheme/output/generate_sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/output/generate_sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/output/generate_sexpr.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,13 +1,13 @@
 // Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #if !defined(SCHEME_OUTPUT_GENERATE_SEXPR_MAR_29_2010_1210PM)
 #define SCHEME_OUTPUT_GENERATE_SEXPR_MAR_29_2010_1210PM
 
-#include "../utree.hpp"
-#include "../output/sexpr.hpp"
+#include <utree/utree.hpp>
+#include <output/sexpr.hpp>
 
 namespace scheme { namespace output
 {

Modified: branches/release/libs/spirit/example/scheme/output/generate_sexpr_impl.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/output/generate_sexpr_impl.hpp (original)
+++ branches/release/libs/spirit/example/scheme/output/generate_sexpr_impl.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -11,8 +11,8 @@
 #include <boost/spirit/include/karma_list.hpp>
 #include <boost/spirit/include/support_ostream_iterator.hpp>
 
-#include "../output/sexpr.hpp"
-#include "../output/generate_sexpr.hpp"
+#include <output/sexpr.hpp>
+#include <output/generate_sexpr.hpp>
 
 namespace scheme { namespace output
 {

Modified: branches/release/libs/spirit/example/scheme/output/sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/output/sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/output/sexpr.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,13 +1,14 @@
 // Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #if !defined(SCHEME_OUTPUT_SEXPR_MAR_8_2010_829AM)
 #define SCHEME_OUTPUT_SEXPR_MAR_8_2010_829AM
 
-#include "../utree.hpp"
-#include "../detail/utree_detail3.hpp"
+#include <utree/utree.hpp>
+#include <utree/detail/utree_detail3.hpp>
+#include <output/utree_traits.hpp>
 
 #include <string>
 
@@ -16,122 +17,6 @@
 #include <boost/spirit/include/karma.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace traits
-{
- // the specialization below tells Spirit to handle scheme::utree as if it
- // where a 'real' variant (in the context of karma)
- template <>
- struct not_is_variant<scheme::utree, karma::domain>
- : mpl::false_ {};
-
- // The specializations below tell Spirit to verify whether an attribute
- // type is compatible with a given variant type
- template <>
- struct compute_compatible_component_variant<
- boost::iterator_range<scheme::utree::iterator>, scheme::utree>
- : mpl::true_
- {
- typedef boost::iterator_range<scheme::utree::iterator> compatible_type;
- typedef mpl::int_<scheme::utree_type::list_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<
- boost::iterator_range<scheme::utree::const_iterator>, scheme::utree>
- : mpl::true_
- {
- typedef boost::iterator_range<scheme::utree::const_iterator> compatible_type;
- typedef mpl::int_<scheme::utree_type::list_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<scheme::nil, scheme::utree>
- : mpl::true_
- {
- typedef scheme::nil compatible_type;
- typedef mpl::int_<scheme::utree_type::nil_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<bool, scheme::utree>
- : mpl::true_
- {
- typedef bool compatible_type;
- typedef mpl::int_<scheme::utree_type::bool_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<int, scheme::utree>
- : mpl::true_
- {
- typedef int compatible_type;
- typedef mpl::int_<scheme::utree_type::int_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<double, scheme::utree>
- : mpl::true_
- {
- typedef double compatible_type;
- typedef mpl::int_<scheme::utree_type::double_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<
- scheme::utf8_string_range, scheme::utree>
- : mpl::true_
- {
- typedef scheme::utf8_string_range compatible_type;
- typedef mpl::int_<scheme::utree_type::string_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<
- scheme::utf8_string, scheme::utree>
- : mpl::true_
- {
- typedef scheme::utf8_string compatible_type;
- typedef mpl::int_<scheme::utree_type::string_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<
- scheme::utf8_symbol_range, scheme::utree>
- : mpl::true_
- {
- typedef scheme::utf8_symbol_range compatible_type;
- typedef mpl::int_<scheme::utree_type::symbol_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<
- scheme::utf8_symbol, scheme::utree>
- : mpl::true_
- {
- typedef scheme::utf8_symbol compatible_type;
- typedef mpl::int_<scheme::utree_type::symbol_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<
- scheme::binary_range, scheme::utree>
- : mpl::true_
- {
- typedef scheme::binary_range compatible_type;
- typedef mpl::int_<scheme::utree_type::binary_type> distance;
- };
-
- template <>
- struct compute_compatible_component_variant<
- scheme::binary_string, scheme::utree>
- : mpl::true_
- {
- typedef scheme::binary_string compatible_type;
- typedef mpl::int_<scheme::utree_type::binary_type> distance;
- };
-}}}
-
-///////////////////////////////////////////////////////////////////////////////
 namespace scheme { namespace output
 {
     using boost::spirit::karma::grammar;
@@ -165,6 +50,7 @@
                       | byte_str
                       | list
                       | nil_
+ | ref_
                       ;
 
             list = '(' << *start << ')';
@@ -173,6 +59,7 @@
             symbol = string;
             byte_str = 'b' << *right_align(2, '0')[hex2];
             nil_ = eps << "<nil>";
+ ref_ = start;
         }
 
         typedef boost::iterator_range<utree::const_iterator> utree_list;
@@ -183,6 +70,7 @@
         rule<OutputIterator, utf8_string_range()> string_;
         rule<OutputIterator, binary_range()> byte_str;
         rule<OutputIterator, nil()> nil_;
+ rule<OutputIterator, space_type, utree()> ref_;
     };
 }}
 

Copied: branches/release/libs/spirit/example/scheme/qi/component_names.hpp (from r61303, /trunk/libs/spirit/example/scheme/qi/component_names.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/qi/component_names.hpp (original)
+++ branches/release/libs/spirit/example/scheme/qi/component_names.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -67,6 +67,13 @@
       , "ascii", "standard", "standard_wide", "iso8859_1", "unicode"
       , 0
     };
+
+ // a list of names for all supported unary parser operators
+ static char const* const unary_names[] =
+ {
+ "*", "+", "-", "!", "&"
+ , 0
+ };
 }}
 
 #endif

Modified: branches/release/libs/spirit/example/scheme/qi/parse_qiexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/qi/parse_qiexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/qi/parse_qiexpr.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -6,7 +6,7 @@
 #if !defined(BOOST_SPIRIT_PARSE_QIEXPR)
 #define BOOST_SPIRIT_PARSE_QIEXPR
 
-#include "../utree.hpp"
+#include <utree/utree.hpp>
 
 namespace scheme { namespace input
 {

Modified: branches/release/libs/spirit/example/scheme/qi/parse_qiexpr_impl.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/qi/parse_qiexpr_impl.hpp (original)
+++ branches/release/libs/spirit/example/scheme/qi/parse_qiexpr_impl.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -10,8 +10,8 @@
 #include <boost/spirit/include/support_istream_iterator.hpp>
 #include <boost/spirit/include/qi_parse.hpp>
 
-#include "../qi/qiexpr_parser.hpp"
-#include "../qi/parse_qiexpr.hpp"
+#include <qi/qiexpr_parser.hpp>
+#include <qi/parse_qiexpr.hpp>
 
 namespace scheme { namespace input
 {
@@ -21,8 +21,8 @@
     {
         typedef typename String::const_iterator iterator_type;
 
- scheme::input::qiexpr<iterator_type> p;
- scheme::input::qiexpr_white_space<iterator_type> ws;
+ scheme::qi::qiexpr_parser<iterator_type> p;
+ scheme::qi::qiexpr_white_space<iterator_type> ws;
 
         iterator_type begin = str.begin();
         iterator_type end = str.end();

Copied: branches/release/libs/spirit/example/scheme/qi/qiexpr_generator.hpp (from r61303, /trunk/libs/spirit/example/scheme/qi/qiexpr_generator.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/qi/qiexpr_generator.hpp (original)
+++ branches/release/libs/spirit/example/scheme/qi/qiexpr_generator.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -14,34 +14,10 @@
 #include <utree/utree.hpp>
 #include <utree/detail/utree_detail3.hpp>
 #include <utree/operators.hpp>
+#include <output/utree_traits.hpp>
 #include <qi/component_names.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace traits
-{
- template <>
- struct symbols_lookup<scheme::utree, std::string>
- {
- typedef std::string type;
- static type call(scheme::utree const& t)
- {
- BOOST_ASSERT(t.which() == scheme::utree_type::list_type);
- return boost::get<scheme::utf8_symbol>(t.front());
- }
- };
-
- template <>
- struct symbols_value<scheme::utree, std::string>
- {
- typedef unused_type type;
- static type call(scheme::utree const& t)
- {
- return unused;
- }
- };
-}}}
-
-///////////////////////////////////////////////////////////////////////////////
 namespace scheme { namespace qi
 {
     using boost::spirit::karma::grammar;
@@ -56,30 +32,77 @@
         qiexpr_generator() : qiexpr_generator::base_type(start)
         {
             using boost::spirit::karma::eps;
+ using boost::spirit::karma::string;
+ using boost::spirit::karma::omit;
+ using boost::spirit::karma::repeat;
+ using boost::spirit::karma::_r1;
+
+ start =
+ nil
+ | alternative
+ ;
+
+ alternative =
+ &symbol(std::string("|")) << '(' << permutation % '|' << ')'
+ | permutation
+ ;
 
- start = term.alias();
+ permutation =
+ &symbol(std::string("^")) << '(' << sequence % '^' << ')'
+ | sequence
+ ;
 
- term =
-// primitives2 << '(' << string << ',' << string << ')'
-// | primitives1 << '(' << string << ')'
- /*|*/ primitive0
+ sequence =
+ &symbol(std::string(">>")) << '(' << term % ">>" << ')'
+ | term
                 ;
 
+ term =
+ unary << repeat(1)[alternative]
+ | primitive2 << '(' << literal << ',' << literal << ')'
+ | primitive1 << '(' << literal << ')'
+ | primitive0 << -omit[node]
+ ;
+
+ symbol = string(_r1);
+ literal = '"' << string << '"';
+ node = eps;
+ nil = eps;
+
             // fill the symbol tables with all known primitive parser names
             for (char const* const* p = primitives0; *p; ++p)
- primitive0.add(*p);
+ primitive0.add(utf8_symbol(*p));
 
             for (char const* const* p = primitives1; *p; ++p)
- primitive1.add(*p);
+ primitive1.add(utf8_symbol(*p));
 
             for (char const* const* p = primitives2; *p; ++p)
- primitive2.add(*p);
+ primitive2.add(utf8_symbol(*p));
+
+ for (char const* const* p = unary_names; *p; ++p)
+ unary.add(utf8_symbol(*p));
+
+ start.name("start");
+ alternative.name("alternative");
+ permutation.name("permutation");
+ sequence.name("sequence");
+ term.name("term");
+ node.name("node");
+ literal.name("string");
+ nil.name("nil");
         }
 
- typedef rule<OutputIterator, space_type, utree()> rule_type;
+ typedef rule<OutputIterator, space_type, utree()> delimiting_rule_type;
+ typedef rule<OutputIterator, utree()> rule_type;
+
+ delimiting_rule_type start, alternative, permutation, sequence, term;
+ rule_type node;
+ rule<OutputIterator, nil()> nil;
+ rule<OutputIterator, scheme::utf8_string()> literal;
+ rule<OutputIterator, scheme::utf8_symbol(std::string)> symbol;
 
- rule_type start, term;
- symbols<std::string> primitive0, primitive1, primitive2;
+ symbols<scheme::utf8_symbol> primitive0, primitive1, primitive2;
+ symbols<scheme::utf8_symbol> unary;
     };
 }}
 

Modified: branches/release/libs/spirit/example/scheme/qi/qiexpr_parser.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/qi/qiexpr_parser.hpp (original)
+++ branches/release/libs/spirit/example/scheme/qi/qiexpr_parser.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,10 +1,10 @@
 // Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#if !defined(BOOST_SPIRIT_QIEXPR)
-#define BOOST_SPIRIT_QIEXPR
+#if !defined(BOOST_SPIRIT_QIEXPR_PARSER)
+#define BOOST_SPIRIT_QIEXPR_PARSER
 
 #include <string>
 
@@ -16,10 +16,11 @@
 #include <boost/spirit/include/phoenix_statement.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 
-#include "../utree.hpp"
-#include "../detail/utree_detail3.hpp"
-#include "../utree_operators.hpp"
-#include "../input/string.hpp"
+#include <utree/utree.hpp>
+#include <utree/detail/utree_detail3.hpp>
+#include <utree/operators.hpp>
+#include <input/string.hpp>
+#include <qi/component_names.hpp>
 
 namespace boost { namespace spirit { namespace traits
 {
@@ -27,9 +28,10 @@
 }}}
 
 ///////////////////////////////////////////////////////////////////////////////
-namespace scheme { namespace input
+namespace scheme { namespace qi
 {
     using boost::spirit::ascii::space;
+ using boost::spirit::ascii::char_;
     using boost::spirit::qi::grammar;
     using boost::spirit::qi::rule;
     using boost::spirit::qi::symbols;
@@ -59,7 +61,7 @@
     namespace detail
     {
         ///////////////////////////////////////////////////////////////////////
- // return true if the utree instance represents a list whose first
+ // return true if the utree instance represents a list whose first
         // element is a symbol node equal to the second argument
         inline bool is_list_node(utree const& u, utf8_symbol const& symbol)
         {
@@ -78,7 +80,7 @@
         }
 
         ///////////////////////////////////////////////////////////////////////
- // ensure the given utree instance represents a list whose first
+ // ensure the given utree instance represents a list whose first
         // element is the symbol this function object has been constructed from
         struct make_list_node
         {
@@ -89,21 +91,21 @@
               : symbol(symbol_)
             {}
 
- // If called with one parameter the given node needs to be
+ // If called with one parameter the given node needs to be
             // converted into a list whose first element is the symbol.
             //
- // i.e:
+ // i.e:
             // lit: ("abc") --> (lit "abc")
             void operator()(utree& u) const
             {
                 u.push_front(symbol);
             }
 
- // If called with two parameters we ensure the given node is a
- // (new) list whose first element is the symbol and we append the
+ // If called with two parameters we ensure the given node is a
+ // (new) list whose first element is the symbol and we append the
             // given element to that list.
             //
- // i.e.:
+ // i.e.:
             // >>: (char_), (char_ "abc") --> (>> (char_) (char_ "abc"))
             // >>: (>> (char_ "a")), (char_) --> (>> (char_ "a") (char_))
             void operator()(utree& val, utree const& element) const
@@ -135,72 +137,14 @@
     }
 
     ///////////////////////////////////////////////////////////////////////////
- // a list of names for all supported parser primitives taking no parameters
- static char const* const primitives0[] =
- {
- // character parsers
- "char_"
- , "alnum", "alpha", "blank", "cntrl", "digit", "graph", "print", "punct"
- , "space", "xdigit"
- , "lower", "upper"
-
- // numerics
- , "long_long", "long_", "int_", "short_"
- , "ulong_long", "ulong_", "uint_", "ushort_"
- , "bin", "oct", "hex"
- , "bool_", "true_", "false_"
- , "long_double", "double_", "float_"
-
- // binary
- , "qword", "dword", "word", "byte_"
- , "little_qword", "little_dword", "little_word"
- , "big_qword", "big_dword", "big_word"
-
- // auxiliary
- , "eol", "eoi", "eps"
- , 0
- };
-
- // a list of names for all supported parser primitives taking 1 parameter
- static char const* const primitives1[] =
- {
- // character parsers
- "char_", "lit", "string"
- , 0
- };
-
- // a list of names for all supported parser primitives taking 2 parameter
- static char const* const primitives2[] =
- {
- "char_"
- , 0
- };
-
- // a list of names for all supported parser directives taking 0 parameter
- static char const* const directives0[] =
- {
- // manage skip parser
- "lexeme", "skip", "no_skip"
-
- // case management
- , "no_case"
-
- // auxiliary
- , "omit", "raw"
-
- // encoding
- , "ascii", "standard", "standard_wide", "iso8859_1", "unicode"
- , 0
- };
-
- ///////////////////////////////////////////////////////////////////////////
     template <typename Iterator>
- struct qiexpr : grammar<Iterator, qiexpr_white_space<Iterator>, utree()>
+ struct qiexpr_parser
+ : grammar<Iterator, qiexpr_white_space<Iterator>, utree()>
     {
- typedef typename boost::detail::iterator_traits<Iterator>::value_type
+ typedef typename boost::detail::iterator_traits<Iterator>::value_type
             char_type;
 
- qiexpr() : qiexpr::base_type(start)
+ qiexpr_parser() : qiexpr_parser::base_type(start)
         {
             typedef function<detail::make_list_node> make_list_type;
 
@@ -227,24 +171,24 @@
                 ;
 
             // A ^ B
- permutation =
+ permutation =
                     sequence [ _val = _1 ]
>> *( "^" >> sequence [ make_permutation(_val, _1) ] )
                 ;
 
             // A >> B
- sequence =
+ sequence =
                     unary_term [ _val = _1 ]
>> *( ">>" >> unary_term [ make_sequence(_val, _1) ] )
                 ;
 
             // unary operators
- unary_term =
- '*' >> term [ make_kleene(_val, _1) ]
- | '+' >> term [ make_plus(_val, _1) ]
- | '-' >> term [ make_optional(_val, _1) ]
- | '&' >> term [ make_and_pred(_val, _1) ]
- | '!' >> term [ make_not_pred(_val, _1) ]
+ unary_term =
+ '*' >> alternative [ make_kleene(_val, _1) ]
+ | '+' >> alternative [ make_plus(_val, _1) ]
+ | '-' >> alternative [ make_optional(_val, _1) ]
+ | '&' >> alternative [ make_and_pred(_val, _1) ]
+ | '!' >> alternative [ make_not_pred(_val, _1) ]
                 | term [ _val = _1 ]
                 ;
 
@@ -255,7 +199,7 @@
                 | '(' >> alternative >> ')'
                 ;
 
- // any parser directive
+ // any parser directive
             directive =
                     (directive0 >> '[' >> alternative >> ']')
                     [
@@ -272,7 +216,7 @@
                 ;
 
             // a literal (either 'x' or "abc")
- literal =
+ literal =
                     string_lit [ push_back(_val, _1) ]
                 | string_lit.char_lit [ push_back(_val, _1) ]
                 ;

Copied: branches/release/libs/spirit/example/scheme/scheme/compiler.hpp (from r61299, /trunk/libs/spirit/example/scheme/scheme/compiler.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/scheme/compiler.hpp (original)
+++ branches/release/libs/spirit/example/scheme/scheme/compiler.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -246,6 +246,13 @@
             }
         }
 
+ interpreter(utree const& program, environment* outer = 0)
+ {
+ if (outer == 0)
+ build_basic_environment(env);
+ compile_all(program, env, flist, fragments);
+ }
+
         utree eval(args_type args) const
         {
             return flist.back()(args);

Deleted: branches/release/libs/spirit/example/scheme/scheme_compiler.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/scheme_compiler.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,227 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_SCHEME_COMPILER)
-#define BOOST_SPIRIT_SCHEME_COMPILER
-
-#include <vector>
-#include <map>
-#include <boost/bind.hpp>
-
-#include "scheme_intrinsics.hpp"
-#include "scheme_interpreter.hpp"
-
-namespace scheme
-{
-///////////////////////////////////////////////////////////////////////////////
-// The environment
-///////////////////////////////////////////////////////////////////////////////
- typedef boost::function<actor(actor_list const&)> compiled_function;
-
- class compiler_environment
- {
- public:
-
- environment(environment* parent = 0)
- : outer(parent) {}
-
- template <typename Function>
- void define(std::string const& name, Function const& f)
- {
- // $$$ use exceptions here? $$$
- BOOST_ASSERT(definitions.find(name) == definitions.end());
- definitions[name] = compiled_function(f);
- }
-
- compiled_function* find(std::string const& name)
- {
- std::map<std::string, compiled_function>::iterator
- i = definitions.find(name);
- if (i != definitions.end())
- return &i->second;
- else if (outer != 0)
- return outer->find(name);
- return 0;
- }
-
- environment* parent() const { return outer; }
-
- private:
-
- environment* outer;
- std::map<std::string, compiled_function> definitions;
- };
-
-///////////////////////////////////////////////////////////////////////////////
-// The compiler
-///////////////////////////////////////////////////////////////////////////////
- actor compile(
- utree const& ast, environment& env, actor_list& fragments);
-
- struct external_function : composite<external_function>
- {
- // we must hold f by reference because functions can be recursive
- boost::reference_wrapper<actor const> f;
-
- external_function(actor const& f)
- : f(f) {}
-
- using base_type::operator();
- actor operator()(actor_list const& elements) const
- {
- return actor(lambda_function(f, elements));
- }
- };
-
- struct compiler
- {
- typedef actor result_type;
- environment& env;
- actor_list& fragments;
-
- compiler(environment& env, actor_list& fragments)
- : env(env), fragments(fragments)
- {
- }
-
- actor operator()(nil) const
- {
- return scheme::val(utree());
- }
-
- template <typename T>
- actor operator()(T const& val) const
- {
- return scheme::val(utree(val));
- }
-
- actor operator()(utf8_symbol_range const& str) const
- {
- std::string name(str.begin(), str.end());
- if (compiled_function* mf = env.find(name))
- {
- actor_list flist;
- return (*mf)(flist);
- }
- // $$$ throw? $$$
- BOOST_ASSERT(false);
- return actor();
- }
-
- actor make_lambda(
- std::vector<std::string> const& args,
- utree const& body) const
- {
- environment local_env(&this->env);
- for (std::size_t i = 0; i < args.size(); ++i)
- local_env.define(args[i], boost::bind(arg, i));
- return compile(body, local_env, fragments);
- }
-
- void define_function(
- std::string const& name,
- std::vector<std::string> const& args,
- utree const& body) const
- {
- fragments.push_back(actor());
- actor& f = fragments.back();
- env.define(name, external_function(f));
- f = make_lambda(args, body);
- }
-
- template <typename Iterator>
- actor operator()(boost::iterator_range<Iterator> const& range) const
- {
- std::string name(get_symbol(*range.begin()));
-
- if (name == "define")
- {
- std::string fname;
- std::vector<std::string> args;
-
- Iterator i = range.begin(); ++i;
- if (i->which() == utree_type::list_type)
- {
- // (define (f x) ...body...)
- utree const& decl = *i++;
- Iterator di = decl.begin();
- fname = get_symbol(*di++);
- while (di != decl.end())
- args.push_back(get_symbol(*di++));
- }
- else
- {
- // (define f ...body...)
- fname = get_symbol(*i++);
- }
-
- define_function(fname, args, *i);
- return actor(val(utf8_symbol("<define " + fname + ">")));
- }
-
- if (name == "lambda")
- {
- // (lambda (x) ...body...)
- Iterator i = range.begin(); ++i;
- utree const& arg_names = *i++;
- Iterator ai = arg_names.begin();
- std::vector<std::string> args;
- while (ai != arg_names.end())
- args.push_back(get_symbol(*ai++));
- return make_lambda(args, *i);
- }
-
- if (compiled_function* mf = env.find(name))
- {
- actor_list flist;
- Iterator i = range.begin(); ++i;
- for (; i != range.end(); ++i)
- flist.push_back(compile(*i, env, fragments));
- return (*mf)(flist);
- }
-
- BOOST_ASSERT(false);
- return actor(); // $$$ implement me $$$
- }
-
- static std::string get_symbol(utree const& s)
- {
- utf8_symbol_range symbol = s.as<utf8_symbol_range>();
- return std::string(symbol.begin(), symbol.end());
- }
- };
-
- inline actor compile(
- utree const& ast, environment& env, actor_list& fragments)
- {
- return utree::visit(ast, compiler(env, fragments));
- }
-
- void compile_all(
- utree const& ast,
- environment& env,
- actor_list& results,
- actor_list& fragments)
- {
- BOOST_FOREACH(utree const& program, ast)
- {
- scheme::actor f = compile(program, env, fragments);
- results.push_back(f);
- }
- }
-
- void build_basic_environment(environment& env)
- {
- env.define("if", if_);
- env.define("<", less_than);
- env.define("<=", less_than_equal);
- env.define("+", plus);
- env.define("-", minus);
- env.define("*", times);
- }
-}
-
-#endif

Deleted: branches/release/libs/spirit/example/scheme/scheme_interpreter.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/scheme_interpreter.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,393 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_SCHEME_INTERPRETER)
-#define BOOST_SPIRIT_SCHEME_INTERPRETER
-
-#include <list>
-#include <boost/function.hpp>
-#include <boost/foreach.hpp>
-#include <boost/array.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/preprocessor/repetition/enum_params.hpp>
-
-#define SCHEME_COMPOSITE_LIMIT 10
-
-namespace scheme
-{
-///////////////////////////////////////////////////////////////////////////////
-// The runtime interpreter
-///////////////////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////////////
- // actor
- ///////////////////////////////////////////////////////////////////////////
- struct actor;
-
- typedef std::list<actor> actor_list;
- typedef boost::iterator_range<utree const*> args_type;
- typedef boost::function<utree(args_type args)> actor_function;
-
- struct actor
- {
- typedef utree result_type;
-
- actor()
- : f() {}
-
- actor(actor_function const& f)
- : f(f)
- {
- BOOST_ASSERT(!f.empty());
- }
-
- bool empty() const
- {
- return f.empty();
- }
-
- utree operator()() const
- {
- return f(args_type());
- }
-
- utree operator()(args_type x) const
- {
- return f(x);
- }
-
- template <typename A0>
- utree operator()(A0 const& _0) const
- {
- boost::array<utree, 1> elements;
- elements[0] = _0;
- return f(get_range(elements));
- }
-
- template <typename A0, typename A1>
- utree operator()(A0 const& _0, A1 const& _1) const
- {
- boost::array<utree, 2> elements;
- elements[0] = _0;
- elements[1] = _1;
- return f(get_range(elements));
- }
-
- // More operators
- #include "detail/scheme_function_call.hpp"
-
- actor_function f;
-
- template <std::size_t n>
- static args_type
- get_range(boost::array<utree, n> const& array)
- {
- return args_type(array.begin(), array.end());
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // values
- ///////////////////////////////////////////////////////////////////////////
- struct value_function
- {
- utree val;
- value_function(utree const& val) : val(val) {}
-
- typedef utree result_type;
- utree operator()(args_type /*args*/) const
- {
- return utree(boost::ref(val));
- }
- };
-
- struct value
- {
- typedef actor result_type;
- actor operator()(utree const& val) const
- {
- return actor(value_function(val));
- }
- };
-
- value const val = {};
-
- ///////////////////////////////////////////////////////////////////////////
- // arguments
- ///////////////////////////////////////////////////////////////////////////
- struct argument_function
- {
- std::size_t n;
- argument_function(std::size_t n) : n(n) {}
-
- typedef utree result_type;
- utree operator()(args_type args) const
- {
- return utree(boost::ref(*(args.begin()+n)));
- }
- };
-
- struct argument
- {
- typedef actor result_type;
- actor operator()(std::size_t n) const
- {
- return actor(argument_function(n));
- }
- };
-
- argument const arg = {};
- actor const _1 = arg(0);
- actor const _2 = arg(1);
- actor const _3 = arg(2);
- actor const _4 = arg(3);
- actor const _5 = arg(4);
- actor const _6 = arg(5);
- actor const _7 = arg(6);
- actor const _8 = arg(7);
- actor const _9 = arg(8);
- actor const _10 = arg(10);
-
- ///////////////////////////////////////////////////////////////////////////
- // composite
- ///////////////////////////////////////////////////////////////////////////
- template <typename Derived>
- struct composite
- {
- typedef actor result_type;
- typedef composite<Derived> base_type;
-
- actor operator()(actor_list const& elements) const
- {
- return derived()(elements);
- }
-
- template <typename A0>
- actor operator()(A0 const& _0) const
- {
- actor_list elements;
- elements.push_back(as_function(_0));
- return derived()(elements);
- }
-
- template <typename A0, typename A1>
- actor operator()(A0 const& _0, A1 const& _1) const
- {
- actor_list elements;
- elements.push_back(as_function(_0));
- elements.push_back(as_function(_1));
- return derived()(elements);
- }
-
- // More operators
- #include "detail/scheme_composite_call.hpp"
-
- Derived const& derived() const
- {
- return *static_cast<Derived const*>(this);
- }
-
- template <typename T>
- static actor as_function(T const& val)
- {
- return scheme::val(utree(val));
- }
-
- static actor const& as_function(actor const& f)
- {
- return f;
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // unary_function
- ///////////////////////////////////////////////////////////////////////////
- template <typename Derived>
- struct unary_function
- {
- actor a;
- typedef unary_function<Derived> base_type;
-
- unary_function(actor const& a)
- : a(a)
- {
- BOOST_ASSERT(!a.empty());
- }
-
- typedef utree result_type;
- utree operator()(args_type args) const
- {
- return derived().eval(a(args));
- }
-
- Derived const& derived() const
- {
- return *static_cast<Derived const*>(this);
- }
- };
-
- template <typename Function>
- struct unary_composite : composite<unary_composite<Function> >
- {
- using composite<unary_composite<Function> >::operator();
- actor operator()(actor_list const& elements) const
- {
- return actor(Function(elements.front()));
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // binary_function
- ///////////////////////////////////////////////////////////////////////////
- template <typename Derived>
- struct binary_function
- {
- actor a;
- actor b;
- typedef binary_function<Derived> base_type;
-
- binary_function(actor const& a, actor const& b)
- : a(a), b(b)
- {
- BOOST_ASSERT(!a.empty());
- BOOST_ASSERT(!b.empty());
- }
-
- typedef utree result_type;
- utree operator()(args_type args) const
- {
- return derived().eval(a(args), b(args));
- }
-
- Derived const& derived() const
- {
- return *static_cast<Derived const*>(this);
- }
- };
-
- template <typename Function>
- struct binary_composite : composite<binary_composite<Function> >
- {
- using composite<binary_composite<Function> >::operator();
- actor operator()(actor_list const& elements) const
- {
- actor_list::const_iterator i = elements.begin();
- actor a = *i++;
- actor b = *i;
- return actor(Function(a, b));
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // nary_function
- ///////////////////////////////////////////////////////////////////////////
- template <typename Derived>
- struct nary_function : composite<Derived>
- {
- typedef nary_function<Derived> base_type;
- actor_list elements;
- nary_function(actor_list const& elements)
- : elements(elements)
- {
- BOOST_FOREACH(actor const& element, elements)
- {
- BOOST_ASSERT(!element.empty());
- }
- }
-
- using composite<Derived>::operator();
- utree operator()(args_type args) const
- {
- actor_list::const_iterator i = elements.begin();
- utree result = (*i++)(args);
- boost::iterator_range<actor_list::const_iterator>
- rest(i++, elements.end());
- BOOST_FOREACH(actor const& element, rest)
- {
- if (!derived().eval(result, element(args)))
- break; // allow short-circuit evaluation
- }
- return result;
- }
-
- Derived const& derived() const
- {
- return *static_cast<Derived const*>(this);
- }
- };
-
- template <typename Function>
- struct nary_composite : composite<nary_composite<Function> >
- {
- using composite<nary_composite<Function> >::operator();
- actor operator()(actor_list const& elements) const
- {
- return actor(Function(elements));
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // function
- ///////////////////////////////////////////////////////////////////////////
- struct lambda_function
- {
- actor_list elements;
- // we must hold f by reference because functions can be recursive
- boost::reference_wrapper<actor const> f;
-
- lambda_function(actor const& f, actor_list const& elements)
- : elements(elements), f(f) {}
-
- typedef utree result_type;
- utree operator()(args_type args) const
- {
- if (!elements.empty())
- {
- boost::scoped_array<utree>
- fargs(new utree[elements.size()]);
- std::size_t i = 0;
- BOOST_FOREACH(actor const& element, elements)
- {
- fargs[i++] = element(args);
- }
- utree const* fi = fargs.get();
- return f.get()(args_type(fi, fi+elements.size()));
- }
- else
- {
- return f.get()();
- }
- }
- };
-
- struct function : composite<function>
- {
- actor f;
-
- function() : f() {}
- function(actor const& f) : f(f) {}
-
- using base_type::operator();
- actor operator()(actor_list const& elements) const
- {
- return actor(call_function(f, elements));
- }
-
- function& operator=(function const& other)
- {
- f = other.f;
- return *this;
- }
-
- function& operator=(actor const& f_)
- {
- f = f_;
- return *this;
- }
- };
-}
-
-#endif

Deleted: branches/release/libs/spirit/example/scheme/scheme_intrinsics.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/scheme_intrinsics.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,154 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_SCHEME_INTRINSICS)
-#define BOOST_SPIRIT_SCHEME_INTRINSICS
-
-#include "scheme_interpreter.hpp"
-
-namespace scheme
-{
- ///////////////////////////////////////////////////////////////////////////
- // if
- ///////////////////////////////////////////////////////////////////////////
- struct if_function
- {
- actor cond;
- actor then;
- actor else_;
- if_function(
- actor const& cond, actor const& then, actor const& else_)
- : cond(cond), then(then), else_(else_)
- {
- BOOST_ASSERT(!cond.empty());
- BOOST_ASSERT(!then.empty());
- BOOST_ASSERT(!else_.empty());
- }
-
- typedef utree result_type;
- utree operator()(args_type args) const
- {
- return cond(args).as<bool>() ? then(args) : else_(args);
- }
- };
-
- struct if_composite : composite<if_composite>
- {
- using base_type::operator();
- actor operator()(actor_list const& elements) const
- {
- actor_list::const_iterator i = elements.begin();
- actor if_ = *i++;
- actor then = *i++;
- actor else_ = *i;
- return actor(if_function(if_, then, else_));
- }
- };
-
- if_composite const if_ = if_composite();
-
- ///////////////////////////////////////////////////////////////////////////
- // less_than
- ///////////////////////////////////////////////////////////////////////////
- struct less_than_function
- : binary_function<less_than_function>
- {
- less_than_function(actor const& a, actor const& b)
- : base_type(a, b) {}
-
- typedef utree result_type;
- utree eval(utree const& a, utree const& b) const
- {
- return a < b;
- }
- };
-
- struct less_than_composite
- : binary_composite<less_than_function> {};
-
- less_than_composite const less_than
- = less_than_composite();
- less_than_composite const lt = less_than; // synonym
-
- ///////////////////////////////////////////////////////////////////////////
- // less_than_equal
- ///////////////////////////////////////////////////////////////////////////
- struct less_than_equal_function
- : binary_function<less_than_equal_function>
- {
- less_than_equal_function(actor const& a, actor const& b)
- : base_type(a, b) {}
-
- typedef utree result_type;
- utree eval(utree const& a, utree const& b) const
- {
- return a <= b;
- }
- };
-
- struct less_than_equal_composite
- : binary_composite<less_than_equal_function> {};
-
- less_than_equal_composite const less_than_equal
- = less_than_equal_composite();
- less_than_equal_composite const lte = less_than_equal; // synonym
-
- ///////////////////////////////////////////////////////////////////////////
- // plus
- ///////////////////////////////////////////////////////////////////////////
- struct plus_function : nary_function<plus_function>
- {
- plus_function(actor_list const& elements)
- : base_type(elements) {}
-
- bool eval(utree& result, utree const& element) const
- {
- result = result + element;
- return true;
- }
- };
-
- struct plus_composite : nary_composite<plus_function> {};
- plus_composite const plus = plus_composite();
-
- ///////////////////////////////////////////////////////////////////////////
- // minus
- ///////////////////////////////////////////////////////////////////////////
- struct minus_function : nary_function<minus_function>
- {
- minus_function(actor_list const& elements)
- : base_type(elements) {}
-
- bool eval(utree& result, utree const& element) const
- {
- result = result - element;
- return true;
- }
- };
-
- struct minus_composite : nary_composite<minus_function> {};
- minus_composite const minus = minus_composite();
-
- ///////////////////////////////////////////////////////////////////////////
- // times
- ///////////////////////////////////////////////////////////////////////////
- struct times_function : nary_function<times_function>
- {
- times_function(actor_list const& elements)
- : base_type(elements) {}
-
- bool eval(utree& result, utree const& element) const
- {
- result = result * element;
- return true;
- }
- };
-
- struct times_composite : nary_composite<times_function> {};
- times_composite const times = times_composite();
-}
-
-#endif

Copied: branches/release/libs/spirit/example/scheme/support/line_pos_iterator.hpp (from r61331, /trunk/libs/spirit/example/scheme/support/line_pos_iterator.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/support/line_pos_iterator.hpp (original)
+++ branches/release/libs/spirit/example/scheme/support/line_pos_iterator.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -16,7 +16,9 @@
     // line_pos_iterator: a lighweight line position iterator. This iterator
     // adapter only stores the current line number, nothing else. Unlike
     // spirit classic's position_iterator, it does not store the column
- // number and does not need an end iterator.
+ // number and does not need an end iterator. The current column can be
+ // computed, if needed. Some utilities line oriented are provided
+ // including computation of the current column.
     ///////////////////////////////////////////////////////////////////////////
     template <typename Iterator>
     class line_pos_iterator
@@ -30,12 +32,12 @@
     public:
 
         line_pos_iterator()
- : line_pos_iterator::iterator_adaptor_()
- line(0), prev(0) {}
+ : line_pos_iterator::iterator_adaptor_(),
+ line(1), prev(0) {}
 
         explicit line_pos_iterator(Iterator base)
- : node_iter::iterator_adaptor_(base)
- line(0), prev(0) {}
+ : line_pos_iterator::iterator_adaptor_(base),
+ line(1), prev(0) {}
 
         std::size_t position() const
         {
@@ -47,7 +49,8 @@
         friend class boost::iterator_core_access;
         void increment()
         {
- typename Iterator::reference ref = *(this->base());
+ typename std::iterator_traits<Iterator>::reference
+ ref = *(this->base());
             switch (ref)
             {
                 case '\r':
@@ -62,16 +65,30 @@
                     break;
             }
             prev = ref;
+ ++this->base_reference();
         }
 
         std::size_t line;
- typename Iterator::value_type prev;
+ typename std::iterator_traits<Iterator>::value_type prev;
     };
 
     ///////////////////////////////////////////////////////////////////////////
     // Utilities
     ///////////////////////////////////////////////////////////////////////////
 
+ // Get the line position. Returns -1 if Iterator is not a line_pos_iterator.
+ template <typename Iterator>
+ inline int get_line(Iterator i)
+ {
+ return -1;
+ }
+
+ template <typename Iterator>
+ inline int get_line(line_pos_iterator<Iterator> i)
+ {
+ return i.position();
+ }
+
     // Get an iterator to the beginning of the line. Applicable to any
     // iterator.
     template <typename Iterator>
@@ -94,7 +111,7 @@
     // Get the iterator range containing the current line. Applicable to
     // any iterator.
     template <typename Iterator>
- inline iterator_range<Iterator>
+ inline boost::iterator_range<Iterator>
     get_current_line(
         Iterator lower_bound, Iterator current, Iterator upper_bound)
     {
@@ -102,7 +119,29 @@
         Iterator last = get_line_start(current, upper_bound);
         if (last == current)
             last = upper_bound;
- return iterator_range<Iterator>(first, last);
+ return boost::iterator_range<Iterator>(first, last);
+ }
+
+ // Get the current column. Applicable to any iterator.
+ template <typename Iterator>
+ inline std::size_t
+ get_column(
+ Iterator lower_bound, Iterator current, int tabs = 4)
+ {
+ std::size_t column = 1;
+ Iterator first = get_line_start(lower_bound, current);
+ for (Iterator i = first; i != current; ++i)
+ {
+ switch (*i)
+ {
+ case '\t':
+ column += tabs - (column - 1) % tabs;
+ break;
+ default:
+ ++column;
+ }
+ }
+ return column;
     }
 }
 

Copied: branches/release/libs/spirit/example/scheme/test/Jamfile (from r61292, /trunk/libs/spirit/example/scheme/test/Jamfile)
==============================================================================
--- /trunk/libs/spirit/example/scheme/test/Jamfile (original)
+++ branches/release/libs/spirit/example/scheme/test/Jamfile 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -5,7 +5,9 @@
 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 #==============================================================================
 project spirit-scheme-tests
- : requirements <toolset>gcc:<c++-template-depth>300
+ : requirements
+ <toolset>gcc:<c++-template-depth>300
+ <include>../
     :
     :
     ;
@@ -14,14 +16,33 @@
 import testing ;
 
 {
- test-suite spirit_v2 :
+ test-suite utree :
 
- # run Qi tests
- [ run utree_test.cpp : : : : ]
+ # run utree tests
+ [ run utree/utree_test.cpp : : : : ]
 
     ;
 }
 
+exe sexpr_input_test : sexpr/sexpr_input_test.cpp ;
+exe sexpr_output_test : sexpr/sexpr_output_test.cpp ;
+
+exe parse_qi_test
+ : parse_qiexpr/generate_sexpr_to_ostream.cpp
+ parse_qiexpr/parse_qi_test.cpp
+ parse_qiexpr/parse_qiexpr.cpp
+ ;
+
+exe generate_qi_test
+ : parse_qiexpr/parse_qiexpr.cpp
+ generate_qiexpr/generate_qi_test.cpp
+ generate_qiexpr/generate_qiexpr.cpp
+ ;
+
+exe scheme_test1 : scheme/scheme_test1.cpp ;
+exe scheme_test2 : scheme/scheme_test2.cpp ;
+exe scheme_test3 : scheme/scheme_test3.cpp ;
+
 
 
 

Deleted: branches/release/libs/spirit/example/scheme/test/out.txt
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/out.txt 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,2 +0,0 @@
-success: (123.45 true false 255 63 "this is a € string" "Τη γλώσσα μου έδωσαν ελληνική" b0123456789abcdef123456789abcdef (92 ("another string" apple Sîne)))
-

Modified: branches/release/libs/spirit/example/scheme/test/parse_qiexpr/generate_sexpr_to_ostream.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/parse_qiexpr/generate_sexpr_to_ostream.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/parse_qiexpr/generate_sexpr_to_ostream.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -3,8 +3,8 @@
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#include "../../output/generate_sexpr.hpp"
-#include "../../output/generate_sexpr_impl.hpp"
+#include <output/generate_sexpr.hpp>
+#include <output/generate_sexpr_impl.hpp>
 
 #include <fstream>
 

Modified: branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qi_test.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qi_test.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qi_test.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -11,9 +11,9 @@
 #include <fstream>
 #include <iterator>
 
-#include "../../utree.hpp"
-#include "../../qi/parse_qiexpr.hpp"
-#include "../../output/generate_sexpr.hpp"
+#include <utree/utree.hpp>
+#include <qi/parse_qiexpr.hpp>
+#include <output/generate_sexpr.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 // Main program

Modified: branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qiexpr.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qiexpr.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qiexpr.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -3,12 +3,12 @@
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#include <fstream>
+#include <string>
 
-#include "../../qi/parse_qiexpr.hpp"
-#include "../../qi/parse_qiexpr_impl.hpp"
+#include <qi/parse_qiexpr.hpp>
+#include <qi/parse_qiexpr_impl.hpp>
 
-// explicit template instantiation for the function parse_sexpr
+// explicit template instantiation for the function parse_qiexpr
 namespace scheme { namespace input
 {
     template bool parse_qiexpr(std::string const&, utree& result);

Deleted: branches/release/libs/spirit/example/scheme/test/scheme.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/scheme.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,105 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#include <boost/config/warning_disable.hpp>
-
-#include "../input/sexpr.hpp"
-#include "../input/parse_sexpr_impl.hpp"
-#include "../scheme_compiler.hpp"
-#include "../utree_io.hpp"
-#include <iostream>
-#include <fstream>
-
-inline std::ostream& println(std::ostream& out, scheme::utree const& val)
-{
- out << val << std::endl;
- return out;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Main program
-///////////////////////////////////////////////////////////////////////////////
-int main(int argc, char **argv)
-{
- { // testing the c++ side
-
- using scheme::if_;
- using scheme::plus;
- using scheme::times;
- using scheme::minus;
- using scheme::lte;
- using scheme::_1;
- using scheme::_2;
- using scheme::function;
-
- std::cout << "result: " << plus(11, 22, 33)() << std::endl;
- std::cout << "result: " << plus(11, 22, _1)(33) << std::endl;
- std::cout << "result: " << plus(11, _1, _2)(22, 33) << std::endl;
-
- function factorial;
- factorial = if_(lte(_1, 0), 1, times(_1, factorial(minus(_1, 1))));
-
- std::cout << "result: " << factorial(_1) (10) << std::endl;
- }
-
- char const* filename = NULL;
- if (argc > 1)
- {
- filename = argv[1];
- }
- else
- {
- std::cerr << "Error: No input file provided." << std::endl;
- return 1;
- }
-
- std::ifstream in(filename, std::ios_base::in);
-
- if (!in)
- {
- std::cerr << "Error: Could not open input file: "
- << filename << std::endl;
- return 1;
- }
-
- // Ignore the BOM marking the beginning of a UTF-8 file in Windows
- char c = in.peek();
- if (c == '\xef')
- {
- char s[3];
- in >> s[0] >> s[1] >> s[2];
- s[3] = '\0';
- if (s != std::string("\xef\xbb\xbf"))
- {
- std::cerr << "Error: Unexpected characters from input file: "
- << filename << std::endl;
- return 1;
- }
- }
-
- scheme::utree program;
- if (scheme::input::parse_sexpr_list(in, program))
- {
- std::cout << "success: " << std::endl;
- scheme::environment env;
- scheme::build_basic_environment(env);
- scheme::actor_list fragments;
- scheme::actor_list flist;
- compile_all(program, env, flist, fragments);
- BOOST_FOREACH(scheme::actor const& f, flist)
- {
- std::cout << "result: " << f() << std::endl;
- }
- }
- else
- {
- std::cout << "parse error" << std::endl;
- }
-
- return 0;
-}
-
-

Copied: branches/release/libs/spirit/example/scheme/test/scheme/scheme_test1.cpp (from r61285, /trunk/libs/spirit/example/scheme/test/scheme/scheme_test1.cpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/test/scheme/scheme_test1.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/scheme/scheme_test1.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -6,9 +6,9 @@
 =============================================================================*/
 #include <boost/config/warning_disable.hpp>
 
-#include "../../input/parse_sexpr_impl.hpp"
-#include "../../scheme_compiler.hpp"
-#include "../../utree_io.hpp"
+#include <input/parse_sexpr_impl.hpp>
+#include <scheme/compiler.hpp>
+#include <utree/io.hpp>
 #include <iostream>
 #include <fstream>
 
@@ -75,14 +75,7 @@
     }
 
     scheme::utree program;
- if (scheme::input::parse_sexpr_list(in, program))
- {
- std::cout << "success: " << std::endl;
- scheme::environment env;
- scheme::build_basic_environment(env);
- scheme::actor_list fragments;
- scheme::actor_list flist;
- compile_all(program, env, flist, fragments);
+ BOOST_TEST(scheme::input::parse_sexpr_list(in, program, filename));
 
         scheme::actor_list::iterator i = flist.begin();
 

Copied: branches/release/libs/spirit/example/scheme/test/scheme/scheme_test2.cpp (from r61285, /trunk/libs/spirit/example/scheme/test/scheme/scheme_test2.cpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/test/scheme/scheme_test2.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/scheme/scheme_test2.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -6,8 +6,8 @@
 =============================================================================*/
 #include <boost/config/warning_disable.hpp>
 
-#include "../../scheme_compiler.hpp"
-#include "../../utree_io.hpp"
+#include <scheme/compiler.hpp>
+#include <utree/io.hpp>
 #include <iostream>
 #include <fstream>
 

Copied: branches/release/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp (from r61285, /trunk/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/scheme/scheme_test3.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -6,8 +6,10 @@
 =============================================================================*/
 #include <boost/config/warning_disable.hpp>
 
-#include "../../scheme_compiler.hpp"
-#include "../../utree_io.hpp"
+#include <input/sexpr.hpp>
+#include <input/parse_sexpr_impl.hpp>
+#include <scheme/compiler.hpp>
+#include <utree/io.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 // Main program
@@ -15,7 +17,6 @@
 int main()
 {
     using scheme::interpreter;
- using scheme::_1;
     using scheme::utree;
 
     utree src = "(define (factorial n) (if (<= n 0) 1 (* n (factorial (- n 1)))))";

Deleted: branches/release/libs/spirit/example/scheme/test/scheme_test.scm
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/scheme_test.scm 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,24 +0,0 @@
-; These tests demostrate the functionality of the scheme
-; compiler/interpreter
-
-(define (dbl x) (+ x x))
-
-(define len 123)
-
-(dbl len) ; 246
-
-; The hello-world for interpreters ;-)
-(define (factorial n)
- (if (<= n 0) 1
- (* n (factorial (- n 1)))))
-
-(factorial 10) ; 3628800
-
-; Fibonacci using lambda
-(define fib
- (lambda (n)
- (if (< n 2)
- n
- (+ (fib (- n 1)) (fib (- n 2))))))
-
-(fib 10) ; 55
\ No newline at end of file

Copied: branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_input_test.cpp (from r61285, /trunk/libs/spirit/example/scheme/test/sexpr/sexpr_input_test.cpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/test/sexpr/sexpr_input_test.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_input_test.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -6,9 +6,9 @@
 =============================================================================*/
 #include <boost/config/warning_disable.hpp>
 
-#include "../../input/sexpr.hpp"
-#include "../../input/parse_sexpr_impl.hpp"
-#include "../../utree_io.hpp"
+#include <input/sexpr.hpp>
+#include <input/parse_sexpr_impl.hpp>
+#include <utree/io.hpp>
 #include <iostream>
 #include <fstream>
 

Copied: branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_output_test.cpp (from r61285, /trunk/libs/spirit/example/scheme/test/sexpr/sexpr_output_test.cpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/test/sexpr/sexpr_output_test.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/sexpr/sexpr_output_test.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -11,8 +11,8 @@
 #include <fstream>
 #include <iterator>
 
-#include "../../input/parse_sexpr_impl.hpp"
-#include "../../output/generate_sexpr_impl.hpp"
+#include <input/parse_sexpr_impl.hpp>
+#include <output/generate_sexpr_impl.hpp>
 
 namespace client
 {

Deleted: branches/release/libs/spirit/example/scheme/test/sexpr_input_test.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/sexpr_input_test.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,75 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#include <boost/config/warning_disable.hpp>
-
-#include "../input/sexpr.hpp"
-#include "../input/parse_sexpr_impl.hpp"
-#include <iostream>
-#include <fstream>
-
-inline std::ostream& println(std::ostream& out, scheme::utree const& val)
-{
- out << val << std::endl;
- return out;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Main program
-///////////////////////////////////////////////////////////////////////////////
-int main(int argc, char **argv)
-{
- char const* filename = NULL;
- if (argc > 1)
- {
- filename = argv[1];
- }
- else
- {
- std::cerr << "Error: No input file provided." << std::endl;
- return 1;
- }
-
- std::ifstream in(filename, std::ios_base::in);
-
- if (!in)
- {
- std::cerr << "Error: Could not open input file: "
- << filename << std::endl;
- return 1;
- }
-
- // Ignore the BOM marking the beginning of a UTF-8 file in Windows
- char c = in.peek();
- if (c == '\xef')
- {
- char s[3];
- in >> s[0] >> s[1] >> s[2];
- s[3] = '\0';
- if (s != std::string("\xef\xbb\xbf"))
- {
- std::cerr << "Error: Unexpected characters from input file: "
- << filename << std::endl;
- return 1;
- }
- }
-
- scheme::utree result;
- if (scheme::input::parse_sexpr(in, result))
- {
- std::cout << "success: ";
- println(std::cout, result);
- std::cout << std::endl;
- }
- else
- {
- std::cout << "parse error" << std::endl;
- }
-
- return 0;
-}
-
-

Deleted: branches/release/libs/spirit/example/scheme/test/sexpr_output_test.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/sexpr_output_test.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,105 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/config/warning_disable.hpp>
-
-#define BOOST_SPIRIT_UNICODE
-
-#include <iostream>
-#include <fstream>
-#include <iterator>
-
-#include "../input/parse_sexpr_impl.hpp"
-#include "../output/generate_sexpr_impl.hpp"
-
-namespace client
-{
- bool parse_sexpr_from_file(char const* filename, scheme::utree& result)
- {
- std::ifstream in(filename, std::ios_base::in);
-
- if (!in)
- {
- std::cerr << "Error: Could not open input file: "
- << filename << std::endl;
- exit(-1);
- }
-
- // Ignore the BOM marking the beginning of a UTF-8 file in Windows
- char c = in.peek();
- if (c == '\xef')
- {
- char s[3];
- in >> s[0] >> s[1] >> s[2];
- s[3] = '\0';
- if (s != std::string("\xef\xbb\xbf"))
- {
- std::cerr << "Error: Unexpected characters from input file: "
- << filename << std::endl;
- exit(-1);
- }
- }
-
- return scheme::input::parse_sexpr(in, result);
- }
-
- bool generate_sexpr_to_file(scheme::utree const& tree, char const* filename)
- {
- std::ofstream out(filename);
-
- if (!out)
- {
- std::cerr << "Error: Could not open output file: "
- << filename << std::endl;
- exit(-1);
- }
-
- return scheme::output::generate_sexpr(out, tree);
- }
-}
-
-int main(int argc, char **argv)
-{
- char const* filename_in = NULL;
- if (argc > 1)
- {
- filename_in = argv[1];
- }
- else
- {
- std::cerr << "Error: No input file provided." << std::endl;
- return -1;
- }
-
- char const* filename_out = NULL;
- if (argc > 2)
- {
- filename_out = argv[2];
- }
- else
- {
- std::cerr << "Error: No output file provided." << std::endl;
- return -1;
- }
-
- scheme::utree result;
- if (client::parse_sexpr_from_file(filename_in, result))
- {
- if (client::generate_sexpr_to_file(result, filename_out))
- {
- std::cout << "success!" << std::endl;
- }
- else
- {
- std::cout << "generate error" << std::endl;
- }
- }
- else
- {
- std::cout << "parse error" << std::endl;
- }
-
- return 0;
-}

Deleted: branches/release/libs/spirit/example/scheme/test/sexpr_test.txt
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/sexpr_test.txt 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,13 +0,0 @@
-(
- 123.45
- true
- false
- 0xFF
- 077
- "this is a \u20AC string" ; A UTF-8 string
- "Τη γλώσσα μου έδωσαν ελληνική" ; Another UTF-8 string
- b0123456789ABCDEF0123456789abcdef ; A binary stream
- (
- 92 ("another string" apple Sîne)
- )
-)
\ No newline at end of file

Copied: branches/release/libs/spirit/example/scheme/test/utree/utree_test.cpp (from r61299, /trunk/libs/spirit/example/scheme/test/utree/utree_test.cpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/test/utree/utree_test.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/utree/utree_test.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -229,5 +229,24 @@
         BOOST_TEST(~utree(456) == utree(~456));
     }
 
+ { // test reference iterator
+ utree val;
+ val.push_back(1);
+ val.push_back(2);
+ val.push_back(3);
+ val.push_back(4);
+ check(val, "( 1 2 3 4 )");
+
+ utree::ref_iterator b = val.ref_begin();
+ utree::ref_iterator e = val.ref_end();
+
+ utree ref(boost::make_iterator_range(b, e));
+ BOOST_TEST(ref[0] == utree(1));
+ BOOST_TEST(ref[1] == utree(2));
+ BOOST_TEST(ref[2] == utree(3));
+ BOOST_TEST(ref[3] == utree(4));
+ check(ref, "( 1 2 3 4 )");
+ }
+
     return boost::report_errors();
 }

Deleted: branches/release/libs/spirit/example/scheme/test/utree_test.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/utree_test.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,233 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-
-#include <boost/config/warning_disable.hpp>
-
-#include "../utree.hpp"
-#include "../utree_operators.hpp"
-#include "../utree_io.hpp"
-#include <iostream>
-
-inline std::ostream& println(std::ostream& out, scheme::utree const& val)
-{
- if (val.which() == scheme::utree_type::list_type)
- out << "size:" << val.size() << " ";
- out << val << std::endl;
- return out;
-}
-
-int main()
-{
- using scheme::utree;
-
- {
- // test the size
- std::cout << "size of utree is: "
- << sizeof(scheme::utree) << " bytes" << std::endl;
- }
-
- {
- utree val;
- println(std::cout, val);
- }
-
- {
- utree val(true);
- println(std::cout, val);
- }
-
- {
- utree val(123);
- println(std::cout, val);
- }
-
- {
- utree val(123.456);
- println(std::cout, val);
- }
-
- {
- utree val("Hello, World");
- println(std::cout, val);
- utree val2;
- val2 = val;
- println(std::cout, val2);
- utree val3("Hello, World. Chuckie is back!!!");
- val = val3;
- println(std::cout, val);
-
- utree val4("Apple");
- utree val5("Apple");
- BOOST_ASSERT(val4 == val5);
-
- utree val6("ApplePie");
- BOOST_ASSERT(val4 < val6);
- }
-
- {
- utree val;
- val.push_back(123);
- val.push_back("Chuckie");
- BOOST_ASSERT(val.size() == 2);
- utree val2;
- val2.push_back(123.456);
- val2.push_back("Mah Doggie");
- val.push_back(val2);
- BOOST_ASSERT(val.size() == 3);
- println(std::cout, val);
- println(std::cout, val.front());
-
- utree val3;
- val3.swap(val);
- BOOST_ASSERT(val3.size() == 3);
- println(std::cout, val);
- val3.swap(val);
- println(std::cout, val);
- val.push_back("another string");
- BOOST_ASSERT(val.size() == 4);
- println(std::cout, val);
- val.pop_front();
- println(std::cout, val);
- utree::iterator i = val.begin();
- ++++i;
- val.insert(i, "Right in the middle");
- BOOST_ASSERT(val.size() == 4);
- println(std::cout, val);
- val.pop_back();
- println(std::cout, val);
- BOOST_ASSERT(val.size() == 3);
- utree::iterator it = val.end(); --it;
- val.erase(it);
- println(std::cout, val);
- BOOST_ASSERT(val.size() == 2);
-
- val.insert(val.begin(), val2.begin(), val2.end());
- println(std::cout, val);
- BOOST_ASSERT(val.size() == 4);
- }
-
- {
- utree val;
- val.insert(val.end(), 123);
- val.insert(val.end(), "Mia");
- val.insert(val.end(), "Chuckie");
- val.insert(val.end(), "Poly");
- val.insert(val.end(), "Mochi");
- println(std::cout, val);
- }
-
- {
- utree a, b;
- BOOST_ASSERT(a == b);
- a = 123;
- BOOST_ASSERT(a != b);
- b = 123;
- BOOST_ASSERT(a == b);
- a = 100.00;
- BOOST_ASSERT(a < b);
-
- b = a = utree();
- BOOST_ASSERT(a == b);
- a.push_back(1);
- a.push_back("two");
- a.push_back(3.0);
- b.push_back(1);
- b.push_back("two");
- b.push_back(3.0);
- BOOST_ASSERT(a == b);
- b.push_back(4);
- BOOST_ASSERT(a != b);
- BOOST_ASSERT(a < b);
- }
-
- {
- utree a;
- a.push_back(1);
- a.push_back(2);
- a.push_back(3);
- a.push_back(4);
- a.push_back(5);
- a.push_back(6);
- a.push_back(7);
- a.push_back(8);
- a.push_back(9);
- a.push_back(10);
- a.push_back(11);
- a.push_back(12);
-
- BOOST_ASSERT(a[0] == utree(1));
- BOOST_ASSERT(a[1] == utree(2));
- BOOST_ASSERT(a[2] == utree(3));
- BOOST_ASSERT(a[3] == utree(4));
- BOOST_ASSERT(a[4] == utree(5));
- BOOST_ASSERT(a[5] == utree(6));
- BOOST_ASSERT(a[6] == utree(7));
- BOOST_ASSERT(a[7] == utree(8));
- BOOST_ASSERT(a[8] == utree(9));
- BOOST_ASSERT(a[9] == utree(10));
- BOOST_ASSERT(a[10] == utree(11));
- BOOST_ASSERT(a[11] == utree(12));
- }
-
- { // test references
- utree val(123);
- utree ref(boost::ref(val));
- println(std::cout, ref);
- BOOST_ASSERT(ref == utree(123));
-
- val.clear();
- val.push_back(1);
- val.push_back(2);
- val.push_back(3);
- val.push_back(4);
- println(std::cout, ref);
- BOOST_ASSERT(ref[0] == utree(1));
- BOOST_ASSERT(ref[1] == utree(2));
- BOOST_ASSERT(ref[2] == utree(3));
- BOOST_ASSERT(ref[3] == utree(4));
- }
-
- { // put it in an array
-
- utree vals[] = {
- utree(123),
- utree("Hello, World"),
- utree(123.456)
- };
-
- println(std::cout, vals[0]);
- println(std::cout, vals[1]);
- println(std::cout, vals[2]);
- }
-
- { // operators
-
- BOOST_ASSERT((utree(true) && utree(true)) == utree(true));
- BOOST_ASSERT((utree(true) || utree(false)) == utree(true));
- BOOST_ASSERT(!utree(true) == utree(false));
-
- BOOST_ASSERT((utree(456) + utree(123)) == utree(456 + 123));
- BOOST_ASSERT((utree(456) + utree(123.456)) == utree(456 + 123.456));
- BOOST_ASSERT((utree(456) - utree(123)) == utree(456 - 123));
- BOOST_ASSERT((utree(456) - utree(123.456)) == utree(456 - 123.456));
- BOOST_ASSERT((utree(456) * utree(123)) == utree(456 * 123));
- BOOST_ASSERT((utree(456) * utree(123.456)) == utree(456 * 123.456));
- BOOST_ASSERT((utree(456) / utree(123)) == utree(456 / 123));
- BOOST_ASSERT((utree(456) / utree(123.456)) == utree(456 / 123.456));
- BOOST_ASSERT((utree(456) % utree(123)) == utree(456 % 123));
- BOOST_ASSERT(-utree(456) == utree(-456));
-
- BOOST_ASSERT((utree(456) & utree(123)) == utree(456 & 123));
- BOOST_ASSERT((utree(456) | utree(123)) == utree(456 | 123));
- BOOST_ASSERT((utree(456) ^ utree(123)) == utree(456 ^ 123));
- BOOST_ASSERT((utree(456) << utree(3)) == utree(456 << 3));
- BOOST_ASSERT((utree(456) >> utree(2)) == utree(456 >> 2));
- BOOST_ASSERT(~utree(456) == utree(~456));
- }
-
- return 0;
-}

Modified: branches/release/libs/spirit/example/scheme/todo.txt
==============================================================================
--- branches/release/libs/spirit/example/scheme/todo.txt (original)
+++ branches/release/libs/spirit/example/scheme/todo.txt 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,2 +1,3 @@
 Sexpr:
-- allow sheme-ish #t and #f
\ No newline at end of file
+- allow scheme-ish #t and #f
+- write parser and generator for binary on disk representation of sexpr

Deleted: branches/release/libs/spirit/example/scheme/utree.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/utree.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,299 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_UTREE)
-#define BOOST_SPIRIT_UTREE
-
-#include <cstddef>
-#include <algorithm>
-#include <string>
-#include <ostream>
-
-#include <boost/assert.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/iterator/iterator_facade.hpp>
-#include <boost/range/iterator_range.hpp>
-#include <boost/ref.hpp>
-#include "detail/utree_detail1.hpp"
-
-#if defined(BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4804)
-# pragma warning(disable: 4805)
-# pragma warning(disable: 4244)
-#endif
-
-namespace scheme
-{
- ///////////////////////////////////////////////////////////////////////////
- // Our utree can store these types. This enum tells us what type
- // of data is stored in utree's discriminated union.
- ///////////////////////////////////////////////////////////////////////////
- struct utree_type
- {
- enum info
- {
- nil_type,
- bool_type,
- int_type,
- double_type,
- string_type,
- symbol_type,
- binary_type,
- list_type,
- reference_type
- };
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // The nil type
- ///////////////////////////////////////////////////////////////////////////
- struct nil {};
-
- ///////////////////////////////////////////////////////////////////////////
- // A typed string with parametric Base storage. The storage can be any
- // range or (stl container) of chars.
- ///////////////////////////////////////////////////////////////////////////
- template <typename Base, utree_type::info type_>
- struct basic_string : Base
- {
- static utree_type::info const type = type_;
-
- basic_string()
- : Base() {}
-
- basic_string(Base const& base)
- : Base(base) {}
-
- template <typename Iterator>
- basic_string(Iterator bits, std::size_t len)
- : Base(bits, bits + len) {}
-
- template <typename Iterator>
- basic_string(Iterator first, Iterator last)
- : Base(first, last) {}
-
- basic_string& operator=(basic_string const& other)
- {
- Base::operator=(other);
- return *this;
- }
-
- basic_string& operator=(Base const& other)
- {
- Base::operator=(other);
- return *this;
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // Binary string
- ///////////////////////////////////////////////////////////////////////////
- typedef basic_string<
- boost::iterator_range<char const*>,
- utree_type::binary_type>
- binary_range;
-
- typedef basic_string<
- std::string,
- utree_type::binary_type>
- binary_string;
-
- ///////////////////////////////////////////////////////////////////////////
- // Our UTF-8 string
- ///////////////////////////////////////////////////////////////////////////
- typedef basic_string<
- boost::iterator_range<char const*>,
- utree_type::string_type>
- utf8_string_range;
-
- typedef basic_string<
- std::string,
- utree_type::string_type>
- utf8_string;
-
- ///////////////////////////////////////////////////////////////////////////
- // Our UTF-8 symbol (for identifiers)
- ///////////////////////////////////////////////////////////////////////////
- typedef basic_string<
- boost::iterator_range<char const*>,
- utree_type::symbol_type>
- utf8_symbol_range;
-
- typedef basic_string<
- std::string,
- utree_type::symbol_type>
- utf8_symbol;
-
- ///////////////////////////////////////////////////////////////////////////
- // The main utree (Universal Tree) class
- // The utree is a hierarchical, dynamic type that can store:
- // - a nil
- // - a bool
- // - an integer
- // - a double
- // - a string
- // - a symbol (identifier)
- // - binary data
- // - a (doubly linked) list of utree
- // - a reference to a utree
- //
- // The utree has minimal memory footprint. The data structure size is
- // 16 bytes on a 32-bit platform. Being a container of itself, it can
- // represent tree structures.
- ///////////////////////////////////////////////////////////////////////////
- class utree
- {
- public:
-
- typedef utree value_type;
- typedef detail::list::node_iterator<utree> iterator;
- typedef detail::list::node_iterator<utree const> const_iterator;
- typedef utree& reference;
- typedef utree const& const_reference;
- typedef std::ptrdiff_t difference_type;
- typedef std::size_t size_type;
-
- typedef boost::iterator_range<iterator> range;
- typedef boost::iterator_range<const_iterator> const_range;
-
- utree();
- utree(bool b);
- utree(unsigned int i);
- utree(int i);
- utree(double d);
- utree(char const* str);
- utree(char const* str, std::size_t len);
- utree(std::string const& str);
- utree(boost::reference_wrapper<utree> ref);
-
- template <typename Base, utree_type::info type_>
- utree(basic_string<Base, type_> const& bin);
-
- utree(utree const& other);
- ~utree();
-
- utree& operator=(utree const& other);
- utree& operator=(bool b);
- utree& operator=(unsigned int i);
- utree& operator=(int i);
- utree& operator=(double d);
- utree& operator=(char const* s);
- utree& operator=(std::string const& s);
- utree& operator=(boost::reference_wrapper<utree> ref);
-
- template <typename Base, utree_type::info type_>
- utree& operator=(basic_string<Base, type_> const& bin);
-
- template <typename F>
- typename F::result_type
- static visit(utree const& x, F f);
-
- template <typename F>
- typename F::result_type
- static visit(utree& x, F f);
-
- template <typename F>
- typename F::result_type
- static visit(utree const& x, utree const& y, F f);
-
- template <typename F>
- typename F::result_type
- static visit(utree& x, utree const& y, F f);
-
- template <typename F>
- typename F::result_type
- static visit(utree const& x, utree& y, F f);
-
- template <typename F>
- typename F::result_type
- static visit(utree& x, utree& y, F f);
-
- template <typename T>
- void push_back(T const& val);
-
- template <typename T>
- void push_front(T const& val);
-
- template <typename T>
- iterator insert(iterator pos, T const& x);
-
- template <typename T>
- void insert(iterator pos, std::size_t, T const& x);
-
- template <typename Iter>
- void insert(iterator pos, Iter first, Iter last);
-
- template <typename Iter>
- void assign(Iter first, Iter last);
-
- void clear();
- void pop_front();
- void pop_back();
- iterator erase(iterator pos);
- iterator erase(iterator first, iterator last);
-
- utree& front();
- utree& back();
- utree const& front() const;
- utree const& back() const;
-
- utree& operator[](std::size_t i);
- utree const& operator[](std::size_t i) const;
-
- void swap(utree& other);
-
- iterator begin();
- iterator end();
- const_iterator begin() const;
- const_iterator end() const;
-
- bool empty() const;
- std::size_t size() const;
-
- int which() const;
-
- utree& deref();
- utree const& deref() const;
-
- private:
-
- typedef utree_type type;
-
- template <typename UTreeX, typename UTreeY>
- friend struct detail::visit_impl;
- friend struct detail::index_impl;
- friend struct ulist;
- template <typename T> friend struct detail::get_impl;
-
- type::info get_type() const;
- void set_type(type::info t);
- void ensure_list_type();
- void free();
- void copy(utree const& other);
-
- struct construct_list {};
- utree(construct_list);
-
- union
- {
- detail::fast_string s;
- detail::list l;
- bool b;
- int i;
- double d;
- utree* p;
- };
- };
-}
-
-#if defined(BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
-#include "detail/utree_detail2.hpp"
-
-#endif

Copied: branches/release/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp (from r61299, /trunk/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp (original)
+++ branches/release/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,5 +1,6 @@
 /*=============================================================================
     Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2010 Hartmut Kaiser
 
     Distributed under the Boost Software License, Version 1.0. (See accompanying
     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -65,7 +66,7 @@
             // if it fits, store it in-situ; small_string_size minus the length
             // of the string is placed in buff[small_string_size - 1]
             str = buff;
- buff[small_string_size - 1] = max_string_len - size;
+ buff[small_string_size - 1] = static_cast<char>(max_string_len - size);
             info() &= ~0x1;
         }
         else
@@ -166,7 +167,7 @@
             return node == other.node;
         }
 
- utree& dereference() const
+ reference dereference() const
         {
             return node->val;
         }
@@ -175,6 +176,70 @@
         list::node* prev;
     };
 
+ template <typename Value>
+ class list::node_iterator<boost::reference_wrapper<Value> >
+ : public boost::iterator_facade<
+ node_iterator<boost::reference_wrapper<Value> >
+ , boost::reference_wrapper<Value>
+ , boost::bidirectional_traversal_tag
+ >
+ {
+ public:
+
+ node_iterator()
+ : node(0), prev(0), curr(nil_node) {}
+
+ explicit node_iterator(list::node* node)
+ : node(node), prev(node->prev), curr(node->val) {}
+
+ node_iterator(list::node* node, list::node* prev)
+ : node(node), prev(prev), curr(node ? node->val : nil_node) {}
+
+ private:
+
+ friend class boost::iterator_core_access;
+ friend class scheme::utree;
+
+ void increment()
+ {
+ if (node != 0) // not at end
+ {
+ prev = node;
+ node = node->next;
+ curr = boost::ref(node ? node->val : nil_node);
+ }
+ }
+
+ void decrement()
+ {
+ if (prev != 0) // not at begin
+ {
+ node = prev;
+ prev = prev->prev;
+ curr = boost::ref(node ? node->val : nil_node);
+ }
+ }
+
+ bool equal(node_iterator const& other) const
+ {
+ return node == other.node;
+ }
+
+ reference dereference() const
+ {
+ return curr;
+ }
+
+ list::node* node;
+ list::node* prev;
+
+ static Value nil_node;
+ mutable boost::reference_wrapper<Value> curr;
+ };
+
+ template <typename Value>
+ Value list::node_iterator<boost::reference_wrapper<Value> >::nil_node = Value();
+
     inline void list::free()
     {
         node* p = first;
@@ -514,6 +579,13 @@
         set_type(type::reference_type);
     }
 
+ template <typename Iter>
+ utree::utree(boost::iterator_range<Iter> r)
+ {
+ set_type(type::nil_type);
+ assign(r.begin(), r.end());
+ }
+
     inline utree::utree(utree const& other)
     {
         copy(other);
@@ -599,6 +671,13 @@
         return *this;
     }
 
+ template <typename Iter>
+ utree& utree::operator=(boost::iterator_range<Iter> r)
+ {
+ free();
+ assign(r.begin(), r.end());
+ }
+
     template <typename F>
     typename F::result_type
     inline utree::visit(utree const& x, F f)
@@ -783,6 +862,22 @@
         return iterator(0, l.last);
     }
 
+ inline utree::ref_iterator utree::ref_begin()
+ {
+ if (get_type() == type::reference_type)
+ return p->ref_begin();
+ ensure_list_type();
+ return ref_iterator(l.first);
+ }
+
+ inline utree::ref_iterator utree::ref_end()
+ {
+ if (get_type() == type::reference_type)
+ return p->ref_end();
+ ensure_list_type();
+ return ref_iterator(0, l.last);
+ }
+
     inline utree::const_iterator utree::begin() const
     {
         if (get_type() == type::reference_type)

Copied: branches/release/libs/spirit/example/scheme/utree/detail/utree_detail3.hpp (from r61299, /trunk/libs/spirit/example/scheme/utree/detail/utree_detail3.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/utree/detail/utree_detail3.hpp (original)
+++ branches/release/libs/spirit/example/scheme/utree/detail/utree_detail3.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,5 +1,6 @@
 /*=============================================================================
     Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2010 Hartmut Kaiser
 
     Distributed under the Boost Software License, Version 1.0. (See accompanying
     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -28,12 +29,13 @@
         SCHEME_GET_UTREE_TYPE(utf8_string_range, utree_type::string_type);
         SCHEME_GET_UTREE_TYPE(utf8_string, utree_type::string_type);
         SCHEME_GET_UTREE_TYPE(utf8_symbol_range, utree_type::symbol_type);
- SCHEME_GET_UTREE_TYPE(utf8_symbol, utree_type::string_type);
+ SCHEME_GET_UTREE_TYPE(utf8_symbol, utree_type::symbol_type);
         SCHEME_GET_UTREE_TYPE(binary_range, utree_type::binary_type);
         SCHEME_GET_UTREE_TYPE(boost::iterator_range<utree::iterator>,
             utree_type::list_type);
         SCHEME_GET_UTREE_TYPE(boost::iterator_range<utree::const_iterator>,
             utree_type::list_type);
+ SCHEME_GET_UTREE_TYPE(utree, utree_type::reference_type);
 
 #undef SCHEME_GET_UTREE_TYPE
 
@@ -140,6 +142,16 @@
                 return type(x.s.str(), x.s.size());
             }
         };
+
+ template <>
+ struct get_impl<utree>
+ {
+ typedef utree const& type;
+ static type call(utree const& x)
+ {
+ return x.which() == utree_type::reference_type ? *x.p : x;
+ }
+ };
     }
 }
 
@@ -150,12 +162,12 @@
     typename scheme::detail::get_impl<T>::type
     get(scheme::utree const& x)
     {
+ if (x.which() == scheme::utree_type::reference_type)
+ return get<T>(x.deref());
+
         if (x.which() !=
             (scheme::utree_type::info)scheme::detail::get_utree_type<T>::value)
         {
- if (x.which() == scheme::utree_type::reference_type)
- return get<T>(x.deref());
-
             throw boost::bad_get();
         }
         return scheme::detail::get_impl<T>::call(x);

Copied: branches/release/libs/spirit/example/scheme/utree/utree.hpp (from r61299, /trunk/libs/spirit/example/scheme/utree/utree.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/utree/utree.hpp (original)
+++ branches/release/libs/spirit/example/scheme/utree/utree.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -1,5 +1,6 @@
 /*=============================================================================
     Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2010 Hartmut Kaiser
 
     Distributed under the Boost Software License, Version 1.0. (See accompanying
     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -152,6 +153,8 @@
         typedef utree value_type;
         typedef detail::list::node_iterator<utree> iterator;
         typedef detail::list::node_iterator<utree const> const_iterator;
+ typedef detail::list::node_iterator<boost::reference_wrapper<utree> >
+ ref_iterator;
         typedef utree& reference;
         typedef utree const& const_reference;
         typedef std::ptrdiff_t difference_type;
@@ -169,6 +172,8 @@
         utree(char const* str, std::size_t len);
         utree(std::string const& str);
         utree(boost::reference_wrapper<utree> ref);
+ template <typename Iter>
+ utree(boost::iterator_range<Iter> r);
 
         template <typename Base, utree_type::info type_>
         utree(basic_string<Base, type_> const& bin);
@@ -184,6 +189,8 @@
         utree& operator=(char const* s);
         utree& operator=(std::string const& s);
         utree& operator=(boost::reference_wrapper<utree> ref);
+ template <typename Iter>
+ utree& operator=(boost::iterator_range<Iter> r);
 
         template <typename Base, utree_type::info type_>
         utree& operator=(basic_string<Base, type_> const& bin);
@@ -251,6 +258,9 @@
         const_iterator begin() const;
         const_iterator end() const;
 
+ ref_iterator ref_begin();
+ ref_iterator ref_end();
+
         bool empty() const;
         std::size_t size() const;
 

Deleted: branches/release/libs/spirit/example/scheme/utree_io.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/utree_io.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,31 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#if !defined(BOOST_SPIRIT_UTREE_IO)
-#define BOOST_SPIRIT_UTREE_IO
-
-#include "utree.hpp"
-#include "utree_operators.hpp"
-#include "input/parse_sexpr_impl.hpp"
-#include "output/generate_sexpr_impl.hpp"
-
-namespace scheme
-{
- // Printing
- inline std::ostream& operator<<(std::ostream& out, utree const& x)
- {
- output::generate_sexpr(out, x);
- return out;
- }
-
- // Parsing
- inline std::istream& operator>>(std::istream& in, utree& x)
- {
- input::parse_sexpr(in, x);
- return in;
- }
-}
-
-#endif

Deleted: branches/release/libs/spirit/example/scheme/utree_operators.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/utree_operators.hpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,516 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_UTREE_OPERATORS)
-#define BOOST_SPIRIT_UTREE_OPERATORS
-
-#if defined(BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4804)
-# pragma warning(disable: 4805)
-#endif
-
-#include "utree.hpp"
-#include <boost/preprocessor/cat.hpp>
-#include <boost/type_traits/is_arithmetic.hpp>
-#include <boost/type_traits/is_integral.hpp>
-
-namespace scheme
-{
- // Relational operators
- bool operator==(utree const& a, utree const& b);
- bool operator<(utree const& a, utree const& b);
- bool operator!=(utree const& a, utree const& b);
- bool operator>(utree const& a, utree const& b);
- bool operator<=(utree const& a, utree const& b);
- bool operator>=(utree const& a, utree const& b);
-
- // Input and output
- std::ostream& operator<<(std::ostream& out, utree const& x);
- std::istream& operator>>(std::istream& in, utree& x);
-
- // Logical operators
- utree operator&&(utree const& a, utree const& b);
- utree operator||(utree const& a, utree const& b);
- utree operator!(utree const& a);
-
- // Arithmetic operators
- utree operator+(utree const& a, utree const& b);
- utree operator-(utree const& a, utree const& b);
- utree operator*(utree const& a, utree const& b);
- utree operator/(utree const& a, utree const& b);
- utree operator%(utree const& a, utree const& b);
- utree operator-(utree const& a);
-
- // Bitwise operators
- utree operator&(utree const& a, utree const& b);
- utree operator|(utree const& a, utree const& b);
- utree operator^(utree const& a, utree const& b);
- utree operator<<(utree const& a, utree const& b);
- utree operator>>(utree const& a, utree const& b);
- utree operator~(utree const& a);
-
- // Implementation
- struct utree_is_equal
- {
- typedef bool result_type;
-
- template <typename A, typename B>
- bool dispatch(const A&, const B&, boost::mpl::false_) const
- {
- return false; // cannot compare different types by default
- }
-
- template <typename A, typename B>
- bool dispatch(const A& a, const B& b, boost::mpl::true_) const
- {
- return a == b; // for arithmetic types
- }
-
- template <typename A, typename B>
- bool operator()(const A& a, const B& b) const
- {
- return dispatch(a, b,
- boost::mpl::and_<
- boost::is_arithmetic<A>,
- boost::is_arithmetic<B> >());
- }
-
- template <typename T>
- bool operator()(const T& a, const T& b) const
- {
- // This code works for lists
- return a == b;
- }
-
- template <typename Base, utree_type::info type_>
- bool operator()(
- basic_string<Base, type_> const& a,
- basic_string<Base, type_> const& b) const
- {
- return static_cast<Base const&>(a) == static_cast<Base const&>(b);
- }
-
- bool operator()(nil, nil) const
- {
- return true;
- }
- };
-
- struct utree_is_less_than
- {
- typedef bool result_type;
-
- template <typename A, typename B>
- bool dispatch(const A&, const B&, boost::mpl::false_) const
- {
- return false; // cannot compare different types by default
- }
-
- template <typename A, typename B>
- bool dispatch(const A& a, const B& b, boost::mpl::true_) const
- {
- return a < b; // for arithmetic types
- }
-
- template <typename A, typename B>
- bool operator()(const A& a, const B& b) const
- {
- return dispatch(a, b,
- boost::mpl::and_<
- boost::is_arithmetic<A>,
- boost::is_arithmetic<B> >());
- }
-
- template <typename T>
- bool operator()(const T& a, const T& b) const
- {
- // This code works for lists
- return a < b;
- }
-
- template <typename Base, utree_type::info type_>
- bool operator()(
- basic_string<Base, type_> const& a,
- basic_string<Base, type_> const& b) const
- {
- return static_cast<Base const&>(a) < static_cast<Base const&>(b);
- }
-
- bool operator()(nil, nil) const
- {
- BOOST_ASSERT(false);
- return false; // no less than comparison for nil
- }
- };
-
-// struct utree_print
-// {
-// typedef void result_type;
-//
-// std::ostream& out;
-// utree_print(std::ostream& out) : out(out) {}
-//
-// void operator()(scheme::nil) const
-// {
-// out << "nil";
-// }
-//
-// template <typename T>
-// void operator()(T val) const
-// {
-// out << val;
-// }
-//
-// void operator()(bool b) const
-// {
-// out << (b ? "true" : "false");
-// }
-//
-// void operator()(binary_range const& b) const
-// {
-// out << "b";
-// out.width(2);
-// out.fill('0');
-//
-// typedef binary_range::const_iterator iterator;
-// for (iterator i = b.begin(); i != b.end(); ++i)
-// out << std::hex << int((unsigned char)*i);
-// out << std::dec;
-// }
-//
-// void operator()(utf8_string_range const& str) const
-// {
-// typedef utf8_string_range::const_iterator iterator;
-// iterator i = str.begin();
-// out << '"';
-// for (; i != str.end(); ++i)
-// out << *i;
-// out << '"';
-// }
-//
-// void operator()(utf8_symbol_range const& str) const
-// {
-// typedef utf8_symbol_range::const_iterator iterator;
-// iterator i = str.begin();
-// for (; i != str.end(); ++i)
-// out << *i;
-// }
-//
-// template <typename Iterator>
-// void operator()(boost::iterator_range<Iterator> const& range) const
-// {
-// typedef typename boost::iterator_range<Iterator>::const_iterator iterator;
-// (*this)('(');
-// for (iterator i = range.begin(); i != range.end(); ++i)
-// {
-// if (i != range.begin())
-// (*this)(' ');
-// scheme::utree::visit(*i, *this);
-// }
-// (*this)(')');
-// }
-// };
-
- template <typename Base>
- struct logical_function
- {
- typedef utree result_type;
-
- // binary
- utree operator()(bool a, bool b) const
- {
- return Base::eval(a, b); // for boolean types
- }
-
- // binary
- template <typename A, typename B>
- utree operator()(A const& a, B const& b) const
- {
- // $$$ Throw exception here? $$$
- return utree(); // cannot apply to non booleans
- }
-
- // unary
- utree operator()(bool a) const
- {
- return Base::eval(a); // for boolean types
- }
-
- // unary
- template <typename A>
- utree operator()(A const& a) const
- {
- // $$$ Throw exception here? $$$
- return utree(); // cannot apply to non booleans
- }
- };
-
- template <typename Base>
- struct arithmetic_function
- {
- typedef utree result_type;
-
- template <typename A, typename B>
- utree dispatch(A&, B&, boost::mpl::false_) const
- {
- // $$$ Throw exception here? $$$
- return utree(); // cannot apply to non-arithmetic types
- }
-
- template <typename A, typename B>
- utree dispatch(A& a, B& b, boost::mpl::true_) const
- {
- return Base::eval(a, b); // for arithmetic types
- }
-
- // binary
- template <typename A, typename B>
- utree operator()(A& a, B& b) const
- {
- return dispatch(a, b,
- boost::mpl::and_<
- boost::is_arithmetic<A>,
- boost::is_arithmetic<B> >());
- }
-
- template <typename A>
- utree dispatch(A&, boost::mpl::false_) const
- {
- // $$$ Throw exception here? $$$
- return utree(); // cannot apply to non-arithmetic types
- }
-
- template <typename A>
- utree dispatch(A& a, boost::mpl::true_) const
- {
- return Base::eval(a); // for arithmetic types
- }
-
- // unary
- template <typename A>
- utree operator()(A& a) const
- {
- return dispatch(a, boost::is_arithmetic<A>());
- }
- };
-
- template <typename Base>
- struct integral_function
- {
- typedef utree result_type;
-
- template <typename A, typename B>
- utree dispatch(A&, B&, boost::mpl::false_) const
- {
- // $$$ Throw exception here? $$$
- return utree(); // cannot apply to non-integral types
- }
-
- template <typename A, typename B>
- utree dispatch(A& a, B& b, boost::mpl::true_) const
- {
- return Base::eval(a, b); // for integral types
- }
-
- // binary
- template <typename A, typename B>
- utree operator()(A& a, B& b) const
- {
- return dispatch(a, b,
- boost::mpl::and_<
- boost::is_integral<A>,
- boost::is_integral<B> >());
- }
-
- template <typename A>
- utree dispatch(A&, boost::mpl::false_) const
- {
- // $$$ Throw exception here? $$$
- return utree(); // cannot apply to non-integral types
- }
-
- template <typename A>
- utree dispatch(A& a, boost::mpl::true_) const
- {
- return Base::eval(a); // for integral types
- }
-
- // unary
- template <typename A>
- utree operator()(A& a) const
- {
- return dispatch(a, boost::is_integral<A>());
- }
- };
-
-#define SCHEME_CREATE_FUNCTION(name, expr, base) \
- struct BOOST_PP_CAT(function_impl_, name) \
- { \
- template <typename A, typename B> \
- static utree eval(A& a, B& b) \
- { \
- return utree(expr); \
- } \
- template <typename A> \
- static utree eval(A& a) \
- { \
- static int b; \
- (void) b; \
- return utree(expr); \
- } \
- }; \
- base<BOOST_PP_CAT(function_impl_, name)> const \
- BOOST_PP_CAT(base, BOOST_PP_CAT(_, name)) = {}; \
- /***/
-
-#define SCHEME_CREATE_ARITHMETIC_FUNCTION(name, expr) \
- SCHEME_CREATE_FUNCTION(name, expr, arithmetic_function) \
- /***/
-
-#define SCHEME_CREATE_INTEGRAL_FUNCTION(name, expr) \
- SCHEME_CREATE_FUNCTION(name, expr, integral_function) \
- /***/
-
-#define SCHEME_CREATE_LOGICAL_FUNCTION(name, expr) \
- SCHEME_CREATE_FUNCTION(name, expr, logical_function) \
- /***/
-
- inline bool operator==(utree const& a, utree const& b)
- {
- return utree::visit(a, b, utree_is_equal());
- }
-
- inline bool operator<(utree const& a, utree const& b)
- {
- return utree::visit(a, b, utree_is_less_than());
- }
-
- inline bool operator!=(utree const& a, utree const& b)
- {
- return !(a == b);
- }
-
- inline bool operator>(utree const& a, utree const& b)
- {
- return b < a;
- }
-
- inline bool operator<=(utree const& a, utree const& b)
- {
- return !(b < a);
- }
-
- inline bool operator>=(utree const& a, utree const& b)
- {
- return !(a < b);
- }
-
-// inline std::ostream& operator<<(std::ostream& out, utree const& x)
-// {
-// utree::visit(x, utree_print(out));
-// return out;
-// }
-
- SCHEME_CREATE_LOGICAL_FUNCTION(and_, a&&b);
- SCHEME_CREATE_LOGICAL_FUNCTION(or_, a||b);
- SCHEME_CREATE_LOGICAL_FUNCTION(not_, !a);
-
- SCHEME_CREATE_ARITHMETIC_FUNCTION(plus, a+b);
- SCHEME_CREATE_ARITHMETIC_FUNCTION(minus, a-b);
- SCHEME_CREATE_ARITHMETIC_FUNCTION(times, a*b);
- SCHEME_CREATE_ARITHMETIC_FUNCTION(divides, a/b);
- SCHEME_CREATE_INTEGRAL_FUNCTION(modulus, a%b);
- SCHEME_CREATE_ARITHMETIC_FUNCTION(negate, -a);
-
- SCHEME_CREATE_INTEGRAL_FUNCTION(bitand_, a&b);
- SCHEME_CREATE_INTEGRAL_FUNCTION(bitor_, a|b);
- SCHEME_CREATE_INTEGRAL_FUNCTION(bitxor_, a^b);
- SCHEME_CREATE_INTEGRAL_FUNCTION(shift_left, a<<b);
- SCHEME_CREATE_INTEGRAL_FUNCTION(shift_right, a>>b);
- SCHEME_CREATE_INTEGRAL_FUNCTION(invert, ~a);
-
- inline utree operator&&(utree const& a, utree const& b)
- {
- return utree::visit(a, b, logical_function_and_);
- }
-
- inline utree operator||(utree const& a, utree const& b)
- {
- return utree::visit(a, b, logical_function_or_);
- }
-
- inline utree operator!(utree const& a)
- {
- return utree::visit(a, logical_function_not_);
- }
-
- inline utree operator+(utree const& a, utree const& b)
- {
- return utree::visit(a, b, arithmetic_function_plus);
- }
-
- inline utree operator-(utree const& a, utree const& b)
- {
- return utree::visit(a, b, arithmetic_function_minus);
- }
-
- inline utree operator*(utree const& a, utree const& b)
- {
- return utree::visit(a, b, arithmetic_function_times);
- }
-
- inline utree operator/(utree const& a, utree const& b)
- {
- return utree::visit(a, b, arithmetic_function_divides);
- }
-
- inline utree operator%(utree const& a, utree const& b)
- {
- return utree::visit(a, b, integral_function_modulus);
- }
-
- inline utree operator-(utree const& a)
- {
- return utree::visit(a, arithmetic_function_negate);
- }
-
- inline utree operator&(utree const& a, utree const& b)
- {
- return utree::visit(a, b, integral_function_bitand_);
- }
-
- inline utree operator|(utree const& a, utree const& b)
- {
- return utree::visit(a, b, integral_function_bitor_);
- }
-
- inline utree operator^(utree const& a, utree const& b)
- {
- return utree::visit(a, b, integral_function_bitxor_);
- }
-
- inline utree operator<<(utree const& a, utree const& b)
- {
- return utree::visit(a, b, integral_function_shift_left);
- }
-
- inline utree operator>>(utree const& a, utree const& b)
- {
- return utree::visit(a, b, integral_function_shift_right);
- }
-
- inline utree operator~(utree const& a)
- {
- return utree::visit(a, integral_function_invert);
- }
-}
-
-#if defined(BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
-#endif

Modified: branches/release/libs/spirit/test/Jamfile
==============================================================================
--- branches/release/libs/spirit/test/Jamfile (original)
+++ branches/release/libs/spirit/test/Jamfile 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -153,6 +153,7 @@
     # regression tests
     [ run qi/clear_test.cpp : : : : ]
     [ run qi/reorder_test.cpp : : : : ]
+ [ run karma/karma_optional_double.cpp : : : : ]
 
     ;
 

Modified: branches/release/libs/spirit/test/karma/attribute.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/attribute.cpp (original)
+++ branches/release/libs/spirit/test/karma/attribute.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -49,7 +49,7 @@
 namespace boost { namespace spirit { namespace traits
 {
     template <>
- struct transform_attribute<test_int_data1 const, int>
+ struct transform_attribute<test_int_data1 const, int, karma::domain>
     {
         typedef int type;
         static int pre(test_int_data1 const& d) { return d.i; }
@@ -68,7 +68,7 @@
 namespace boost { namespace spirit { namespace traits
 {
     template <>
- struct transform_attribute<test_int_data2 const, int>
+ struct transform_attribute<test_int_data2 const, int, karma::domain>
     {
         typedef int const& type;
         static int const& pre(test_int_data2 const& d) { return d.i; }

Modified: branches/release/libs/spirit/test/karma/char.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/char.cpp (original)
+++ branches/release/libs/spirit/test/karma/char.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -127,6 +127,9 @@
 
         BOOST_TEST(test(L"x", char_(L"x")));
 
+ BOOST_TEST(test("a", char_("a", "z"), 'a'));
+ BOOST_TEST(test(L"a", char_(L"a", L"z"), L'a'));
+
 #if defined(KARMA_FAIL_COMPILATION)
         BOOST_TEST(test("x", char_)); // anychar without a parameter doesn't make any sense
 #endif

Modified: branches/release/libs/spirit/test/karma/pattern2.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/pattern2.cpp (original)
+++ branches/release/libs/spirit/test/karma/pattern2.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -100,6 +100,23 @@
         BOOST_TEST(test_delimited("12.4 ", start, v, space));
     }
 
+ // test handling of single element fusion sequences
+ {
+ using boost::fusion::vector;
+ karma::rule<outiter_type, vector<int>()> r = int_;
+
+ vector<int> v = 1;
+ BOOST_TEST(test("1", r, v));
+ }
+
+ {
+ using boost::fusion::vector;
+ karma::rule<outiter_type, space_type, vector<int>()> r = int_;
+
+ vector<int> v = 1;
+ BOOST_TEST(test_delimited("1 ", r, v, space));
+ }
+
     return boost::report_errors();
 }
 

Modified: branches/release/libs/spirit/test/karma/sequence.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/sequence.cpp (original)
+++ branches/release/libs/spirit/test/karma/sequence.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -52,6 +52,18 @@
         }
 
         {
+ // a single element
+ char attr = 'a';
+ BOOST_TEST((test("ab", char_ << 'b', attr)));
+ }
+
+ {
+ // a single element fusion sequence
+ fusion::vector<char> attr = 'a';
+ BOOST_TEST((test("ab", char_ << 'b', attr)));
+ }
+
+ {
             fusion::vector<char, char, std::string> p ('a', 'b', "cdefg");
             BOOST_TEST(test("abcdefg", char_ << char_ << string, p));
             BOOST_TEST(test_delimited("a b cdefg ",

Modified: branches/release/libs/spirit/test/karma/symbols.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/symbols.cpp (original)
+++ branches/release/libs/spirit/test/karma/symbols.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -12,9 +12,22 @@
 #include <boost/spirit/include/karma_operator.hpp>
 #include <boost/spirit/include/karma_directive.hpp>
 #include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
 
 #include "test.hpp"
 
+namespace fusion = boost::fusion;
+
+template <typename T>
+inline std::vector<T>
+make_vector(T const& t1, T const& t2)
+{
+ std::vector<T> v;
+ v.push_back(t1);
+ v.push_back(t2);
+ return v;
+}
+
 int main()
 {
     using spirit_test::test;
@@ -65,6 +78,165 @@
         BOOST_TEST((!test("", sym, 'h')));
     }
 
+ { // advanced
+ using boost::spirit::karma::rule;
+ using boost::spirit::karma::lit;
+
+ typedef spirit_test::output_iterator<char>::type output_iterator_type;
+
+ symbols<char, rule<output_iterator_type> > sym;
+
+ rule<output_iterator_type> r1 = lit("Joel");
+ rule<output_iterator_type> r2 = lit("Hartmut");
+ rule<output_iterator_type> r3 = lit("Tom");
+ rule<output_iterator_type> r4 = lit("Kim");
+
+ sym.add
+ ('j', r1.alias())
+ ('h', r2.alias())
+ ('t', r3.alias())
+ ('k', r4.alias())
+ ;
+
+ boost::mpl::true_ f =
+ boost::mpl::bool_<boost::spirit::traits::is_generator<
+ symbols<char, rule<output_iterator_type> > >::value>();
+
+ // silence stupid compiler warnings
+ // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
+ BOOST_TEST((f.value));
+
+ BOOST_TEST((test("Joel", sym, 'j')));
+ BOOST_TEST((test("Hartmut", sym, 'h')));
+ BOOST_TEST((test("Tom", sym, 't')));
+ BOOST_TEST((test("Kim", sym, 'k')));
+ BOOST_TEST((!test("", sym, 'x')));
+
+ // test copy
+ symbols<char, rule<output_iterator_type> > sym2;
+ sym2 = sym;
+ BOOST_TEST((test("Joel", sym2, 'j')));
+ BOOST_TEST((test("Hartmut", sym2, 'h')));
+ BOOST_TEST((test("Tom", sym2, 't')));
+ BOOST_TEST((test("Kim", sym2, 'k')));
+ BOOST_TEST((!test("", sym2, 'x')));
+
+ // make sure it plays well with other generators
+ BOOST_TEST((test("Joelyo", sym << "yo", 'j')));
+
+ sym.remove
+ ('j')
+ ('h')
+ ;
+
+ BOOST_TEST((!test("", sym, 'j')));
+ BOOST_TEST((!test("", sym, 'h')));
+ }
+
+ { // more advanced
+ using boost::spirit::karma::rule;
+ using boost::spirit::karma::lit;
+ using boost::spirit::karma::string;
+
+ typedef spirit_test::output_iterator<char>::type output_iterator_type;
+
+ symbols<char, rule<output_iterator_type, std::string()> > sym;
+ rule<output_iterator_type, std::string()> r1 = string;
+
+ sym.add
+ ('j', r1.alias())
+ ('h', r1.alias())
+ ('t', r1.alias())
+ ('k', r1.alias())
+ ;
+
+ boost::mpl::true_ f =
+ boost::mpl::bool_<boost::spirit::traits::is_generator<
+ symbols<char, std::string> >::value>();
+
+ // silence stupid compiler warnings
+ // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
+ BOOST_TEST((f.value));
+
+ BOOST_TEST((test("Joel", sym, fusion::make_vector('j', "Joel"))));
+ BOOST_TEST((test("Hartmut", sym, fusion::make_vector('h', "Hartmut"))));
+ BOOST_TEST((test("Tom", sym, fusion::make_vector('t', "Tom"))));
+ BOOST_TEST((test("Kim", sym, fusion::make_vector('k', "Kim"))));
+ BOOST_TEST((!test("", sym, 'x')));
+
+ // test copy
+ symbols<char, rule<output_iterator_type, std::string()> > sym2;
+ sym2 = sym;
+ BOOST_TEST((test("Joel", sym2, fusion::make_vector('j', "Joel"))));
+ BOOST_TEST((test("Hartmut", sym2, fusion::make_vector('h', "Hartmut"))));
+ BOOST_TEST((test("Tom", sym2, fusion::make_vector('t', "Tom"))));
+ BOOST_TEST((test("Kim", sym2, fusion::make_vector('k', "Kim"))));
+ BOOST_TEST((!test("", sym2, 'x')));
+
+ // make sure it plays well with other generators
+ BOOST_TEST((test("Joelyo", sym << "yo", fusion::make_vector('j', "Joel"))));
+
+ sym.remove
+ ('j')
+ ('h')
+ ;
+
+ BOOST_TEST((!test("", sym, 'j')));
+ BOOST_TEST((!test("", sym, 'h')));
+ }
+
+ { // more advanced
+ using boost::spirit::karma::rule;
+ using boost::spirit::karma::lit;
+ using boost::spirit::karma::char_;
+
+ typedef spirit_test::output_iterator<char>::type output_iterator_type;
+
+ symbols<char, rule<output_iterator_type, char()> > sym;
+ rule<output_iterator_type, char()> r1 = char_;
+
+ sym.add
+ ('j', r1.alias())
+ ('h', r1.alias())
+ ('t', r1.alias())
+ ('k', r1.alias())
+ ;
+
+ boost::mpl::true_ f =
+ boost::mpl::bool_<boost::spirit::traits::is_generator<
+ symbols<char, rule<output_iterator_type, char()> > >::value>();
+
+ // silence stupid compiler warnings
+ // i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
+ BOOST_TEST((f.value));
+
+ BOOST_TEST((test("J", sym, make_vector('j', 'J'))));
+ BOOST_TEST((test("H", sym, make_vector('h', 'H'))));
+ BOOST_TEST((test("T", sym, make_vector('t', 'T'))));
+ BOOST_TEST((test("K", sym, make_vector('k', 'K'))));
+ BOOST_TEST((!test("", sym, 'x')));
+
+ // test copy
+ symbols<char, rule<output_iterator_type, char()> > sym2;
+ sym2 = sym;
+ BOOST_TEST((test("J", sym2, make_vector('j', 'J'))));
+ BOOST_TEST((test("H", sym2, make_vector('h', 'H'))));
+ BOOST_TEST((test("T", sym2, make_vector('t', 'T'))));
+ BOOST_TEST((test("K", sym2, make_vector('k', 'K'))));
+ BOOST_TEST((!test("", sym2, 'x')));
+
+ // make sure it plays well with other generators
+ BOOST_TEST((test("Jyo", sym << "yo", make_vector('j', 'J'))));
+
+ sym.remove
+ ('j')
+ ('h')
+ ;
+
+ BOOST_TEST((!test("", sym, 'j')));
+ BOOST_TEST((!test("", sym, 'h')));
+ }
+
     { // basics
         symbols<std::string> sym;
 
@@ -110,7 +282,7 @@
         BOOST_TEST((!test("", sym, "Hartmut")));
     }
 
- { // no-case handling
+ { // lower/upper handling
         using namespace boost::spirit::ascii;
         using boost::spirit::karma::lower;
         using boost::spirit::karma::upper;

Modified: branches/release/libs/spirit/test/qi/attribute.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/attribute.cpp (original)
+++ branches/release/libs/spirit/test/qi/attribute.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -54,7 +54,7 @@
 namespace boost { namespace spirit { namespace traits
 {
     template <>
- struct transform_attribute<test_int_data1, int>
+ struct transform_attribute<test_int_data1, int, qi::domain>
     {
         typedef int type;
         static int pre(test_int_data1& d) { return d.i; }
@@ -74,7 +74,7 @@
 namespace boost { namespace spirit { namespace traits
 {
     template <>
- struct transform_attribute<test_int_data2, int>
+ struct transform_attribute<test_int_data2, int, qi::domain>
     {
         typedef int& type;
         static int& pre(test_int_data2& d) { return d.i; }

Modified: branches/release/libs/spirit/test/qi/char.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/char.cpp (original)
+++ branches/release/libs/spirit/test/qi/char.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -116,6 +116,9 @@
         BOOST_TEST(test(L"x", L"x"));
         BOOST_TEST(test("x", ascii::char_("x")));
         BOOST_TEST(test(L"x", wide::char_(L"x")));
+
+ BOOST_TEST(test("x", ascii::char_("a", "z")));
+ BOOST_TEST(test(L"x", ascii::char_(L"a", L"z")));
     }
 
     {

Modified: branches/release/libs/spirit/test/qi/rule.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/rule.cpp (original)
+++ branches/release/libs/spirit/test/qi/rule.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -451,6 +451,29 @@
 #pragma setlocale("")
 #endif
 
+ {
+ typedef boost::variant<double, int> v_type;
+ rule<const char*, v_type()> r1 = int_;
+ v_type v;
+ BOOST_TEST(test_attr("1", r1, v) && v.which() == 1 &&
+ boost::get<int>(v) == 1);
+
+ typedef boost::optional<int> ov_type;
+ rule<const char*, ov_type()> r2 = int_;
+ ov_type ov;
+ BOOST_TEST(test_attr("1", r2, ov) && ov && boost::get<int>(ov) == 1);
+ }
+
+ // test handling of single element fusion sequences
+ {
+ using boost::fusion::vector;
+ using boost::fusion::at_c;
+ rule<const char*, vector<int>()> r = int_;
+
+ vector<int> v = 0;
+ BOOST_TEST(test_attr("1", r, v) && at_c<0>(v) == 1);
+ }
+
     return boost::report_errors();
 }
 

Modified: branches/release/libs/spirit/test/qi/sequence.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/sequence.cpp (original)
+++ branches/release/libs/spirit/test/qi/sequence.cpp 2010-07-04 17:04:31 EDT (Sun, 04 Jul 2010)
@@ -106,6 +106,13 @@
     }
 
     {
+ // a single element fusion sequence
+ vector<char> attr;
+ BOOST_TEST((test_attr("ab", char_ >> 'b', attr)));
+ BOOST_TEST((at_c<0>(attr) == 'a'));
+ }
+
+ {
         // make sure single element tuples get passed through if the rhs
         // has a single element tuple as its attribute
         vector<double, int> fv;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk