Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56189 - in branches/release/boost/spirit: . home home/classic home/classic/actor home/classic/core/composite home/classic/core/non_terminal/impl home/classic/core/primitives/impl home/classic/meta home/classic/phoenix home/classic/utility home/karma home/karma/action home/karma/auxiliary home/karma/binary home/karma/char home/karma/detail home/karma/directive home/karma/directive/detail home/karma/nonterminal home/karma/nonterminal/detail home/karma/numeric home/karma/numeric/detail home/karma/operator home/karma/operator/detail home/karma/operator/karma-alt home/karma/stream home/karma/stream/detail home/karma/string home/lex home/lex/detail home/lex/lexer home/lex/lexer/detail home/lex/lexer/lexertl home/lex/qi home/lex/qi/state home/lex/qi/utility home/phoenix/core home/phoenix/operator home/phoenix/operator/detail home/phoenix/scope home/phoenix/statement home/phoenix/statement/detail home/phoenix/stl/algorithm/detail home/phoenix/stl/container home/qi home/qi/action home/qi/auxiliary home/qi/binary home/qi/char home/qi/char/detail home/qi/debug home/qi/detail home/qi/directive home/qi/nonterminal home/qi/nonterminal/detail home/qi/numeric home/qi/numeric/detail home/qi/operator home/qi/stream home/qi/stream/detail home/qi/string home/qi/string/detail home/support home/support/algorithm home/support/auxiliary home/support/char_class home/support/char_encoding home/support/char_set home/support/detail home/support/detail/integer home/support/detail/lexer home/support/detail/lexer/containers home/support/detail/lexer/conversion home/support/detail/lexer/parser home/support/detail/lexer/parser/tokeniser home/support/detail/lexer/parser/tree home/support/detail/lexer/partition home/support/detail/math home/support/detail/math/detail home/support/iterators home/support/iterators/detail home/support/meta_grammar home/support/nonterminal home/support/nonterminal/detail include repository repository/home repository/home/karma repository/home/karma/directive repository/home/karma/nonterminal repository/home/qi repository/home/qi/directive repository/home/qi/nonterminal repository/home/qi/primitive repository/home/support repository/include
From: hartmut.kaiser_at_[hidden]
Date: 2009-09-14 12:51:03


Author: hkaiser
Date: 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
New Revision: 56189
URL: http://svn.boost.org/trac/boost/changeset/56189

Log:
Spirit: merging V2.1 from trunk
Added:
   branches/release/boost/spirit/home/karma/char/char_class.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/char/char_class.hpp
   branches/release/boost/spirit/home/karma/char/char_generator.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/char/char_generator.hpp
   branches/release/boost/spirit/home/karma/delimit_out.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/delimit_out.hpp
   branches/release/boost/spirit/home/karma/detail/alternative_function.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/detail/alternative_function.hpp
   branches/release/boost/spirit/home/karma/detail/default_width.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/detail/default_width.hpp
   branches/release/boost/spirit/home/karma/detail/fail_function.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/detail/fail_function.hpp
   branches/release/boost/spirit/home/karma/detail/get_casetag.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/detail/get_casetag.hpp
   branches/release/boost/spirit/home/karma/detail/pass_container.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/detail/pass_container.hpp
   branches/release/boost/spirit/home/karma/detail/string_compare.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/detail/string_compare.hpp
   branches/release/boost/spirit/home/karma/detail/unused_delimiter.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/detail/unused_delimiter.hpp
   branches/release/boost/spirit/home/karma/directive/buffer.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/directive/buffer.hpp
   branches/release/boost/spirit/home/karma/directive/maxwidth.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/directive/maxwidth.hpp
   branches/release/boost/spirit/home/karma/directive/omit.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/directive/omit.hpp
   branches/release/boost/spirit/home/karma/directive/repeat.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/directive/repeat.hpp
   branches/release/boost/spirit/home/karma/directive/upper_lower_case.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/directive/upper_lower_case.hpp
   branches/release/boost/spirit/home/karma/generate_attr.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/generate_attr.hpp
   branches/release/boost/spirit/home/karma/generator.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/generator.hpp
   branches/release/boost/spirit/home/karma/meta_compiler.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/meta_compiler.hpp
   branches/release/boost/spirit/home/karma/nonterminal/detail/fcall.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/nonterminal/detail/fcall.hpp
   branches/release/boost/spirit/home/karma/nonterminal/detail/generator_binder.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/nonterminal/detail/generator_binder.hpp
   branches/release/boost/spirit/home/karma/nonterminal/detail/parameterized.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/nonterminal/detail/parameterized.hpp
   branches/release/boost/spirit/home/karma/numeric/detail/real_utils.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/numeric/detail/real_utils.hpp
   branches/release/boost/spirit/home/karma/operator/and_predicate.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/operator/and_predicate.hpp
   branches/release/boost/spirit/home/karma/operator/not_predicate.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/operator/not_predicate.hpp
   branches/release/boost/spirit/home/karma/reference.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/reference.hpp
   branches/release/boost/spirit/home/karma/stream/detail/iterator_sink.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/stream/detail/iterator_sink.hpp
   branches/release/boost/spirit/home/karma/stream/format_manip_attr.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/stream/format_manip_attr.hpp
   branches/release/boost/spirit/home/karma/stream/ostream_iterator.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/karma/stream/ostream_iterator.hpp
   branches/release/boost/spirit/home/lex/argument.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/argument.hpp
   branches/release/boost/spirit/home/lex/detail/
      - copied from r56182, /trunk/boost/spirit/home/lex/detail/
   branches/release/boost/spirit/home/lex/detail/sequence_function.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/detail/sequence_function.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/functor.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/functor.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/iterator.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/iterator.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/static_version.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/static_version.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp
   branches/release/boost/spirit/home/lex/lexer/pass_flags.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/pass_flags.hpp
   branches/release/boost/spirit/home/lex/lexer/support_functions.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/support_functions.hpp
   branches/release/boost/spirit/home/lex/lexer/terminals.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer/terminals.hpp
   branches/release/boost/spirit/home/lex/lexer_type.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/lexer_type.hpp
   branches/release/boost/spirit/home/lex/meta_compiler.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/meta_compiler.hpp
   branches/release/boost/spirit/home/lex/primitives.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/primitives.hpp
   branches/release/boost/spirit/home/lex/qi.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/qi.hpp
   branches/release/boost/spirit/home/lex/qi/in_state.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/qi/in_state.hpp
   branches/release/boost/spirit/home/lex/qi/plain_token.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/qi/plain_token.hpp
   branches/release/boost/spirit/home/lex/qi/state_switcher.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/qi/state_switcher.hpp
   branches/release/boost/spirit/home/lex/reference.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/reference.hpp
   branches/release/boost/spirit/home/lex/tokenize_and_parse_attr.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/lex/tokenize_and_parse_attr.hpp
   branches/release/boost/spirit/home/qi/auxiliary/attr.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/auxiliary/attr.hpp
   branches/release/boost/spirit/home/qi/auxiliary/eoi.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/auxiliary/eoi.hpp
   branches/release/boost/spirit/home/qi/auxiliary/eol.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/auxiliary/eol.hpp
   branches/release/boost/spirit/home/qi/detail/pass_container.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/detail/pass_container.hpp
   branches/release/boost/spirit/home/qi/detail/unused_skipper.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/detail/unused_skipper.hpp
   branches/release/boost/spirit/home/qi/directive/no_case.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/directive/no_case.hpp
   branches/release/boost/spirit/home/qi/directive/repeat.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/directive/repeat.hpp
   branches/release/boost/spirit/home/qi/directive/skip.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/directive/skip.hpp
   branches/release/boost/spirit/home/qi/meta_compiler.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/meta_compiler.hpp
   branches/release/boost/spirit/home/qi/nonterminal/debug_handler.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/nonterminal/debug_handler.hpp
   branches/release/boost/spirit/home/qi/nonterminal/detail/fcall.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/nonterminal/detail/fcall.hpp
   branches/release/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp
   branches/release/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp
   branches/release/boost/spirit/home/qi/nonterminal/error_handler.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/nonterminal/error_handler.hpp
   branches/release/boost/spirit/home/qi/nonterminal/simple_trace.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/nonterminal/simple_trace.hpp
   branches/release/boost/spirit/home/qi/parse_attr.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/parse_attr.hpp
   branches/release/boost/spirit/home/qi/parser.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/parser.hpp
   branches/release/boost/spirit/home/qi/reference.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/reference.hpp
   branches/release/boost/spirit/home/qi/skip_over.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/skip_over.hpp
   branches/release/boost/spirit/home/qi/stream/detail/iterator_source.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/stream/detail/iterator_source.hpp
   branches/release/boost/spirit/home/qi/stream/match_manip_attr.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/stream/match_manip_attr.hpp
   branches/release/boost/spirit/home/qi/string/lit.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/string/lit.hpp
   branches/release/boost/spirit/home/qi/string/symbols.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/string/symbols.hpp
   branches/release/boost/spirit/home/qi/string/tst.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/string/tst.hpp
   branches/release/boost/spirit/home/qi/string/tst_map.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/qi/string/tst_map.hpp
   branches/release/boost/spirit/home/support/action_dispatch.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/action_dispatch.hpp
   branches/release/boost/spirit/home/support/algorithm/any_if_ns.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/algorithm/any_if_ns.hpp
   branches/release/boost/spirit/home/support/assert_msg.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/assert_msg.hpp
   branches/release/boost/spirit/home/support/attributes.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/attributes.hpp
   branches/release/boost/spirit/home/support/char_encoding/
      - copied from r56182, /trunk/boost/spirit/home/support/char_encoding/
   branches/release/boost/spirit/home/support/char_encoding/ascii.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_encoding/ascii.hpp
   branches/release/boost/spirit/home/support/char_encoding/iso8859_1.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_encoding/iso8859_1.hpp
   branches/release/boost/spirit/home/support/char_encoding/standard.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_encoding/standard.hpp
   branches/release/boost/spirit/home/support/char_encoding/standard_wide.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_encoding/standard_wide.hpp
   branches/release/boost/spirit/home/support/char_set/
      - copied from r56182, /trunk/boost/spirit/home/support/char_set/
   branches/release/boost/spirit/home/support/char_set/basic_chset.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_set/basic_chset.hpp
   branches/release/boost/spirit/home/support/char_set/range.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_set/range.hpp
   branches/release/boost/spirit/home/support/char_set/range_functions.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_set/range_functions.hpp
   branches/release/boost/spirit/home/support/char_set/range_run.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_set/range_run.hpp
   branches/release/boost/spirit/home/support/char_set/range_run_impl.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/char_set/range_run_impl.hpp
   branches/release/boost/spirit/home/support/common_terminals.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/common_terminals.hpp
   branches/release/boost/spirit/home/support/container.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/container.hpp
   branches/release/boost/spirit/home/support/context.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/context.hpp
   branches/release/boost/spirit/home/support/detail/as_variant.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/as_variant.hpp
   branches/release/boost/spirit/home/support/detail/endian.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/endian.hpp
   branches/release/boost/spirit/home/support/detail/get_encoding.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/get_encoding.hpp
   branches/release/boost/spirit/home/support/detail/lexer/internals.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/lexer/internals.hpp
   branches/release/boost/spirit/home/support/detail/make_cons.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/make_cons.hpp
   branches/release/boost/spirit/home/support/detail/make_vector.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/make_vector.hpp
   branches/release/boost/spirit/home/support/detail/pow10.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/pow10.hpp
   branches/release/boost/spirit/home/support/detail/scoped_enum_emulation.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/scoped_enum_emulation.hpp
   branches/release/boost/spirit/home/support/detail/sign.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/detail/sign.hpp
   branches/release/boost/spirit/home/support/info.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/info.hpp
   branches/release/boost/spirit/home/support/lazy.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/lazy.hpp
   branches/release/boost/spirit/home/support/make_component.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/make_component.hpp
   branches/release/boost/spirit/home/support/meta_compiler.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/meta_compiler.hpp
   branches/release/boost/spirit/home/support/modify.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/modify.hpp
   branches/release/boost/spirit/home/support/multi_pass.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/multi_pass.hpp
   branches/release/boost/spirit/home/support/multi_pass_wrapper.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/multi_pass_wrapper.hpp
   branches/release/boost/spirit/home/support/nonterminal/expand_arg.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/nonterminal/expand_arg.hpp
   branches/release/boost/spirit/home/support/nonterminal/extract_param.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/nonterminal/extract_param.hpp
   branches/release/boost/spirit/home/support/sequence_base_id.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/sequence_base_id.hpp
   branches/release/boost/spirit/home/support/string_traits.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/string_traits.hpp
   branches/release/boost/spirit/home/support/terminal.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/terminal.hpp
   branches/release/boost/spirit/home/support/utf8.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/home/support/utf8.hpp
   branches/release/boost/spirit/include/karma_alternative.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_alternative.hpp
   branches/release/boost/spirit/include/karma_and_predicate.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_and_predicate.hpp
   branches/release/boost/spirit/include/karma_buffer.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_buffer.hpp
   branches/release/boost/spirit/include/karma_center_alignment.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_center_alignment.hpp
   branches/release/boost/spirit/include/karma_char_.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_char_.hpp
   branches/release/boost/spirit/include/karma_char_class.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_char_class.hpp
   branches/release/boost/spirit/include/karma_eol.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_eol.hpp
   branches/release/boost/spirit/include/karma_eps.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_eps.hpp
   branches/release/boost/spirit/include/karma_generate_attr.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_generate_attr.hpp
   branches/release/boost/spirit/include/karma_int.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_int.hpp
   branches/release/boost/spirit/include/karma_kleene.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_kleene.hpp
   branches/release/boost/spirit/include/karma_lazy.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_lazy.hpp
   branches/release/boost/spirit/include/karma_left_alignment.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_left_alignment.hpp
   branches/release/boost/spirit/include/karma_list.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_list.hpp
   branches/release/boost/spirit/include/karma_maxwidth.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_maxwidth.hpp
   branches/release/boost/spirit/include/karma_not_predicate.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_not_predicate.hpp
   branches/release/boost/spirit/include/karma_omit.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_omit.hpp
   branches/release/boost/spirit/include/karma_optional.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_optional.hpp
   branches/release/boost/spirit/include/karma_plus.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_plus.hpp
   branches/release/boost/spirit/include/karma_real.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_real.hpp
   branches/release/boost/spirit/include/karma_repeat.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_repeat.hpp
   branches/release/boost/spirit/include/karma_right_alignment.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_right_alignment.hpp
   branches/release/boost/spirit/include/karma_sequence.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_sequence.hpp
   branches/release/boost/spirit/include/karma_uint.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_uint.hpp
   branches/release/boost/spirit/include/karma_upper_lower_case.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_upper_lower_case.hpp
   branches/release/boost/spirit/include/karma_verbatim.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/karma_verbatim.hpp
   branches/release/boost/spirit/include/lex_char_token_def.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/lex_char_token_def.hpp
   branches/release/boost/spirit/include/lex_generate_static_lexertl.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/lex_generate_static_lexertl.hpp
   branches/release/boost/spirit/include/lex_lexertl.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/lex_lexertl.hpp
   branches/release/boost/spirit/include/lex_primitives.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/lex_primitives.hpp
   branches/release/boost/spirit/include/lex_static_lexertl.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/lex_static_lexertl.hpp
   branches/release/boost/spirit/include/qi_core.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/qi_core.hpp
   branches/release/boost/spirit/include/qi_parse_attr.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/qi_parse_attr.hpp
   branches/release/boost/spirit/include/support_any_if_ns.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/support_any_if_ns.hpp
   branches/release/boost/spirit/include/support_attributes.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/support_attributes.hpp
   branches/release/boost/spirit/include/support_modify.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/include/support_modify.hpp
   branches/release/boost/spirit/repository/
      - copied from r56182, /trunk/boost/spirit/repository/
   branches/release/boost/spirit/repository/home/
      - copied from r56182, /trunk/boost/spirit/repository/home/
   branches/release/boost/spirit/repository/home/karma/
      - copied from r56182, /trunk/boost/spirit/repository/home/karma/
   branches/release/boost/spirit/repository/home/karma.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/karma.hpp
   branches/release/boost/spirit/repository/home/karma/directive/
      - copied from r56182, /trunk/boost/spirit/repository/home/karma/directive/
   branches/release/boost/spirit/repository/home/karma/directive.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/karma/directive.hpp
   branches/release/boost/spirit/repository/home/karma/directive/confix.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/karma/directive/confix.hpp
   branches/release/boost/spirit/repository/home/karma/nonterminal/
      - copied from r56182, /trunk/boost/spirit/repository/home/karma/nonterminal/
   branches/release/boost/spirit/repository/home/karma/nonterminal.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/karma/nonterminal.hpp
   branches/release/boost/spirit/repository/home/karma/nonterminal/subrule.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/karma/nonterminal/subrule.hpp
   branches/release/boost/spirit/repository/home/qi/
      - copied from r56182, /trunk/boost/spirit/repository/home/qi/
   branches/release/boost/spirit/repository/home/qi.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/qi.hpp
   branches/release/boost/spirit/repository/home/qi/directive/
      - copied from r56182, /trunk/boost/spirit/repository/home/qi/directive/
   branches/release/boost/spirit/repository/home/qi/directive.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/qi/directive.hpp
   branches/release/boost/spirit/repository/home/qi/directive/confix.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/qi/directive/confix.hpp
   branches/release/boost/spirit/repository/home/qi/directive/distinct.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/qi/directive/distinct.hpp
   branches/release/boost/spirit/repository/home/qi/nonterminal/
      - copied from r56182, /trunk/boost/spirit/repository/home/qi/nonterminal/
   branches/release/boost/spirit/repository/home/qi/nonterminal.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/qi/nonterminal.hpp
   branches/release/boost/spirit/repository/home/qi/nonterminal/subrule.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/qi/nonterminal/subrule.hpp
   branches/release/boost/spirit/repository/home/qi/primitive/
      - copied from r56182, /trunk/boost/spirit/repository/home/qi/primitive/
   branches/release/boost/spirit/repository/home/qi/primitive.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/qi/primitive.hpp
   branches/release/boost/spirit/repository/home/qi/primitive/flush_multi_pass.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/qi/primitive/flush_multi_pass.hpp
   branches/release/boost/spirit/repository/home/support/
      - copied from r56182, /trunk/boost/spirit/repository/home/support/
   branches/release/boost/spirit/repository/home/support/confix.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/support/confix.hpp
   branches/release/boost/spirit/repository/home/support/distinct.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/support/distinct.hpp
   branches/release/boost/spirit/repository/home/support/flush_multi_pass.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/support/flush_multi_pass.hpp
   branches/release/boost/spirit/repository/home/support/subrule_context.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/home/support/subrule_context.hpp
   branches/release/boost/spirit/repository/include/
      - copied from r56182, /trunk/boost/spirit/repository/include/
   branches/release/boost/spirit/repository/include/karma.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/karma.hpp
   branches/release/boost/spirit/repository/include/karma_confix.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/karma_confix.hpp
   branches/release/boost/spirit/repository/include/karma_directive.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/karma_directive.hpp
   branches/release/boost/spirit/repository/include/karma_nonterminal.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/karma_nonterminal.hpp
   branches/release/boost/spirit/repository/include/karma_subrule.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/karma_subrule.hpp
   branches/release/boost/spirit/repository/include/qi.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/qi.hpp
   branches/release/boost/spirit/repository/include/qi_confix.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/qi_confix.hpp
   branches/release/boost/spirit/repository/include/qi_directive.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/qi_directive.hpp
   branches/release/boost/spirit/repository/include/qi_distinct.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/qi_distinct.hpp
   branches/release/boost/spirit/repository/include/qi_flush_multi_pass.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/qi_flush_multi_pass.hpp
   branches/release/boost/spirit/repository/include/qi_nonterminal.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/qi_nonterminal.hpp
   branches/release/boost/spirit/repository/include/qi_primitive.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/qi_primitive.hpp
   branches/release/boost/spirit/repository/include/qi_subrule.hpp
      - copied unchanged from r56182, /trunk/boost/spirit/repository/include/qi_subrule.hpp
Removed:
   branches/release/boost/spirit/home/karma/action/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/auxiliary/confix.hpp
   branches/release/boost/spirit/home/karma/auxiliary/functor.hpp
   branches/release/boost/spirit/home/karma/auxiliary/functor_director.hpp
   branches/release/boost/spirit/home/karma/auxiliary/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/auxiliary/none.hpp
   branches/release/boost/spirit/home/karma/binary/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/char/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/char/space.hpp
   branches/release/boost/spirit/home/karma/delimit.hpp
   branches/release/boost/spirit/home/karma/detail/ostream_iterator.hpp
   branches/release/boost/spirit/home/karma/directive/alignment_meta_grammar.hpp
   branches/release/boost/spirit/home/karma/directive/case_meta_grammar.hpp
   branches/release/boost/spirit/home/karma/directive/delimiter_meta_grammar.hpp
   branches/release/boost/spirit/home/karma/directive/detail/
   branches/release/boost/spirit/home/karma/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/nonterminal/detail/rule.hpp
   branches/release/boost/spirit/home/karma/nonterminal/grammar_fwd.hpp
   branches/release/boost/spirit/home/karma/nonterminal/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/nonterminal/nonterminal.hpp
   branches/release/boost/spirit/home/karma/nonterminal/nonterminal_director.hpp
   branches/release/boost/spirit/home/karma/numeric/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/numeric/numeric_fwd.hpp
   branches/release/boost/spirit/home/karma/operator/detail/
   branches/release/boost/spirit/home/karma/operator/karma-alt/
   branches/release/boost/spirit/home/karma/operator/karma-alt.zip
   branches/release/boost/spirit/home/karma/operator/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/stream/detail/iterator_ostream.hpp
   branches/release/boost/spirit/home/karma/stream/meta_grammar.hpp
   branches/release/boost/spirit/home/karma/string/meta_grammar.hpp
   branches/release/boost/spirit/home/lex/lexer/detail/
   branches/release/boost/spirit/home/lex/lexer/lexer_actions.hpp
   branches/release/boost/spirit/home/lex/lexer/lexer_fwd.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_generate_static.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_iterator.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_lexer.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_static_lexer.hpp
   branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_token.hpp
   branches/release/boost/spirit/home/lex/lexer/meta_grammar.hpp
   branches/release/boost/spirit/home/lex/lexer/terminal_director.hpp
   branches/release/boost/spirit/home/lex/lexer/terminal_holder.hpp
   branches/release/boost/spirit/home/lex/lexer/token_set.hpp
   branches/release/boost/spirit/home/lex/meta_grammar.hpp
   branches/release/boost/spirit/home/lex/qi/meta_grammar.hpp
   branches/release/boost/spirit/home/lex/qi/state/
   branches/release/boost/spirit/home/lex/qi/utility/
   branches/release/boost/spirit/home/lex/set_state.hpp
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/std_list_fwd.hpp
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/std_map_fwd.hpp
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/std_set_fwd.hpp
   branches/release/boost/spirit/home/qi/action/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/auxiliary/confix.hpp
   branches/release/boost/spirit/home/qi/auxiliary/functor.hpp
   branches/release/boost/spirit/home/qi/auxiliary/functor_director.hpp
   branches/release/boost/spirit/home/qi/auxiliary/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/auxiliary/none.hpp
   branches/release/boost/spirit/home/qi/auxiliary/primitives.hpp
   branches/release/boost/spirit/home/qi/binary/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/char/detail/
   branches/release/boost/spirit/home/qi/char/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/debug/
   branches/release/boost/spirit/home/qi/debug.hpp
   branches/release/boost/spirit/home/qi/detail/construct_fwd.hpp
   branches/release/boost/spirit/home/qi/directive/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/nonterminal/detail/error_handler.hpp
   branches/release/boost/spirit/home/qi/nonterminal/detail/rule.hpp
   branches/release/boost/spirit/home/qi/nonterminal/error_handler_result.hpp
   branches/release/boost/spirit/home/qi/nonterminal/grammar_fwd.hpp
   branches/release/boost/spirit/home/qi/nonterminal/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/nonterminal/nonterminal.hpp
   branches/release/boost/spirit/home/qi/nonterminal/nonterminal_director.hpp
   branches/release/boost/spirit/home/qi/nonterminal/virtual_component_base.hpp
   branches/release/boost/spirit/home/qi/numeric/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/operator/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/skip.hpp
   branches/release/boost/spirit/home/qi/stream/detail/iterator_istream.hpp
   branches/release/boost/spirit/home/qi/stream/meta_grammar.hpp
   branches/release/boost/spirit/home/qi/string/meta_grammar.hpp
   branches/release/boost/spirit/home/support/as_variant.hpp
   branches/release/boost/spirit/home/support/ascii.hpp
   branches/release/boost/spirit/home/support/attribute_of.hpp
   branches/release/boost/spirit/home/support/attribute_transform.hpp
   branches/release/boost/spirit/home/support/auxiliary/
   branches/release/boost/spirit/home/support/char_class/
   branches/release/boost/spirit/home/support/component.hpp
   branches/release/boost/spirit/home/support/detail/action_dispatch.hpp
   branches/release/boost/spirit/home/support/detail/container.hpp
   branches/release/boost/spirit/home/support/detail/math/nonfinite_num_facets.hpp
   branches/release/boost/spirit/home/support/detail/to_narrow.hpp
   branches/release/boost/spirit/home/support/detail/values.hpp
   branches/release/boost/spirit/home/support/iso8859_1.hpp
   branches/release/boost/spirit/home/support/meta_grammar/
   branches/release/boost/spirit/home/support/meta_grammar.hpp
   branches/release/boost/spirit/home/support/modifier.hpp
   branches/release/boost/spirit/home/support/nonterminal/detail/
   branches/release/boost/spirit/home/support/nonterminal/nonterminal.hpp
   branches/release/boost/spirit/home/support/placeholders.hpp
   branches/release/boost/spirit/home/support/standard.hpp
   branches/release/boost/spirit/home/support/standard_wide.hpp
   branches/release/boost/spirit/include/karma_meta_grammar.hpp
   branches/release/boost/spirit/include/lex_lexer_lexertl.hpp
   branches/release/boost/spirit/include/lex_lexer_static_lexertl.hpp
   branches/release/boost/spirit/include/lex_meta_grammar.hpp
   branches/release/boost/spirit/include/lex_set_state.hpp
   branches/release/boost/spirit/include/qi_debug.hpp
   branches/release/boost/spirit/include/qi_meta_grammar.hpp
   branches/release/boost/spirit/include/support_as_variant.hpp
   branches/release/boost/spirit/include/support_attribute_of.hpp
   branches/release/boost/spirit/include/support_attribute_transform.hpp
   branches/release/boost/spirit/include/support_basic_rules.hpp
   branches/release/boost/spirit/include/support_basic_transforms.hpp
   branches/release/boost/spirit/include/support_component.hpp
   branches/release/boost/spirit/include/support_functor_holder.hpp
   branches/release/boost/spirit/include/support_grammar.hpp
   branches/release/boost/spirit/include/support_meta_function_holder.hpp
   branches/release/boost/spirit/include/support_meta_grammar.hpp
   branches/release/boost/spirit/include/support_modifier.hpp
   branches/release/boost/spirit/include/support_nonterminal.hpp
   branches/release/boost/spirit/include/support_placeholders.hpp
Properties modified:
   branches/release/boost/spirit/ (props changed)
Text files modified:
   branches/release/boost/spirit/home/classic/actor/ref_value_actor.hpp | 9
   branches/release/boost/spirit/home/classic/core/composite/actions.hpp | 5
   branches/release/boost/spirit/home/classic/core/composite/alternative.hpp | 9
   branches/release/boost/spirit/home/classic/core/composite/composite.hpp | 5
   branches/release/boost/spirit/home/classic/core/composite/difference.hpp | 11
   branches/release/boost/spirit/home/classic/core/composite/kleene_star.hpp | 9
   branches/release/boost/spirit/home/classic/core/composite/positive.hpp | 9
   branches/release/boost/spirit/home/classic/core/composite/sequence.hpp | 9
   branches/release/boost/spirit/home/classic/core/non_terminal/impl/rule.ipp | 9
   branches/release/boost/spirit/home/classic/core/primitives/impl/numerics.ipp | 12
   branches/release/boost/spirit/home/classic/dynamic.hpp | 2
   branches/release/boost/spirit/home/classic/meta/refactoring.hpp | 9
   branches/release/boost/spirit/home/classic/phoenix/actor.hpp | 9
   branches/release/boost/spirit/home/classic/phoenix/closures.hpp | 9
   branches/release/boost/spirit/home/classic/phoenix/composite.hpp | 9
   branches/release/boost/spirit/home/classic/phoenix/primitives.hpp | 9
   branches/release/boost/spirit/home/classic/phoenix/tuples.hpp | 9
   branches/release/boost/spirit/home/classic/utility/confix.hpp | 9
   branches/release/boost/spirit/home/classic/utility/rule_parser.hpp | 2
   branches/release/boost/spirit/home/karma.hpp | 9
   branches/release/boost/spirit/home/karma/action.hpp | 5
   branches/release/boost/spirit/home/karma/action/action.hpp | 134 ++++---
   branches/release/boost/spirit/home/karma/auxiliary.hpp | 9
   branches/release/boost/spirit/home/karma/auxiliary/eol.hpp | 67 +++
   branches/release/boost/spirit/home/karma/auxiliary/eps.hpp | 117 +++++-
   branches/release/boost/spirit/home/karma/auxiliary/lazy.hpp | 223 ++++++++++--
   branches/release/boost/spirit/home/karma/binary.hpp | 5
   branches/release/boost/spirit/home/karma/binary/binary.hpp | 282 +++++++++++++----
   branches/release/boost/spirit/home/karma/binary/padding.hpp | 100 ++++-
   branches/release/boost/spirit/home/karma/char.hpp | 7
   branches/release/boost/spirit/home/karma/char/char.hpp | 586 ++++++++++++++++++++++-------------
   branches/release/boost/spirit/home/karma/detail/generate_to.hpp | 49 +-
   branches/release/boost/spirit/home/karma/detail/output_iterator.hpp | 574 +++++++++++++++++++++++-----------
   branches/release/boost/spirit/home/karma/detail/string_generate.hpp | 124 +++++--
   branches/release/boost/spirit/home/karma/directive.hpp | 32 +
   branches/release/boost/spirit/home/karma/directive/center_alignment.hpp | 392 +++++++++++++---------
   branches/release/boost/spirit/home/karma/directive/delimit.hpp | 205 +++++++----
   branches/release/boost/spirit/home/karma/directive/left_alignment.hpp | 372 ++++++++++++---------
   branches/release/boost/spirit/home/karma/directive/right_alignment.hpp | 385 +++++++++++++---------
   branches/release/boost/spirit/home/karma/directive/verbatim.hpp | 104 +++--
   branches/release/boost/spirit/home/karma/domain.hpp | 48 ++
   branches/release/boost/spirit/home/karma/generate.hpp | 385 ++++++++++------------
   branches/release/boost/spirit/home/karma/nonterminal.hpp | 5
   branches/release/boost/spirit/home/karma/nonterminal/grammar.hpp | 92 +++--
   branches/release/boost/spirit/home/karma/nonterminal/rule.hpp | 379 ++++++++++++++--------
   branches/release/boost/spirit/home/karma/numeric.hpp | 6
   branches/release/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp | 542 +++++++++++++++-----------------
   branches/release/boost/spirit/home/karma/numeric/int.hpp | 510 +++++++++++++++++++++---------
   branches/release/boost/spirit/home/karma/numeric/real.hpp | 503 ++++++++++++++++++++----------
   branches/release/boost/spirit/home/karma/numeric/real_policies.hpp | 255 +++++++++------
   branches/release/boost/spirit/home/karma/numeric/uint.hpp | 563 +++++++++++++++++++++++++--------
   branches/release/boost/spirit/home/karma/operator.hpp | 7
   branches/release/boost/spirit/home/karma/operator/alternative.hpp | 150 ++++++--
   branches/release/boost/spirit/home/karma/operator/kleene.hpp | 127 ++++---
   branches/release/boost/spirit/home/karma/operator/list.hpp | 137 ++++---
   branches/release/boost/spirit/home/karma/operator/optional.hpp | 128 ++++---
   branches/release/boost/spirit/home/karma/operator/plus.hpp | 131 ++++---
   branches/release/boost/spirit/home/karma/operator/sequence.hpp | 201 +++++++++--
   branches/release/boost/spirit/home/karma/stream.hpp | 7
   branches/release/boost/spirit/home/karma/stream/detail/format_manip.hpp | 96 +++--
   branches/release/boost/spirit/home/karma/stream/format_manip.hpp | 143 ++++----
   branches/release/boost/spirit/home/karma/stream/stream.hpp | 351 +++++++++++++++-----
   branches/release/boost/spirit/home/karma/string.hpp | 5
   branches/release/boost/spirit/home/karma/string/lit.hpp | 444 +++++++++++++-------------
   branches/release/boost/spirit/home/karma/what.hpp | 31 -
   branches/release/boost/spirit/home/lex.hpp | 8
   branches/release/boost/spirit/home/lex/domain.hpp | 22
   branches/release/boost/spirit/home/lex/lexer.hpp | 15
   branches/release/boost/spirit/home/lex/lexer/action.hpp | 125 +++---
   branches/release/boost/spirit/home/lex/lexer/char_token_def.hpp | 152 ++++++++
   branches/release/boost/spirit/home/lex/lexer/lexer.hpp | 351 +++++++++-----------
   branches/release/boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp | 129 ++-----
   branches/release/boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp | 297 ++++++++++-------
   branches/release/boost/spirit/home/lex/lexer/sequence.hpp | 59 ++
   branches/release/boost/spirit/home/lex/lexer/string_token_def.hpp | 101 +++++
   branches/release/boost/spirit/home/lex/lexer/token_def.hpp | 226 +++++++------
   branches/release/boost/spirit/home/lex/lexer_lexertl.hpp | 6
   branches/release/boost/spirit/home/lex/lexer_static_lexertl.hpp | 10
   branches/release/boost/spirit/home/lex/tokenize_and_parse.hpp | 273 ++++++++--------
   branches/release/boost/spirit/home/phoenix/core/actor.hpp | 9
   branches/release/boost/spirit/home/phoenix/core/argument.hpp | 6
   branches/release/boost/spirit/home/phoenix/core/basic_environment.hpp | 5
   branches/release/boost/spirit/home/phoenix/core/composite.hpp | 4
   branches/release/boost/spirit/home/phoenix/core/limits.hpp | 59 +++
   branches/release/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_eval.hpp | 3
   branches/release/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_gen.hpp | 4
   branches/release/boost/spirit/home/phoenix/operator/member.hpp | 6
   branches/release/boost/spirit/home/phoenix/scope/dynamic.hpp | 12
   branches/release/boost/spirit/home/phoenix/scope/lambda.hpp | 4
   branches/release/boost/spirit/home/phoenix/scope/let.hpp | 4
   branches/release/boost/spirit/home/phoenix/scope/local_variable.hpp | 4
   branches/release/boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp | 4
   branches/release/boost/spirit/home/phoenix/statement/detail/catch_eval.hpp | 4
   branches/release/boost/spirit/home/phoenix/statement/try_catch.hpp | 6
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_hash_map.hpp | 43 ++
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_hash_set.hpp | 39 +
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_list.hpp | 2
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_map.hpp | 2
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_set.hpp | 2
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/std_hash_map_fwd.hpp | 33 +
   branches/release/boost/spirit/home/phoenix/stl/algorithm/detail/std_hash_set_fwd.hpp | 29 +
   branches/release/boost/spirit/home/phoenix/stl/container/container.hpp | 6
   branches/release/boost/spirit/home/qi.hpp | 22
   branches/release/boost/spirit/home/qi/action.hpp | 11
   branches/release/boost/spirit/home/qi/action/action.hpp | 136 ++++---
   branches/release/boost/spirit/home/qi/auxiliary.hpp | 19
   branches/release/boost/spirit/home/qi/auxiliary/eps.hpp | 114 +++++-
   branches/release/boost/spirit/home/qi/auxiliary/lazy.hpp | 231 ++++++++++---
   branches/release/boost/spirit/home/qi/binary.hpp | 14
   branches/release/boost/spirit/home/qi/binary/binary.hpp | 234 ++++++++++---
   branches/release/boost/spirit/home/qi/char.hpp | 11
   branches/release/boost/spirit/home/qi/char/char.hpp | 661 ++++++++++++++++++++++++---------------
   branches/release/boost/spirit/home/qi/char/char_class.hpp | 118 +++---
   branches/release/boost/spirit/home/qi/char/char_parser.hpp | 149 ++++++--
   branches/release/boost/spirit/home/qi/detail/alternative_function.hpp | 40 +
   branches/release/boost/spirit/home/qi/detail/assign_to.hpp | 30 +
   branches/release/boost/spirit/home/qi/detail/construct.hpp | 24
   branches/release/boost/spirit/home/qi/detail/expect_function.hpp | 36 +
   branches/release/boost/spirit/home/qi/detail/fail_function.hpp | 23
   branches/release/boost/spirit/home/qi/detail/pass_function.hpp | 19
   branches/release/boost/spirit/home/qi/detail/permute_function.hpp | 18
   branches/release/boost/spirit/home/qi/detail/string_parse.hpp | 6
   branches/release/boost/spirit/home/qi/directive.hpp | 14
   branches/release/boost/spirit/home/qi/directive/lexeme.hpp | 92 +++--
   branches/release/boost/spirit/home/qi/directive/omit.hpp | 86 +++-
   branches/release/boost/spirit/home/qi/directive/raw.hpp | 86 +++-
   branches/release/boost/spirit/home/qi/domain.hpp | 49 ++
   branches/release/boost/spirit/home/qi/nonterminal.hpp | 16
   branches/release/boost/spirit/home/qi/nonterminal/grammar.hpp | 96 +++--
   branches/release/boost/spirit/home/qi/nonterminal/rule.hpp | 521 +++++++++++++------------------
   branches/release/boost/spirit/home/qi/numeric.hpp | 11
   branches/release/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp | 46 +-
   branches/release/boost/spirit/home/qi/numeric/detail/real_impl.hpp | 191 +++++++----
   branches/release/boost/spirit/home/qi/numeric/int.hpp | 122 ++++++-
   branches/release/boost/spirit/home/qi/numeric/numeric_utils.hpp | 30 +
   branches/release/boost/spirit/home/qi/numeric/real.hpp | 110 +++++-
   branches/release/boost/spirit/home/qi/numeric/real_policies.hpp | 56 +-
   branches/release/boost/spirit/home/qi/numeric/uint.hpp | 159 ++++++++-
   branches/release/boost/spirit/home/qi/operator.hpp | 11
   branches/release/boost/spirit/home/qi/operator/alternative.hpp | 119 +++---
   branches/release/boost/spirit/home/qi/operator/and_predicate.hpp | 75 ++-
   branches/release/boost/spirit/home/qi/operator/difference.hpp | 102 +++---
   branches/release/boost/spirit/home/qi/operator/expect.hpp | 45 ++
   branches/release/boost/spirit/home/qi/operator/kleene.hpp | 122 +++---
   branches/release/boost/spirit/home/qi/operator/list.hpp | 126 +++---
   branches/release/boost/spirit/home/qi/operator/not_predicate.hpp | 74 ++-
   branches/release/boost/spirit/home/qi/operator/optional.hpp | 106 +++---
   branches/release/boost/spirit/home/qi/operator/permutation.hpp | 123 ++++--
   branches/release/boost/spirit/home/qi/operator/plus.hpp | 123 +++---
   branches/release/boost/spirit/home/qi/operator/sequence.hpp | 42 ++
   branches/release/boost/spirit/home/qi/operator/sequence_base.hpp | 135 +++++--
   branches/release/boost/spirit/home/qi/operator/sequential_or.hpp | 112 ++++--
   branches/release/boost/spirit/home/qi/parse.hpp | 162 ++++----
   branches/release/boost/spirit/home/qi/stream.hpp | 16
   branches/release/boost/spirit/home/qi/stream/detail/match_manip.hpp | 111 ++++--
   branches/release/boost/spirit/home/qi/stream/match_manip.hpp | 154 +++++----
   branches/release/boost/spirit/home/qi/stream/stream.hpp | 84 +++-
   branches/release/boost/spirit/home/qi/string.hpp | 11
   branches/release/boost/spirit/home/qi/string/detail/tst.hpp | 207 ------------
   branches/release/boost/spirit/home/qi/what.hpp | 29
   branches/release/boost/spirit/home/support.hpp | 35 +
   branches/release/boost/spirit/home/support/algorithm/any.hpp | 10
   branches/release/boost/spirit/home/support/algorithm/any_if.hpp | 62 +--
   branches/release/boost/spirit/home/support/algorithm/any_ns.hpp | 8
   branches/release/boost/spirit/home/support/argument.hpp | 153 +-------
   branches/release/boost/spirit/home/support/char_class.hpp | 200 +++++++----
   branches/release/boost/spirit/home/support/detail/hold_any.hpp | 47 +-
   branches/release/boost/spirit/home/support/detail/integer/cover_operators.hpp | 48 ++
   branches/release/boost/spirit/home/support/detail/integer/endian.hpp | 330 ++++++++++++-------
   branches/release/boost/spirit/home/support/detail/lexer/char_traits.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/consts.hpp | 16
   branches/release/boost/spirit/home/support/detail/lexer/containers/ptr_list.hpp | 6
   branches/release/boost/spirit/home/support/detail/lexer/containers/ptr_vector.hpp | 6
   branches/release/boost/spirit/home/support/detail/lexer/conversion/char_state_machine.hpp | 4
   branches/release/boost/spirit/home/support/detail/lexer/debug.hpp | 205 +++++++----
   branches/release/boost/spirit/home/support/detail/lexer/file_input.hpp | 67 ++-
   branches/release/boost/spirit/home/support/detail/lexer/generate_cpp.hpp | 33 +
   branches/release/boost/spirit/home/support/detail/lexer/generator.hpp | 123 ++++--
   branches/release/boost/spirit/home/support/detail/lexer/input.hpp | 124 +++++--
   branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp | 42 -
   branches/release/boost/spirit/home/support/detail/lexer/parser/tokeniser/num_token.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/parser/tokeniser/re_tokeniser.hpp | 15
   branches/release/boost/spirit/home/support/detail/lexer/parser/tokeniser/re_tokeniser_helper.hpp | 132 +++---
   branches/release/boost/spirit/home/support/detail/lexer/parser/tokeniser/re_tokeniser_state.hpp | 5
   branches/release/boost/spirit/home/support/detail/lexer/parser/tree/end_node.hpp | 12
   branches/release/boost/spirit/home/support/detail/lexer/parser/tree/iteration_node.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/parser/tree/leaf_node.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/parser/tree/node.hpp | 10
   branches/release/boost/spirit/home/support/detail/lexer/parser/tree/selection_node.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/parser/tree/sequence_node.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/partition/charset.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/partition/equivset.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/rules.hpp | 340 +++++++++++++++++--
   branches/release/boost/spirit/home/support/detail/lexer/runtime_error.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/serialise.hpp | 19
   branches/release/boost/spirit/home/support/detail/lexer/size_t.hpp | 2
   branches/release/boost/spirit/home/support/detail/lexer/state_machine.hpp | 111 +++---
   branches/release/boost/spirit/home/support/detail/lexer/string_token.hpp | 7
   branches/release/boost/spirit/home/support/detail/math/detail/fp_traits.hpp | 4
   branches/release/boost/spirit/home/support/detail/math/fpclassify.hpp | 6
   branches/release/boost/spirit/home/support/detail/math/signbit.hpp | 4
   branches/release/boost/spirit/home/support/detail/what_function.hpp | 28
   branches/release/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp | 22
   branches/release/boost/spirit/home/support/iterators/detail/combine_policies.hpp | 181 +++++-----
   branches/release/boost/spirit/home/support/iterators/detail/first_owner_policy.hpp | 22
   branches/release/boost/spirit/home/support/iterators/detail/fixed_size_queue.hpp | 14
   branches/release/boost/spirit/home/support/iterators/detail/fixed_size_queue_policy.hpp | 24
   branches/release/boost/spirit/home/support/iterators/detail/functor_input_policy.hpp | 8
   branches/release/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp | 42 +-
   branches/release/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp | 18
   branches/release/boost/spirit/home/support/iterators/detail/multi_pass.hpp | 39 +-
   branches/release/boost/spirit/home/support/iterators/detail/no_check_policy.hpp | 9
   branches/release/boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp | 25
   branches/release/boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp | 34 -
   branches/release/boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp | 77 ++--
   branches/release/boost/spirit/home/support/iterators/look_ahead.hpp | 33 +
   branches/release/boost/spirit/home/support/iterators/multi_pass.hpp | 109 ++++-
   branches/release/boost/spirit/home/support/iterators/multi_pass_fwd.hpp | 56 ++
   branches/release/boost/spirit/home/support/nonterminal/locals.hpp | 29
   branches/release/boost/spirit/home/support/safe_bool.hpp | 50 --
   branches/release/boost/spirit/home/support/unused.hpp | 69 ++-
   branches/release/boost/spirit/include/karma.hpp | 10
   branches/release/boost/spirit/include/karma_action.hpp | 10
   branches/release/boost/spirit/include/karma_auxiliary.hpp | 10
   branches/release/boost/spirit/include/karma_binary.hpp | 10
   branches/release/boost/spirit/include/karma_char.hpp | 10
   branches/release/boost/spirit/include/karma_delimit.hpp | 12
   branches/release/boost/spirit/include/karma_directive.hpp | 10
   branches/release/boost/spirit/include/karma_domain.hpp | 10
   branches/release/boost/spirit/include/karma_generate.hpp | 10
   branches/release/boost/spirit/include/karma_nonterminal.hpp | 10
   branches/release/boost/spirit/include/karma_numeric.hpp | 10
   branches/release/boost/spirit/include/karma_operator.hpp | 10
   branches/release/boost/spirit/include/karma_stream.hpp | 10
   branches/release/boost/spirit/include/karma_string.hpp | 10
   branches/release/boost/spirit/include/karma_what.hpp | 10
   branches/release/boost/spirit/include/lex.hpp | 10
   branches/release/boost/spirit/include/lex_domain.hpp | 10
   branches/release/boost/spirit/include/lex_lexer.hpp | 10
   branches/release/boost/spirit/include/lex_tokenize_and_parse.hpp | 11
   branches/release/boost/spirit/include/phoenix.hpp | 4
   branches/release/boost/spirit/include/phoenix_algorithm.hpp | 4
   branches/release/boost/spirit/include/phoenix_bind.hpp | 4
   branches/release/boost/spirit/include/phoenix_container.hpp | 4
   branches/release/boost/spirit/include/phoenix_core.hpp | 4
   branches/release/boost/spirit/include/phoenix_function.hpp | 4
   branches/release/boost/spirit/include/phoenix_fusion.hpp | 4
   branches/release/boost/spirit/include/phoenix_object.hpp | 4
   branches/release/boost/spirit/include/phoenix_operator.hpp | 4
   branches/release/boost/spirit/include/phoenix_scope.hpp | 4
   branches/release/boost/spirit/include/phoenix_statement.hpp | 4
   branches/release/boost/spirit/include/phoenix_stl.hpp | 4
   branches/release/boost/spirit/include/phoenix_version.hpp | 4
   branches/release/boost/spirit/include/qi.hpp | 10
   branches/release/boost/spirit/include/qi_action.hpp | 10
   branches/release/boost/spirit/include/qi_auxiliary.hpp | 10
   branches/release/boost/spirit/include/qi_binary.hpp | 10
   branches/release/boost/spirit/include/qi_char.hpp | 10
   branches/release/boost/spirit/include/qi_directive.hpp | 10
   branches/release/boost/spirit/include/qi_domain.hpp | 10
   branches/release/boost/spirit/include/qi_nonterminal.hpp | 10
   branches/release/boost/spirit/include/qi_numeric.hpp | 10
   branches/release/boost/spirit/include/qi_operator.hpp | 10
   branches/release/boost/spirit/include/qi_parse.hpp | 10
   branches/release/boost/spirit/include/qi_skip.hpp | 12
   branches/release/boost/spirit/include/qi_stream.hpp | 10
   branches/release/boost/spirit/include/qi_string.hpp | 10
   branches/release/boost/spirit/include/qi_what.hpp | 10
   branches/release/boost/spirit/include/support.hpp | 10
   branches/release/boost/spirit/include/support_any.hpp | 10
   branches/release/boost/spirit/include/support_any_if.hpp | 10
   branches/release/boost/spirit/include/support_any_ns.hpp | 10
   branches/release/boost/spirit/include/support_argument.hpp | 10
   branches/release/boost/spirit/include/support_ascii.hpp | 12
   branches/release/boost/spirit/include/support_char_class.hpp | 10
   branches/release/boost/spirit/include/support_iso8859_1.hpp | 12
   branches/release/boost/spirit/include/support_locals.hpp | 10
   branches/release/boost/spirit/include/support_look_ahead.hpp | 10
   branches/release/boost/spirit/include/support_multi_pass.hpp | 10
   branches/release/boost/spirit/include/support_multi_pass_fwd.hpp | 10
   branches/release/boost/spirit/include/support_safe_bool.hpp | 10
   branches/release/boost/spirit/include/support_standard.hpp | 12
   branches/release/boost/spirit/include/support_standard_wide.hpp | 12
   branches/release/boost/spirit/include/support_unused.hpp | 10
   branches/release/boost/spirit/version.hpp | 8
   285 files changed, 12688 insertions(+), 7913 deletions(-)

Modified: branches/release/boost/spirit/home/classic/actor/ref_value_actor.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/actor/ref_value_actor.hpp (original)
+++ branches/release/boost/spirit/home/classic/actor/ref_value_actor.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -14,6 +14,11 @@
 
 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
     ///////////////////////////////////////////////////////////////////////////
     // Summary:
     // A semantic action policy holder. This holder stores a reference to ref.
@@ -65,6 +70,10 @@
 
 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
 }}
 
 #endif

Modified: branches/release/boost/spirit/home/classic/core/composite/actions.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/composite/actions.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/composite/actions.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -16,6 +16,11 @@
 
 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
     ///////////////////////////////////////////////////////////////////////////
     //
     // action class

Modified: branches/release/boost/spirit/home/classic/core/composite/alternative.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/composite/alternative.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/composite/alternative.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -39,6 +39,11 @@
     ///////////////////////////////////////////////////////////////////////////
     struct alternative_parser_gen;
     
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
     template <typename A, typename B>
     struct alternative
     : public binary<A, B, parser<alternative<A, B> > >
@@ -66,6 +71,10 @@
             return this->right().parse(scan);
         }
     };
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
     
     struct alternative_parser_gen
     {

Modified: branches/release/boost/spirit/home/classic/core/composite/composite.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/composite/composite.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/composite/composite.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -17,6 +17,11 @@
 
 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
     ///////////////////////////////////////////////////////////////////////////
     //
     // unary class.

Modified: branches/release/boost/spirit/home/classic/core/composite/difference.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/composite/difference.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/composite/difference.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -35,7 +35,12 @@
     //
     ///////////////////////////////////////////////////////////////////////////
     struct difference_parser_gen;
-
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
     template <typename A, typename B>
     struct difference
     : public binary<A, B, parser<difference<A, B> > >
@@ -69,6 +74,10 @@
             return scan.no_match();
         }
     };
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
     
     struct difference_parser_gen
     {

Modified: branches/release/boost/spirit/home/classic/core/composite/kleene_star.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/composite/kleene_star.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/composite/kleene_star.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -34,6 +34,11 @@
     ///////////////////////////////////////////////////////////////////////////
     struct kleene_star_parser_gen;
     
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
     template <typename S>
     struct kleene_star
     : public unary<S, parser<kleene_star<S> > >
@@ -70,6 +75,10 @@
         }
     };
     
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
     struct kleene_star_parser_gen
     {
         template <typename S>

Modified: branches/release/boost/spirit/home/classic/core/composite/positive.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/composite/positive.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/composite/positive.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -34,6 +34,11 @@
     ///////////////////////////////////////////////////////////////////////////
     struct positive_parser_gen;
     
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
     template <typename S>
     struct positive
     : public unary<S, parser<positive<S> > >
@@ -73,6 +78,10 @@
             return hit;
         }
     };
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
     
     struct positive_parser_gen
     {

Modified: branches/release/boost/spirit/home/classic/core/composite/sequence.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/composite/sequence.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/composite/sequence.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -36,6 +36,11 @@
     //////////////////////////////////////////////////////////////////////////
     struct sequence_parser_gen;
     
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
     template <typename A, typename B>
     struct sequence : public binary<A, B, parser<sequence<A, B> > >
     {
@@ -61,6 +66,10 @@
             return scan.no_match();
         }
     };
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
     
     struct sequence_parser_gen
     {

Modified: branches/release/boost/spirit/home/classic/core/non_terminal/impl/rule.ipp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/non_terminal/impl/rule.ipp (original)
+++ branches/release/boost/spirit/home/classic/core/non_terminal/impl/rule.ipp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -223,6 +223,11 @@
         // concrete_parser class
         //
         ///////////////////////////////////////////////////////////////////////
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
         template <typename ParserT, typename ScannerT, typename AttrT>
         struct concrete_parser : abstract_parser<ScannerT, AttrT>
         {
@@ -243,6 +248,10 @@
 
             typename ParserT::embed_t p;
         };
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
 
 #if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1
 

Modified: branches/release/boost/spirit/home/classic/core/primitives/impl/numerics.ipp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/primitives/impl/numerics.ipp (original)
+++ branches/release/boost/spirit/home/classic/core/primitives/impl/numerics.ipp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -151,6 +151,11 @@
         // initialized before calling this function.
         //
         ///////////////////////////////////////////////////////////////////////
+#if defined(BOOST_MSVC)
+#pragma warning(push)
+#pragma warning(disable:4127) //conditional expression is constant
+#endif
+
         template <typename T, int Radix>
         struct positive_accumulate
         {
@@ -351,11 +356,6 @@
         // real_parser_impl class
         //
         ///////////////////////////////////////////////////////////////////////
-#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
-#pragma warning(push)
-#pragma warning(disable:4127)
-#endif
-
         template <typename RT, typename T, typename RealPoliciesT>
         struct real_parser_impl
         {
@@ -464,7 +464,7 @@
             }
         };
 
-#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
+#if defined(BOOST_MSVC)
 #pragma warning(pop)
 #endif
 

Modified: branches/release/boost/spirit/home/classic/dynamic.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/dynamic.hpp (original)
+++ branches/release/boost/spirit/home/classic/dynamic.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -23,6 +23,8 @@
 #include <boost/spirit/home/classic/dynamic/lazy.hpp>
 #include <boost/spirit/home/classic/dynamic/stored_rule.hpp>
 #include <boost/spirit/home/classic/dynamic/rule_alias.hpp>
+#include <boost/spirit/home/classic/dynamic/select.hpp>
+#include <boost/spirit/home/classic/dynamic/switch.hpp>
 
 ////////////////////////////////////////////////////////////////////////////////
 #endif // BOOST_SPIRIT_DYNAMIC_HPP

Modified: branches/release/boost/spirit/home/classic/meta/refactoring.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/meta/refactoring.hpp (original)
+++ branches/release/boost/spirit/home/classic/meta/refactoring.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -21,6 +21,11 @@
 
 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 // refactor_unary_parser class
@@ -269,6 +274,10 @@
 
 const attach_action_gen<> attach_action_d = attach_action_gen<>();
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
 

Modified: branches/release/boost/spirit/home/classic/phoenix/actor.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/phoenix/actor.hpp (original)
+++ branches/release/boost/spirit/home/classic/phoenix/actor.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -124,6 +124,11 @@
 };
 
 //////////////////////////////////
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
 template <typename BaseT>
 struct actor : public BaseT {
 
@@ -270,6 +275,10 @@
     operator[](B const& b) const;
 };
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
 ///////////////////////////////////////////////////////////////////////////
 //
 // as_actor

Modified: branches/release/boost/spirit/home/classic/phoenix/closures.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/phoenix/closures.hpp (original)
+++ branches/release/boost/spirit/home/classic/phoenix/closures.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -21,6 +21,11 @@
 ///////////////////////////////////////////////////////////////////////////////
 namespace phoenix {
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 // Adaptable closures
@@ -431,6 +436,10 @@
     mutable holder_t frame;
 };
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
 }
    // namespace phoenix
 

Modified: branches/release/boost/spirit/home/classic/phoenix/composite.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/phoenix/composite.hpp (original)
+++ branches/release/boost/spirit/home/classic/phoenix/composite.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -14,6 +14,11 @@
 ///////////////////////////////////////////////////////////////////////////////
 namespace phoenix {
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 // composite class
@@ -1417,6 +1422,10 @@
 
 } // namespace impl
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
 } // namespace phoenix
 
 #endif

Modified: branches/release/boost/spirit/home/classic/phoenix/primitives.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/phoenix/primitives.hpp (original)
+++ branches/release/boost/spirit/home/classic/phoenix/primitives.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -196,6 +196,11 @@
 // a variable<T const&> object using a constant reference.
 //
 ///////////////////////////////////////////////////////////////////////////////
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
 template <typename T>
 struct variable {
 
@@ -215,6 +220,10 @@
     T& var;
 };
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
 //////////////////////////////////
 template <typename T>
 inline actor<variable<T> > const

Modified: branches/release/boost/spirit/home/classic/phoenix/tuples.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/phoenix/tuples.hpp (original)
+++ branches/release/boost/spirit/home/classic/phoenix/tuples.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -60,6 +60,11 @@
 #include <boost/call_traits.hpp>
 #include <boost/type_traits/remove_reference.hpp>
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 namespace phoenix {
 
@@ -1323,6 +1328,10 @@
 #endif
 #endif
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 } // namespace phoenix
 

Modified: branches/release/boost/spirit/home/classic/utility/confix.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/utility/confix.hpp (original)
+++ branches/release/boost/spirit/home/classic/utility/confix.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -36,6 +36,11 @@
 //
 ///////////////////////////////////////////////////////////////////////////////
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+
 template<typename NestedT = non_nested, typename LexemeT = non_lexeme>
 struct confix_parser_gen;
 
@@ -71,6 +76,10 @@
     typename as_parser<CloseT>::type::embed_t close;
 };
 
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 // Confix parser generator template

Modified: branches/release/boost/spirit/home/classic/utility/rule_parser.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/utility/rule_parser.hpp (original)
+++ branches/release/boost/spirit/home/classic/utility/rule_parser.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -419,7 +419,7 @@
           BOOST_SPIRIT_RP_EMIT(MV_STATIC,mbrs,BOOST_PP_IDENTITY(typename)) \
         public: \
           BOOST_TYPEOF_NESTED_TYPEDEF_TPL(__expr, \
- ::BOOST_SPIRIT_CLASSIC_NS::type_of::depend_on_type<__Dummy>(x) ) \
+ ::BOOST_SPIRIT_CLASSIC_NS::type_of::depend_on_type<__Dummy>(x) ) \
         }; \
                                                                                \
       public: \

Modified: branches/release/boost/spirit/home/karma.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma.hpp (original)
+++ branches/release/boost/spirit/home/karma.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,8 +6,8 @@
 #if !defined(SPIRIT_KARMA_CORE_MARCH_06_2007_0833PM)
 #define SPIRIT_KARMA_CORE_MARCH_06_2007_0833PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/char.hpp>
@@ -18,7 +18,12 @@
 #include <boost/spirit/home/karma/action.hpp>
 #include <boost/spirit/home/karma/directive.hpp>
 #include <boost/spirit/home/karma/auxiliary.hpp>
+#include <boost/spirit/home/karma/binary.hpp>
 #include <boost/spirit/home/karma/generate.hpp>
+#include <boost/spirit/home/karma/generate_attr.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
 #include <boost/spirit/home/karma/what.hpp>
+#include <boost/spirit/home/karma/stream.hpp>
 
 #endif

Modified: branches/release/boost/spirit/home/karma/action.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/action.hpp (original)
+++ branches/release/boost/spirit/home/karma/action.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,11 +6,10 @@
 #if !defined(BOOST_SPIRIT_KARMA_ACTION_MAR_04_2007_0912AM)
 #define BOOST_SPIRIT_KARMA_ACTION_MAR_04_2007_0912AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/action/action.hpp>
-#include <boost/spirit/home/karma/action/meta_grammar.hpp>
 
 #endif

Modified: branches/release/boost/spirit/home/karma/action/action.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/action/action.hpp (original)
+++ branches/release/boost/spirit/home/karma/action/action.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,84 +6,112 @@
 #if !defined(BOOST_SPIRIT_KARMA_ACTION_MAR_07_2007_0851AM)
 #define BOOST_SPIRIT_KARMA_ACTION_MAR_07_2007_0851AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/detail/values.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
-#include <boost/spirit/home/support/detail/action_dispatch.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/support/argument.hpp>
+#include <boost/spirit/home/support/context.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/action_dispatch.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/identity.hpp>
 #include <boost/type_traits/remove_const.hpp>
 #include <boost/type_traits/is_same.hpp>
-#include <vector>
 
 namespace boost { namespace spirit { namespace karma
 {
     ///////////////////////////////////////////////////////////////////////////
- struct sequence; // forward declaration only
-
- ///////////////////////////////////////////////////////////////////////////
- struct action
+ BOOST_PP_REPEAT(SPIRIT_ARGUMENTS_LIMIT, SPIRIT_USING_ARGUMENT, _)
+
+ template <typename Subject, typename Action>
+ struct action : unary_generator<action<Subject, Action> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+ typedef typename subject_type::properties properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::left<Component>::type,
- Context
- >
- {
- };
+ : traits::attribute_of<Subject, Context, Iterator>
+ {};
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
- {
- typedef typename
- result_of::left<Component>::type::director
- director;
- typedef typename is_same<director, sequence>::type is_sequence;
+ action(Subject const& subject, Action f)
+ : subject(subject), f(f) {}
 
- typedef typename
- attribute<Component, Context, unused_type>::type
- param_type;
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr_) const
+ {
+ typedef typename attribute<Context, unused_type>::type attr_type;
+ typedef traits::make_attribute<attr_type, Attribute> make_attribute;
 
- // create a parameter if one is not supplied
+ // create a attribute if none is supplied
             // this creates a _copy_ of the parameter because the semantic
             // action likely will change parts of this
- typename mpl::if_<
- is_same<typename remove_const<Parameter>::type, unused_type>,
- param_type,
- Parameter
- >::type p = spirit::detail::make_value<param_type>::call(param);
-
- // call the function, passing the parameter, the context
- // and a bool flag that the client can set to false to
- // fail generating.
- // The client can return false to fail parsing.
- bool pass = spirit::detail::action_dispatch(
- spirit::right(component), p, ctx, is_sequence());
+ typename make_attribute::value_type attr = make_attribute::call(attr_);
 
- return pass &&
- director::generate(spirit::left(component), sink, ctx, d, p);
+ // call the function, passing the attribute, the context and a bool
+ // flag that the client can set to false to fail generating.
+ // The client can return false to fail parsing.
+ return traits::action_dispatch<Subject>()(f, attr, ctx) &&
+ subject.generate(sink, ctx, d, attr);
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- typedef typename
- spirit::result_of::left<Component>::type::director
- director;
- return director::what(spirit::left(component), ctx);
+ // the action is transparent (does not add any info)
+ return subject.what(context);
         }
+
+ subject_type subject;
+ Action f;
     };
 
 }}}
 
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Karma action meta-compiler
+ template <>
+ struct make_component<karma::domain, tag::action>
+ {
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Elements, typename Modifiers>
+ struct result<This(Elements, Modifiers)>
+ {
+ typedef typename
+ remove_const<typename Elements::car_type>::type
+ subject_type;
+
+ typedef typename
+ remove_const<typename Elements::cdr_type::car_type>::type
+ action_type;
+
+ typedef karma::action<subject_type, action_type> type;
+ };
+
+ template <typename Elements>
+ typename result<make_component(Elements, unused_type)>::type
+ operator()(Elements const& elements, unused_type) const
+ {
+ typename result<make_component(Elements, unused_type)>::type
+ result(elements.car, elements.cdr.car);
+ return result;
+ }
+ };
+}}
+
 #endif

Deleted: branches/release/boost/spirit/home/karma/action/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/action/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,70 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_META_GRAMMAR_MAR_04_2007_0907AM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_MAR_04_2007_0907AM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/utility/enable_if.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- struct action;
-
- struct main_meta_grammar;
-
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // action meta-grammar
- ///////////////////////////////////////////////////////////////////////////
- struct action_meta_grammar :
- meta_grammar::binary_rule<
- karma::domain, proto::tag::subscript, action,
- main_meta_grammar, proto::when<proto::_, proto::_child>
- >
- {
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hooks into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<
- Expr,
- typename enable_if<
- proto::matches<Expr, action_meta_grammar>
- >::type
- >
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<
- Expr,
- typename enable_if<
- proto::matches<Expr, action_meta_grammar>
- >::type
- >
- : mpl::identity<action_meta_grammar>
- {
- };
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/auxiliary.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary.hpp (original)
+++ branches/release/boost/spirit/home/karma/auxiliary.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,13 +6,12 @@
 #if !defined(BOOST_SPIRIT_KARMA_AUXILIARY_MAR_26_2007_1225PM)
 #define BOOST_SPIRIT_KARMA_AUXILIARY_MAR_26_2007_1225PM
 
-#include <boost/spirit/home/karma/auxiliary/none.hpp>
-#include <boost/spirit/home/karma/auxiliary/confix.hpp>
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
 #include <boost/spirit/home/karma/auxiliary/eps.hpp>
 #include <boost/spirit/home/karma/auxiliary/eol.hpp>
 #include <boost/spirit/home/karma/auxiliary/lazy.hpp>
-#include <boost/spirit/home/karma/auxiliary/functor.hpp>
-#include <boost/spirit/home/karma/auxiliary/functor_director.hpp>
-#include <boost/spirit/home/karma/auxiliary/meta_grammar.hpp>
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/auxiliary/confix.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/confix.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,121 +0,0 @@
-// Copyright (c) 2001-2008 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_KARMA_CONFIX_AUG_19_2008_1041AM)
-#define BOOST_SPIRIT_KARMA_CONFIX_AUG_19_2008_1041AM
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
-#include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/auxiliary/confix.hpp>
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // the director for a confix() generated generator
- struct confix_director
- {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef typename
- result_of::subject<Component>::type
- subject_type;
-
- typedef typename
- traits::attribute_of<karma::domain, subject_type, Context>::type
- type;
- };
-
- private:
- ///////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Context,
- typename Delimiter, typename Expr>
- static void
- generate_helper(OutputIterator& sink, Context& ctx, Delimiter const& d,
- Expr const& e)
- {
- BOOST_MPL_ASSERT_MSG(
- (spirit::traits::is_component<karma::domain, Expr>::value),
- expression_is_not_convertible_to_a_generator, (Context, Expr));
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- expr;
-
- expr eg = spirit::as_component(karma::domain(), e);
- typedef typename expr::director director;
- director::generate(eg, sink, ctx, d, unused);
- }
-
- template <typename Context, typename Expr>
- static std::string what_helper(Expr const& e, Context& ctx)
- {
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- expr;
-
- expr eg = spirit::as_component(karma::domain(), e);
- typedef typename expr::director director;
- return director::what(eg, ctx);
- }
-
- public:
- ///////////////////////////////////////////////////////////////////////
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
- {
- // generate the prefix
- generate_helper(sink, ctx, d,
- spirit::detail::confix_extractor::prefix(
- proto::child_c<0>(spirit::argument1(component))));
-
- // generate the embedded items
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
- bool result = director::generate(spirit::subject(component), sink,
- ctx, d, param);
-
- // append the suffix
- generate_helper(sink, ctx, d,
- spirit::detail::confix_extractor::suffix(
- proto::child_c<0>(spirit::argument1(component))));
-
- return result;
- }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- std::string result = "confix(";
-
- result += what_helper(spirit::detail::confix_extractor::prefix(
- proto::child_c<0>(spirit::argument1(component))), ctx);
- result += ", ";
-
- result += what_helper(spirit::detail::confix_extractor::suffix(
- proto::child_c<0>(spirit::argument1(component))), ctx);
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
- result += director::what(spirit::subject(component), ctx);
- result += "]";
-
- return result;
- }
- };
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/auxiliary/eol.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/eol.hpp (original)
+++ branches/release/boost/spirit/home/karma/auxiliary/eol.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2008 Hartmut Kaiser
+// Copyright (c) 2001-2009 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)
@@ -6,36 +6,71 @@
 #if !defined(BOOST_SPIRIT_KARMA_EOL_JUL_08_2008_1014AM)
 #define BOOST_SPIRIT_KARMA_EOL_JUL_08_2008_1014AM
 
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
 #include <boost/spirit/home/karma/detail/generate_to.hpp>
 
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, tag::eol> // enables eol
+ : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
- struct eol_generator
+ using boost::spirit::eol;
+ using boost::spirit::eoi_type;
+
+ struct eol_generator : primitive_generator<eol_generator>
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef unused_type type;
         };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ static bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr)
+ {
+ return detail::generate_to(sink, '\n') &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
+
+ template <typename Context>
+ info what(Context const& ctx) const
         {
- detail::generate_to(sink, '\n');
- karma::delimit(sink, d); // always do post-delimiting
- return true;
+ return info("eol");
         }
+ };
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers>
+ struct make_primitive<tag::eol, Modifiers>
+ {
+ typedef eol_generator result_type;
+ result_type operator()(unused_type, unused_type) const
         {
- return "eol";
+ return result_type();
         }
     };
 

Modified: branches/release/boost/spirit/home/karma/auxiliary/eps.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/eps.hpp (original)
+++ branches/release/boost/spirit/home/karma/auxiliary/eps.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,60 +6,127 @@
 #if !defined(BOOST_SPIRIT_KARMA_EPS_APRIL_21_2007_0246PM)
 #define BOOST_SPIRIT_KARMA_EPS_APRIL_21_2007_0246PM
 
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/fusion/include/at.hpp>
 
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+
+ // enables eps
+ template <>
+ struct use_terminal<karma::domain, tag::eps>
+ : mpl::true_ {};
+
+ // enables eps(bool-condition)
+ template <typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::eps, fusion::vector1<A0> > >
+ : is_convertible<A0, bool> {};
+
+ // enables lazy eps(f)
+ template <>
+ struct use_lazy_terminal<karma::domain, tag::eps, 1>
+ : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
- struct eps_generator
+ using boost::spirit::eps;
+ using boost::spirit::eps_type;
+
+ struct eps_generator : primitive_generator<eps_generator>
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef unused_type type;
         };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ static bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr)
         {
- karma::delimit(sink, d);
- return true;
+ return karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context const& ctx) const
         {
- return "eps";
+ return info("eps");
         }
     };
 
- struct semantic_predicate
+ struct semantic_predicate : primitive_generator<semantic_predicate>
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef unused_type type;
         };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& /*param*/)
+ semantic_predicate(bool predicate)
+ : predicate_(predicate)
+ {}
+
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ // only do post-delimiting when predicate is true
+ return predicate_ && karma::delimit_out(sink, d);
+ }
+
+ template <typename Context>
+ info what(Context const& ctx) const
         {
- karma::delimit(sink, d);
- return fusion::at_c<0>(component.elements)(unused, ctx);
+ return info("semantic-predicate");
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ bool predicate_;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers>
+ struct make_primitive<tag::eps, Modifiers>
+ {
+ typedef eps_generator result_type;
+ result_type operator()(unused_type, unused_type) const
+ {
+ return result_type();
+ }
+ };
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::eps, fusion::vector1<A0> >
+ , Modifiers>
+ {
+ typedef semantic_predicate result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return "semantic-predicate";
+ return result_type(fusion::at_c<0>(term.args));
         }
     };
 

Deleted: branches/release/boost/spirit/home/karma/auxiliary/functor.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/functor.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,213 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_FUNCTOR_APR_01_2007_1038AM)
-#define BOOST_SPIRIT_KARMA_FUNCTOR_APR_01_2007_1038AM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/auxiliary/functor_holder.hpp>
-#include <boost/spirit/home/support/auxiliary/meta_function_holder.hpp>
-#include <boost/spirit/home/support/detail/values.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/lambda.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/remove_const.hpp>
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit
-{
- namespace karma
- {
- template <typename Functor, typename ParameterMF = Functor>
- class functor_generator;
- }
-
- namespace result_of
- {
- template <typename Functor>
- struct as_generator
- {
- typedef karma::functor_generator<Functor> type;
- };
-
- template <typename Functor, typename ParameterMF>
- struct as_generator_mf
- {
- typedef karma::functor_generator<Functor, ParameterMF> type;
- };
- }
-
-}} // boost::spirit
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // This struct may be used as a base class for a user defined functor
- ///////////////////////////////////////////////////////////////////////////
- struct functor_base
- {
- ///////////////////////////////////////////////////////////////////////
- // The return value of a karma functor is always bool
- ///////////////////////////////////////////////////////////////////////
- template <typename Parameter, typename OutputIterator>
- struct result
- {
- typedef bool type;
- };
-
-// FIXME: It will be possible to specify the return value as a typedef, but for
-// that Phoenix will have to be fixed.
-// typedef bool result_type;
-
- ///////////////////////////////////////////////////////////////////////
- // The expected parameter type of a functor has to be defined using a
- // embedded apply metafunction. Normally this will be overloaded by
- // the derived class, but the default is unused type.
- ///////////////////////////////////////////////////////////////////////
- template <typename Context>
- struct apply
- {
- typedef spirit::unused_type type;
- };
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // The functor generator template may be used to create new generators
- // without having to dig into the implementation details of Karma
- ///////////////////////////////////////////////////////////////////////////
- template <typename Functor, typename ParameterMF>
- class functor_generator
- : public proto::extends<
- typename make_functor_holder<
- functor_generator<Functor, ParameterMF> const*,
- functor_generator<Functor, ParameterMF>
- >::type,
- functor_generator<Functor, ParameterMF>
- >
- {
- private:
- typedef functor_generator<Functor, ParameterMF> self_type;
- typedef typename
- make_functor_holder<self_type const*, self_type>::type
- functor_tag;
- typedef proto::extends<functor_tag, self_type> base_type;
-
- public:
- template <typename Context>
- struct result
- : mpl::apply<ParameterMF, Context>
- {};
-
- private:
- // generate function just delegates to the functor supplied function
- template <typename OutputIterator, typename Context, typename Parameter>
- bool
- generate (OutputIterator& sink, Context& ctx, Parameter const& p) const
- {
- // create an attribute if none is supplied
- typedef typename result<Context>::type parameter_type;
- typename mpl::if_<
- is_same<typename remove_const<Parameter>::type, unused_type>,
- parameter_type,
- Parameter const&
- >::type
- param = spirit::detail::make_value<parameter_type>::call(p);
-
- return functor(param, ctx, sink);
- }
-
- friend struct functor_director;
-
- public:
- explicit functor_generator()
- : base_type(make_tag())
- {
- }
-
- functor_generator(Functor const& functor_)
- : base_type(make_tag()), functor(functor_)
- {
- }
-
- functor_generator(Functor const& functor_, ParameterMF const& mf)
- : base_type(make_tag()), functor(functor_), mf_(mf)
- {
- }
-
- private:
- functor_tag make_tag() const
- {
- functor_tag xpr = {{ this }};
- return xpr;
- }
-
- Functor functor;
- meta_function_holder<Functor, ParameterMF> mf_;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // The as_generator generator function may be used to create a functor
- // generator from a function object (some callable item).
- // The supplied functor needs to expose
- //
- // - an embedded result meta function:
- //
- // template <typename Parameter, typename OutputIterator>
- // struct result
- // {
- // typedef bool type;
- // };
- //
- // which declares 'bool' as the result type of the defined function
- // operator and
- //
- // - an embedded apply meta function:
- //
- // template <typename Context>
- // struct apply
- // {
- // typedef unspecified type;
- // };
- //
- // which declares the given type as the expected attribute type for
- // the generator to create.
- ///////////////////////////////////////////////////////////////////////////
- template <typename Functor>
- inline typename result_of::as_generator<Functor>::type
- as_generator(Functor const& func)
- {
- return functor_generator<Functor>(func);
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // The as_generator_mf generator function is equivalent to the function
- // as_generator above except that the user has to explicitly specify a
- // type exposing an embedded apply meta function declaring the expected
- // parameter type for the generator to create.
- ///////////////////////////////////////////////////////////////////////////
- template <typename ParameterMF, typename Functor>
- inline typename result_of::as_generator_mf<Functor, ParameterMF>::type
- as_generator_mf(Functor const& func, ParameterMF const& mf)
- {
- return functor_generator<Functor, ParameterMF>(func, mf);
- }
-
- template <typename ParameterMF, typename Functor>
- inline typename result_of::as_generator_mf<Functor, ParameterMF>::type
- as_generator_mf(Functor const& func)
- {
- return functor_generator<Functor, ParameterMF>(func, ParameterMF());
- }
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/karma/auxiliary/functor_director.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/functor_director.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,53 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_FUNCTOR_DIRECTOR_APR_01_2007_1041AM)
-#define BOOST_SPIRIT_KARMA_FUNCTOR_DIRECTOR_APR_01_2007_1041AM
-
-#include <boost/spirit/home/support/auxiliary/functor_holder.hpp>
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- // this is the director for all functor generators
- struct functor_director
- {
- // expected value type of the generator
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef typename
- result_of::subject<Component>::type::functor_holder
- functor_holder;
- typedef typename functor_holder::functor_type functor_type;
-
- typedef typename
- functor_type::template result<Context>::type
- type;
- };
-
- // generate functionality, delegates back to the corresponding functor
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
- {
- bool result = subject(component).held->generate(sink, ctx, param);
- karma::delimit(sink, d); // always do post-delimiting
- return result;
- }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- return "functor";
- }
- };
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/auxiliary/lazy.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/lazy.hpp (original)
+++ branches/release/boost/spirit/home/karma/auxiliary/lazy.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,5 @@
 // Copyright (c) 2001-2009 Hartmut Kaiser
+// Copyright (c) 2001-2009 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)
@@ -6,84 +7,222 @@
 #if !defined(BOOST_SPIRIT_KARMA_LAZY_MARCH_27_2007_1231PM)
 #define BOOST_SPIRIT_KARMA_LAZY_MARCH_27_2007_1231PM
 
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
 #include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/lazy.hpp>
+#include <boost/spirit/home/phoenix/core/actor.hpp>
 #include <boost/fusion/include/at.hpp>
 #include <boost/utility/result_of.hpp>
 #include <boost/type_traits/remove_reference.hpp>
+#include <boost/mpl/not.hpp>
+
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Eval>
+ struct use_terminal<karma::domain, phoenix::actor<Eval> > // enables phoenix actors
+ : mpl::true_ {};
+
+ // forward declaration
+ template <typename Terminal, typename Actor, int Arity>
+ struct lazy_terminal;
+
+}}
 
 namespace boost { namespace spirit { namespace karma
 {
- struct lazy_generator
+ using spirit::lazy;
+ typedef modify<karma::domain> karma_modify;
+
+ template <typename Function, typename Modifiers>
+ struct lazy_generator : generator<lazy_generator<Function, Modifiers> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef mpl::int_<generator_properties::all_properties> properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
         {
             typedef typename
- result_of::subject<Component>::type
- subject_type;
+ boost::result_of<karma_modify(tag::lazy_eval, Modifiers)>::type
+ modifier;
 
             typedef typename
                 remove_reference<
- typename boost::result_of<
- subject_type(unused_type, Context)
- >::type
+ typename boost::result_of<Function(unused_type, Context)>::type
>::type
             expr_type;
 
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr_type) is not a valid spirit karma
+ // expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, expr_type);
+
             typedef typename
- result_of::as_component<karma::domain, expr_type>::type
- component_type;
+ result_of::compile<karma::domain, expr_type, modifier>::type
+ generator_type;
 
             typedef typename
- traits::attribute_of<
- karma::domain, component_type, Context>::type
+ traits::attribute_of<generator_type, Context, Iterator>::type
             type;
         };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ lazy_generator(Function const& func, Modifiers const& modifiers)
+ : func(func), modifiers(modifiers) {}
+
+ template <
+ typename OutputIterator, typename Context,
+ typename Delimiter, typename Attribute
+ >
+ bool generate(OutputIterator& sink, Context& context,
+ Delimiter const& d, Attribute const& attr) const
+ {
+ return compile<karma::domain>(func(unused, context)
+ , karma_modify()(tag::lazy_eval(), modifiers))
+ .generate(sink, context, d, attr);
+ }
+
+ template <typename Context>
+ info what(Context& context) const
+ {
+ return info("lazy"
+ , compile<karma::domain>(func(unused, context)
+ , karma_modify()(tag::lazy_eval(), modifiers))
+ .what(context)
+ );
+ }
+
+ Function func;
+ Modifiers modifiers;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Function, typename Subject, typename Modifiers>
+ struct lazy_directive
+ : unary_generator<lazy_directive<Function, Subject, Modifiers> >
+ {
+ typedef mpl::int_<generator_properties::all_properties> properties;
+
+ typedef Subject subject_type;
+
+ template <typename Context, typename Iterator>
+ struct attribute
         {
             typedef typename
- result_of::subject<Component>::type
- subject_type;
+ boost::result_of<karma_modify(tag::lazy_eval, Modifiers)>::type
+ modifier;
 
             typedef typename
                 remove_reference<
- typename boost::result_of<
- subject_type(unused_type, Context)
- >::type
+ typename boost::result_of<Function(unused_type, Context)>::type
+ >::type
+ directive_expr_type;
+
+ typedef typename
+ proto::result_of::make_expr<
+ proto::tag::subscript
+ , directive_expr_type
+ , Subject
>::type
             expr_type;
 
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr_type) is not a valid spirit karma
+ // expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, expr_type);
+
             typedef typename
- result_of::as_component<karma::domain, expr_type>::type
- component_type;
+ result_of::compile<karma::domain, expr_type, modifier>::type
+ generator_type;
 
- component_type subject
- = spirit::as_component(
- karma::domain(),
- fusion::at_c<0>(component.elements)(unused, ctx));
-
- return component_type::director::
- generate(subject, sink, ctx, d, param);
- }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- std::string result = "lazy[";
- // FIXME: need to get at the what of the embedded component
- result += "...";
- result += "]";
- return result;
+ typedef typename
+ traits::attribute_of<generator_type, Context, Iterator>::type
+ type;
+ };
+
+ lazy_directive(Function const& function, Subject const& subject
+ , Modifiers const& modifiers)
+ : function(function), subject(subject), modifiers(modifiers) {}
+
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ return compile<karma::domain>(
+ proto::make_expr<proto::tag::subscript>(
+ function(unused, ctx), subject)
+ , karma_modify()(tag::lazy_eval(), modifiers))
+ .generate(sink, ctx, d, attr);
         }
+
+ template <typename Context>
+ info what(Context& ctx) const
+ {
+ return info("lazy-directive"
+ , compile<karma::domain>(
+ proto::make_expr<proto::tag::subscript>(
+ function(unused, ctx), subject)
+ , karma_modify()(tag::lazy_eval(), modifiers))
+ .what(ctx)
+ );
+ }
+
+ Function function;
+ Subject subject;
+ Modifiers modifiers;
     };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Eval, typename Modifiers>
+ struct make_primitive<phoenix::actor<Eval>, Modifiers>
+ {
+ typedef lazy_generator<phoenix::actor<Eval>, Modifiers> result_type;
+ result_type operator()(phoenix::actor<Eval> const& f
+ , Modifiers const& modifiers) const
+ {
+ return result_type(f, modifiers);
+ }
+ };
+
+ template <typename Terminal, typename Actor, int Arity, typename Modifiers>
+ struct make_primitive<lazy_terminal<Terminal, Actor, Arity>, Modifiers>
+ {
+ typedef lazy_generator<Actor, Modifiers> result_type;
+ result_type operator()(
+ lazy_terminal<Terminal, Actor, Arity> const& lt
+ , Modifiers const& modifiers) const
+ {
+ return result_type(lt.actor, modifiers);
+ }
+ };
+
+ template <
+ typename Terminal, typename Actor, int Arity, typename Subject
+ , typename Modifiers>
+ struct make_directive<lazy_terminal<Terminal, Actor, Arity>
+ , Subject, Modifiers>
+ {
+ typedef lazy_directive<Actor, Subject, Modifiers> result_type;
+ result_type operator()(
+ lazy_terminal<Terminal, Actor, Arity> const& lt
+ , Subject const& subject, Modifiers const& modifiers) const
+ {
+ return result_type(lt.actor, subject, modifiers);
+ }
+ };
+
 }}}
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/auxiliary/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,106 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_META_GRAMMAR_MARCH_26_2007_1230PM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_MARCH_26_2007_1230PM
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/placeholders.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/utility/enable_if.hpp>
-
-namespace boost { namespace spirit
-{
- template <typename T, typename Functor>
- struct functor_holder;
-}}
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- struct main_meta_grammar;
-
- struct none;
- struct eps_generator;
- struct eol_generator;
- struct semantic_predicate;
- struct lazy_generator;
- struct functor_director;
- struct confix_director;
-
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // auxiliary generators meta-grammar
- ///////////////////////////////////////////////////////////////////////////
-
- // none, and lazy
- struct auxiliary_meta_grammar
- : proto::or_<
- // none
- meta_grammar::empty_terminal_rule<
- karma::domain, tag::none, none>,
- // eps
- meta_grammar::empty_terminal_rule<
- karma::domain, tag::eps, eps_generator>,
- // eol
- meta_grammar::empty_terminal_rule<
- karma::domain, tag::eol, eol_generator>,
- // eps(...)
- meta_grammar::function1_rule<
- karma::domain, tag::eps, semantic_predicate>,
- // lazy(...)
- meta_grammar::function1_rule<
- karma::domain, tag::lazy, lazy_generator>,
- // functor generators
- meta_grammar::terminal_rule<
- karma::domain,
- functor_holder<proto::_, proto::_>,
- functor_director
- >,
- // confix("...", "...")[...]
- meta_grammar::subscript_rule<
- karma::domain, tag::confix_tag<proto::_, proto::_>,
- confix_director, main_meta_grammar
- >
- >
- {
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hooks into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<
- Expr,
- typename enable_if<
- proto::matches<Expr, auxiliary_meta_grammar>
- >::type
- >
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<
- Expr,
- typename enable_if<
- proto::matches<Expr, auxiliary_meta_grammar>
- >::type
- >
- : mpl::identity<auxiliary_meta_grammar>
- {
- };
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/karma/auxiliary/none.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/auxiliary/none.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,42 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_NONE_MARCH_26_2007_1227PM)
-#define BOOST_SPIRIT_KARMA_NONE_MARCH_26_2007_1227PM
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
-#include <boost/spirit/home/support/unused.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- struct none
- {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef unused_type type;
- };
-
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
- {
- karma::delimit(sink, d); // always do post-delimiting
- return false;
- }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- return "none";
- }
- };
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/binary.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/binary.hpp (original)
+++ branches/release/boost/spirit/home/karma/binary.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,12 +6,11 @@
 #if !defined(BOOST_SPIRIT_KARMA_BINARY_MAY_04_2007_0859AM)
 #define BOOST_SPIRIT_KARMA_BINARY_MAY_04_2007_0859AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/binary/binary.hpp>
 #include <boost/spirit/home/karma/binary/padding.hpp>
-#include <boost/spirit/home/karma/binary/meta_grammar.hpp>
 
 #endif

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,30 +6,102 @@
 #if !defined(BOOST_SPIRIT_KARMA_BINARY_MAY_04_2007_0904AM)
 #define BOOST_SPIRIT_KARMA_BINARY_MAY_04_2007_0904AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/detail/integer/endian.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/detail/endian.hpp>
+
 #include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
 #include <boost/spirit/home/karma/detail/generate_to.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/fusion/include/vector.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/is_enum.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+#define BOOST_SPIRIT_ENABLE_BINARY(name) \
+ template <> \
+ struct use_terminal<karma::domain, tag::name> \
+ : mpl::true_ {}; \
+ \
+ template <typename A0> \
+ struct use_terminal<karma::domain \
+ , terminal_ex<tag::name, fusion::vector1<A0> > > \
+ : mpl::or_<is_integral<A0>, is_enum<A0> > {}; \
+ \
+ template <> \
+ struct use_lazy_terminal<karma::domain, tag::name, 1> : mpl::true_ {}; \
+ \
+/***/
 
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+
+ BOOST_SPIRIT_ENABLE_BINARY(byte_) // enables byte_
+ BOOST_SPIRIT_ENABLE_BINARY(word) // enables word
+ BOOST_SPIRIT_ENABLE_BINARY(big_word) // enables big_word
+ BOOST_SPIRIT_ENABLE_BINARY(little_word) // enables little_word
+ BOOST_SPIRIT_ENABLE_BINARY(dword) // enables dword
+ BOOST_SPIRIT_ENABLE_BINARY(big_dword) // enables big_dword
+ BOOST_SPIRIT_ENABLE_BINARY(little_dword) // enables little_dword
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_SPIRIT_ENABLE_BINARY(qword) // enables qword
+ BOOST_SPIRIT_ENABLE_BINARY(big_qword) // enables big_qword
+ BOOST_SPIRIT_ENABLE_BINARY(little_qword) // enables little_qword
+#endif
+
+}}
+
+#undef BOOST_SPIRIT_ENABLE_BINARY
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
+ using boost::spirit::byte_;
+ using boost::spirit::byte__type;
+ using boost::spirit::word;
+ using boost::spirit::word_type;
+ using boost::spirit::big_word;
+ using boost::spirit::big_word_type;
+ using boost::spirit::little_word;
+ using boost::spirit::little_word_type;
+ using boost::spirit::dword;
+ using boost::spirit::dword_type;
+ using boost::spirit::big_dword;
+ using boost::spirit::big_dword_type;
+ using boost::spirit::little_dword;
+ using boost::spirit::little_dword_type;
+#ifdef BOOST_HAS_LONG_LONG
+ using boost::spirit::qword;
+ using boost::spirit::qword_type;
+ using boost::spirit::big_qword;
+ using boost::spirit::big_qword_type;
+ using boost::spirit::little_qword;
+ using boost::spirit::little_qword_type;
+#endif
+
     namespace detail
     {
         template <int bits>
         struct integer
         {
 #ifdef BOOST_HAS_LONG_LONG
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 bits == 8 || bits == 16 || bits == 32 || bits == 64,
                 not_supported_binary_size, ());
 #else
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 bits == 8 || bits == 16 || bits == 32,
                 not_supported_binary_size, ());
 #endif
@@ -62,124 +134,200 @@
 #endif
 
         ///////////////////////////////////////////////////////////////////////
- template <boost::integer::endianness bits>
+ template <BOOST_SCOPED_ENUM(boost::integer::endianness) bits>
         struct what;
 
         template <>
- struct what<boost::integer::native>
+ struct what<boost::integer::endianness::native>
         {
- static std::string is()
+ static info is()
             {
- return "native-endian binary";
+ return info("native-endian binary");
             }
         };
 
         template <>
- struct what<boost::integer::little>
+ struct what<boost::integer::endianness::little>
         {
- static char const* is()
+ static info is()
             {
- return "little-endian binary";
+ return info("little-endian binary");
             }
         };
 
         template <>
- struct what<boost::integer::big>
+ struct what<boost::integer::endianness::big>
         {
- static char const* is()
+ static info is()
             {
- return "big-endian binary";
+ return info("big-endian binary");
             }
         };
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template <integer::endianness endian, int bits>
- struct any_binary_director
+ template <BOOST_SCOPED_ENUM(boost::integer::endianness) endian, int bits>
+ struct any_binary_generator
+ : primitive_generator<any_binary_generator<endian, bits> >
     {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef boost::integer::endian<
+ template <typename Context, typename Unused = unused_type>
+ struct attribute
+ : karma::detail::integer<bits>
+ {};
+
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ static bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr)
+ {
+ // Even if the endian types are not pod's (at least not in the
+ // definition of C++03) it seems to be safe to assume they are.
+ // This allows us to treat them as a sequence of consecutive bytes.
+ boost::integer::endian<
                 endian, typename karma::detail::integer<bits>::type, bits
- > type;
- };
-
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
- {
- typename traits::attribute_of<
- karma::domain, Component, Context>::type p (param);
+ > p;
+ p = attr;
             unsigned char const* bytes =
                 reinterpret_cast<unsigned char const*>(&p);
 
- for (unsigned int i = 0; i < sizeof(p); ++i)
- detail::generate_to(sink, *bytes++);
-
- karma::delimit(sink, d); // always do post-delimiting
- return true;
+ for (unsigned int i = 0; i < sizeof(p); ++i)
+ {
+ if (!detail::generate_to(sink, *bytes++))
+ return false;
+ }
+ return karma::delimit_out(sink, d); // always do post-delimiting
         }
 
         // this any_byte_director has no parameter attached, it needs to have
         // been initialized from a direct literal
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
- static bool
- generate(Component const&, OutputIterator&, Context&, Delimiter const&,
- unused_type)
+ template <
+ typename OutputIterator, typename Context, typename Delimiter>
+ static bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false,
+ BOOST_SPIRIT_ASSERT_MSG(false,
                 binary_generator_not_usable_without_attribute, ());
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
             return karma::detail::what<endian>::is();
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////
- template <integer::endianness endian, int bits>
- struct binary_lit_director
+ template <BOOST_SCOPED_ENUM(boost::integer::endianness) endian, int bits>
+ struct literal_binary_generator
+ : primitive_generator<literal_binary_generator<endian, bits> >
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef unused_type type;
         };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
+ template <typename T>
+ literal_binary_generator(T const& t)
         {
- boost::integer::endian<
- endian, typename karma::detail::integer<bits>::type, bits
- > p (fusion::at_c<0>(component.elements));
+ data_ = t;
+ }
 
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ // Even if the endian types are not pod's (at least not in the
+ // definition of C++03) it seems to be safe to assume they are
+ // (but in C++0x the endian types _are_ PODs).
+ // This allows us to treat them as a sequence of consecutive bytes.
             unsigned char const* bytes =
- reinterpret_cast<unsigned char const*>(&p);
+ reinterpret_cast<unsigned char const*>(&data_);
 
- for (unsigned int i = 0; i < sizeof(p); ++i)
- detail::generate_to(sink, *bytes++);
-
- karma::delimit(sink, d); // always do post-delimiting
- return true;
+ for (unsigned int i = 0; i < sizeof(data_type); ++i)
+ {
+ if (!detail::generate_to(sink, *bytes++))
+ return false;
+ }
+ return karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
             return karma::detail::what<endian>::is();
         }
+
+ typedef boost::integer::endian<
+ endian, typename karma::detail::integer<bits>::type, bits
+ > data_type;
+
+ data_type data_;
     };
 
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ template <BOOST_SCOPED_ENUM(boost::integer::endianness) endian
+ , int bits>
+ struct basic_binary
+ {
+ typedef any_binary_generator<endian, bits> result_type;
+
+ result_type operator()(unused_type, unused_type) const
+ {
+ return result_type();
+ }
+ };
+
+ template <typename Modifiers
+ , BOOST_SCOPED_ENUM(boost::integer::endianness) endian, int bits>
+ struct basic_binary_literal
+ {
+ typedef literal_binary_generator<endian, bits> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
+ }
+ };
+ }
+
+#define BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(name, endian, bits) \
+ template <typename Modifiers> \
+ struct make_primitive<tag::name, Modifiers> \
+ : detail::basic_binary<boost::integer::endianness::endian, bits> {}; \
+ \
+ template <typename Modifiers, typename A0> \
+ struct make_primitive<terminal_ex<tag::name, fusion::vector1<A0> > \
+ , Modifiers> \
+ : detail::basic_binary_literal<Modifiers \
+ , boost::integer::endianness::endian, bits> {}; \
+ \
+ /***/
+
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(byte_, native, 8)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(word, native, 16)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(big_word, big, 16)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(little_word, little, 16)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(dword, native, 32)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(big_dword, big, 32)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(little_dword, little, 32)
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(qword, native, 64)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(big_qword, big, 64)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(little_qword, little, 64)
+#endif
+
+#undef BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE
+
 }}}
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/binary/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/binary/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,264 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_META_GRAMMAR_MAY_04_2007_0853AM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_MAY_04_2007_0853AM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/placeholders.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/spirit/home/support/detail/integer/endian.hpp>
-#include <boost/mpl/identity.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/utility/enable_if.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- template <integer::endianness endian, int bits>
- struct any_binary_director;
-
- template <integer::endianness endian, int bits>
- struct binary_lit_director;
-
- struct binary_padding_director;
-
- struct main_meta_grammar;
-
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of an integer based binary literal type
- ///////////////////////////////////////////////////////////////////////////
- template <typename T>
- struct extract_literal_bin_director
- {
- typedef binary_lit_director<
- boost::integer::native, sizeof(T)*CHAR_BIT
- > type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of a binary tag
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag>
- struct extract_binary_director;
-
- // native endian binaries
- template <>
- struct extract_binary_director<tag::byte>
- {
- typedef any_binary_director<boost::integer::native, 8> type;
- };
-
- template <>
- struct extract_binary_director<tag::word>
- {
- typedef any_binary_director<boost::integer::native, 16> type;
- };
-
- template <>
- struct extract_binary_director<tag::dword>
- {
- typedef any_binary_director<boost::integer::native, 32> type;
- };
-
- // big endian binaries
- template <>
- struct extract_binary_director<tag::big_word>
- {
- typedef any_binary_director<boost::integer::big, 16> type;
- };
-
- template <>
- struct extract_binary_director<tag::big_dword>
- {
- typedef any_binary_director<boost::integer::big, 32> type;
- };
-
- // little endian binaries
- template <>
- struct extract_binary_director<tag::little_word>
- {
- typedef any_binary_director<boost::integer::little, 16> type;
- };
-
- template <>
- struct extract_binary_director<tag::little_dword>
- {
- typedef any_binary_director<boost::integer::little, 32> type;
- };
-
-#ifdef BOOST_HAS_LONG_LONG
- template <>
- struct extract_binary_director<tag::qword>
- {
- typedef any_binary_director<boost::integer::native, 64> type;
- };
-
- template <>
- struct extract_binary_director<tag::big_qword>
- {
- typedef any_binary_director<boost::integer::big, 64> type;
- };
-
- template <>
- struct extract_binary_director<tag::little_qword>
- {
- typedef any_binary_director<boost::integer::little, 64> type;
- };
-#endif
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of a binary literal tag
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag, typename T>
- struct extract_binary_lit_director;
-
- // native endian binaries
- template <typename T>
- struct extract_binary_lit_director<tag::byte, T>
- {
- typedef binary_lit_director<boost::integer::native, 8> type;
- };
-
- template <typename T>
- struct extract_binary_lit_director<tag::word, T>
- {
- typedef binary_lit_director<boost::integer::native, 16> type;
- };
-
- template <typename T>
- struct extract_binary_lit_director<tag::dword, T>
- {
- typedef binary_lit_director<boost::integer::native, 32> type;
- };
-
- // big endian binaries
- template <typename T>
- struct extract_binary_lit_director<tag::big_word, T>
- {
- typedef binary_lit_director<boost::integer::big, 16> type;
- };
-
- template <typename T>
- struct extract_binary_lit_director<tag::big_dword, T>
- {
- typedef binary_lit_director<boost::integer::big, 32> type;
- };
-
- // little endian binaries
- template <typename T>
- struct extract_binary_lit_director<tag::little_word, T>
- {
- typedef binary_lit_director<boost::integer::little, 16> type;
- };
-
- template <typename T>
- struct extract_binary_lit_director<tag::little_dword, T>
- {
- typedef binary_lit_director<boost::integer::little, 32> type;
- };
-
-#ifdef BOOST_HAS_LONG_LONG
- template <typename T>
- struct extract_binary_lit_director<tag::qword, T>
- {
- typedef binary_lit_director<boost::integer::native, 64> type;
- };
-
- template <typename T>
- struct extract_binary_lit_director<tag::big_qword, T>
- {
- typedef binary_lit_director<boost::integer::big, 64> type;
- };
-
- template <typename T>
- struct extract_binary_lit_director<tag::little_qword, T>
- {
- typedef binary_lit_director<boost::integer::little, 64> type;
- };
-#endif
-
- ///////////////////////////////////////////////////////////////////////////
- // binary meta-grammar
- ///////////////////////////////////////////////////////////////////////////
- // literals: 10, 10L, 10LL
- struct int_binary_meta_grammar
- : meta_grammar::compose_empty<
- proto::if_<
- is_int_lit_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_literal_bin_director<mpl::_> >
- >
- {
- };
-
- struct binary_meta_grammar
- : proto::or_<
- meta_grammar::compose_empty<
- proto::if_<
- is_binary_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_binary_director<mpl::_> >
- >,
- meta_grammar::compose_function1_eval<
- proto::function<
- proto::if_<
- is_binary_tag<proto::_child, karma::domain>()
- >,
- int_binary_meta_grammar
- >,
- karma::domain,
- mpl::identity<extract_binary_lit_director<mpl::_, mpl::_> >
- >,
- meta_grammar::function1_rule<
- karma::domain, tag::pad, binary_padding_director
- >
- >
- {
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hooks into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<
- Expr,
- typename enable_if<
- proto::matches<Expr, binary_meta_grammar>
- >::type
- >
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<
- Expr,
- typename enable_if<
- proto::matches<Expr, binary_meta_grammar>
- >::type
- >
- : mpl::identity<binary_meta_grammar>
- {
- };
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/binary/padding.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/binary/padding.hpp (original)
+++ branches/release/boost/spirit/home/karma/binary/padding.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2008 Hartmut Kaiser
+// Copyright (c) 2001-2009 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)
@@ -6,51 +6,105 @@
 #if !defined(BOOST_SPIRIT_KARMA_PADDING_MAY_06_2008_0436PM)
 #define BOOST_SPIRIT_KARMA_PADDING_MAY_06_2008_0436PM
 
-#include <boost/lexical_cast.hpp>
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/info.hpp>
 
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/karma/detail/generate_to.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/fusion/include/at.hpp>
-#include <boost/spirit/home/karma/detail/generate_to.hpp>
+#include <boost/fusion/include/vector.hpp>
 
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+
+ // enables pad(...)
+ template <typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::pad, fusion::vector1<A0> > >
+ : mpl::true_ {};
+
+ // enables lazy pad(...)
+ template <>
+ struct use_lazy_terminal<karma::domain, tag::pad, 1>
+ : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
- struct binary_padding_director
+ using boost::spirit::pad;
+ using boost::spirit::pad_type;
+
+ struct binary_padding_generator
+ : primitive_generator<binary_padding_generator>
     {
- template <typename Component, typename Context, typename Unused>
+ typedef mpl::int_<generator_properties::tracking> properties;
+
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef unused_type type;
         };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const&)
+ binary_padding_generator(int numpadbytes)
+ : numpadbytes_(numpadbytes)
+ {}
+
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
         {
- std::size_t padbytes = fusion::at_c<0>(component.elements);
- std::size_t count = sink.get_out_count() % padbytes;
-
+ std::size_t count = sink.get_out_count() % numpadbytes_;
             if (count)
- count = padbytes - count;
-
+ count = numpadbytes_ - count;
+
             bool result = true;
             while (result && count-- != 0)
                 result = detail::generate_to(sink, 0);
 
- karma::delimit(sink, d); // always do post-delimiting
+ if (result)
+ result = karma::delimit_out(sink, d); // always do post-delimiting
             return result;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ static info what(Context const& ctx)
+ {
+ return info("pad");
+ }
+
+ int numpadbytes_;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::pad, fusion::vector1<A0> >
+ , Modifiers>
+ {
+ typedef binary_padding_generator result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return std::string("pad(") +
- boost::lexical_cast<std::string>(
- fusion::at_c<0>(component.elements)) +
- ")";
+ return result_type(fusion::at_c<0>(term.args));
         }
     };
 

Modified: branches/release/boost/spirit/home/karma/char.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/char.hpp (original)
+++ branches/release/boost/spirit/home/karma/char.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,12 +6,11 @@
 #if !defined(BOOST_SPIRIT_KARMA_CHAR_FEB_21_2007_0547PM)
 #define BOOST_SPIRIT_KARMA_CHAR_FEB_21_2007_0547PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/char/char.hpp>
-#include <boost/spirit/home/karma/char/space.hpp>
-#include <boost/spirit/home/karma/char/meta_grammar.hpp>
+#include <boost/spirit/home/karma/char/char_class.hpp>
 
 #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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,71 +6,134 @@
 #if !defined(BOOST_SPIRIT_KARMA_CHAR_FEB_21_2007_0543PM)
 #define BOOST_SPIRIT_KARMA_CHAR_FEB_21_2007_0543PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/char_class.hpp>
+#include <boost/spirit/home/support/detail/get_encoding.hpp>
+#include <boost/spirit/home/support/char_set/basic_chset.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/char/char_generator.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/karma/detail/get_casetag.hpp>
 #include <boost/spirit/home/karma/detail/generate_to.hpp>
-#include <boost/spirit/home/support/modifier.hpp>
-#include <boost/spirit/home/support/char_class.hpp>
-#include <boost/spirit/home/support/detail/to_narrow.hpp>
-#include <boost/spirit/home/support/iso8859_1.hpp>
-#include <boost/spirit/home/support/ascii.hpp>
 #include <boost/fusion/include/at.hpp>
-#include <boost/fusion/include/value_at.hpp>
 #include <boost/fusion/include/vector.hpp>
 #include <boost/fusion/include/cons.hpp>
-#include <boost/utility/enable_if.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/bool.hpp>
+#include <string>
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename CharEncoding>
+ struct use_terminal<karma::domain
+ , tag::char_code<tag::char_, CharEncoding> // enables char_
+ > : mpl::true_ {};
+
+ template <typename CharEncoding, typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<
+ tag::char_code<tag::char_, CharEncoding> // enables char_('x'), char_("x")
+ , fusion::vector1<A0>
+ >
+ > : mpl::true_ {};
+
+ template <typename CharEncoding, typename A0, typename A1>
+ struct use_terminal<karma::domain
+ , terminal_ex<
+ tag::char_code<tag::char_, CharEncoding> // enables char_('a','z')
+ , fusion::vector2<A0, A1>
+ >
+ > : mpl::true_ {};
+
+ template <typename CharEncoding> // enables *lazy* char_('x'), char_("x")
+ struct use_lazy_terminal<
+ karma::domain
+ , tag::char_code<tag::char_, CharEncoding>
+ , 1 // arity
+ > : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, char> // enables 'x'
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, char[2]> // enables "x"
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, wchar_t> // enables L'x'
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, wchar_t[2]> // enables L"x"
+ : mpl::true_ {};
+
+}}
 
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
+ using spirit::lit; // lit('x') is equivalent to 'x'
+
     ///////////////////////////////////////////////////////////////////////////
     //
     // any_char
- // generates a single character from the associated parameter
+ // generates a single character from the associated attribute
     //
- // Note: this generator has to have an associated parameter
+ // Note: this generator has to have an associated attribute
     //
     ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
+ template <typename CharEncoding, typename Tag>
     struct any_char
+ : char_generator<any_char<CharEncoding, Tag>, CharEncoding, Tag>
     {
- template <typename Component, typename Context, typename Unused>
+ typedef typename CharEncoding::char_type char_type;
+ typedef CharEncoding char_encoding;
+
+ template <typename Context, typename Unused>
         struct attribute
         {
- typedef Char type;
+ typedef char_type type;
         };
 
- // any_char has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const&, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
+ // any_char has an attached parameter
+ template <typename Attribute, typename CharParam, typename Context>
+ bool test(Attribute const& attr, CharParam& ch, Context&) const
         {
- detail::generate_to(sink, param);
- karma::delimit(sink, d); // always do post-delimiting
+ ch = attr;
             return true;
         }
 
- // this any_char has no parameter attached, it needs to have been
+ // any_char has no attribute attached, it needs to have been
         // initialized from a direct literal
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
- static bool
- generate(Component const&, OutputIterator&, Context&, Delimiter const&,
- unused_type)
+ template <typename CharParam, typename Context>
+ bool test(unused_type, CharParam&, Context&) const
         {
- BOOST_MPL_ASSERT_MSG(false, char__not_usable_without_attribute, ());
+ // It is not possible (doesn't make sense) to use char_ without
+ // providing any attribute, as the generator doesn't 'know' what
+ // character to output. The following assertion fires if this
+ // situation is detected in your code.
+ BOOST_SPIRIT_ASSERT_MSG(false, char_not_usable_without_attribute, ());
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
- return "any-char";
+ return info("any-char");
         }
     };
 
@@ -81,243 +144,332 @@
     // from
     //
     ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
+ template <typename CharEncoding, typename Tag, bool no_attribute>
     struct literal_char
+ : char_generator<literal_char<CharEncoding, Tag, no_attribute>
+ , CharEncoding, Tag>
     {
- template <typename Component, typename Context, typename Unused>
+ typedef typename CharEncoding::char_type char_type;
+ typedef CharEncoding char_encoding;
+
+ literal_char(char_type ch)
+ : ch (spirit::char_class::convert<char_encoding>::to(Tag(), ch))
+ {}
+
+ template <typename Context, typename Unused>
         struct attribute
- {
- typedef unused_type type;
- };
+ : mpl::if_c<no_attribute, unused_type, char_type>
+ {};
 
- // any_char has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
+ // A char_('x') which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
+ // any_char has an attached parameter
+ template <typename Attribute, typename CharParam, typename Context>
+ bool test(Attribute const& attr, CharParam& ch_, Context&) const
+ {
+ // fail if attribute isn't matched my immediate literal
+ ch_ = attr;
+ return attr == ch;
+ }
+
+ // A char_('x') without any associated attribute just emits its
+ // immediate literal
+ template <typename CharParam, typename Context>
+ bool test(unused_type, CharParam& ch_, Context&) const
         {
- detail::generate_to(sink, fusion::at_c<0>(component.elements));
- karma::delimit(sink, d); // always do post-delimiting
+ ch_ = ch;
             return true;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context const& ctx) const
         {
- return std::string("'")
- + spirit::detail::to_narrow_char(
- fusion::at_c<0>(component.elements))
- + '\'';
+ return info("literal-char", char_encoding::toucs4(ch));
         }
+
+ char_type ch;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- //
- // lazy_char
- // generates a single character given by a functor it was initialized
- // from
- //
- ///////////////////////////////////////////////////////////////////////////
- struct lazy_char
+ // char range generator
+ template <typename CharEncoding, typename Tag>
+ struct char_range
+ : char_generator<char_range<CharEncoding, Tag>, CharEncoding, Tag>
     {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef unused_type type;
- };
+ typedef typename CharEncoding::char_type char_type;
+ typedef CharEncoding char_encoding;
 
- // any_char has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& /*param*/)
- {
- detail::generate_to(sink,
- fusion::at_c<0>(component.elements)(unused, ctx));
- karma::delimit(sink, d); // always do post-delimiting
- return true;
+ char_range(char_type from, char_type to)
+ : from(spirit::char_class::convert<char_encoding>::to(Tag(), from))
+ , to(spirit::char_class::convert<char_encoding>::to(Tag(), to))
+ {}
+
+ // A char_('a', 'z') which has an associated attribute emits it only if
+ // it matches the character range, otherwise it fails.
+ template <typename Attribute, typename CharParam, typename Context>
+ bool test(Attribute const& attr, CharParam& ch, Context&) const
+ {
+ // fail if attribute doesn't belong to character range
+ ch = attr;
+ return (from <= char_type(attr)) && (char_type(attr) <= to);
+ }
+
+ // A char_('a', 'z') without any associated attribute fails compiling
+ template <typename CharParam, typename Context>
+ bool test(unused_type, CharParam&, Context&) const
+ {
+ BOOST_SPIRIT_ASSERT_MSG(false
+ , char_range_not_usable_without_attribute, ());
+ return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& /*context*/) const
         {
- return "char";
+ info result("char-range", char_encoding::toucs4(from));
+ boost::get<std::string&>(result.value) += '-';
+ boost::get<std::string&>(result.value) += to_utf8(char_encoding::toucs4(to));
+ return result;
         }
+
+ char_type from, to;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- //
- // lower and upper case variants of any_char with an associated parameter
- // note: this generator has to have a parameter associated
- //
- ///////////////////////////////////////////////////////////////////////////
- template <typename Char, typename Tag>
- struct case_any_char
+ // character set generator
+ template <typename CharEncoding, typename Tag>
+ struct char_set
+ : char_generator<char_set<CharEncoding, Tag>, CharEncoding, Tag>
     {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef Char type;
- };
-
- typedef typename Tag::char_set char_set;
- typedef typename Tag::char_class char_class_;
+ typedef typename CharEncoding::char_type char_type;
+ typedef CharEncoding char_encoding;
 
- // case_any_char has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
- {
- using spirit::char_class::convert;
- Char p = convert<char_set>::to(char_class_(), param);
- detail::generate_to(sink, p);
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
+ template <typename String>
+ char_set(String const& str)
+ {
+ typedef typename traits::char_type_of<String>::type in_type;
 
- // this case_any_char has no parameter attached, it needs to have been
- // initialized from a direct literal
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
- static bool
- generate(Component const&, OutputIterator&, Context&, Delimiter const&,
- unused_type)
+ BOOST_SPIRIT_ASSERT_MSG((
+ (sizeof(char_type) == sizeof(in_type))
+ ), cannot_convert_string, (String));
+
+ typedef spirit::char_class::convert<char_encoding> convert_type;
+
+ char_type const* definition =
+ (char_type const*)traits::get_c_string(str);
+ char_type ch = convert_type::to(Tag(), *definition++);
+ while (ch)
+ {
+ char_type next = convert_type::to(Tag(), *definition++);
+ if (next == '-')
+ {
+ next = convert_type::to(Tag(), *definition++);
+ if (next == 0)
+ {
+ chset.set(ch);
+ chset.set('-');
+ break;
+ }
+ chset.set(ch, next);
+ }
+ else
+ {
+ chset.set(ch);
+ }
+ ch = next;
+ }
+ }
+
+ // A char_("a-z") which has an associated attribute emits it only if
+ // it matches the character set, otherwise it fails.
+ template <typename Attribute, typename CharParam, typename Context>
+ bool test(Attribute const& attr, CharParam& ch, Context&) const
+ {
+ // fail if attribute doesn't belong to character set
+ ch = attr;
+ return chset.test(char_type(attr));
+ }
+
+ // A char_("a-z") without any associated attribute fails compiling
+ template <typename CharParam, typename Context>
+ bool test(unused_type, CharParam&, Context&) const
         {
- BOOST_MPL_ASSERT_MSG(false, char__not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false
+ , char_set_not_usable_without_attribute, ());
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& /*context*/) const
         {
- std::string result;
- result = std::string("any-") +
- spirit::char_class::what<char_set>::is(char_class_()) +
- "case-char";
- return result;
+ return info("char-set");
         }
- };
 
-}}} // namespace boost::spirit::karma
+ support::detail::basic_chset<char_type> chset;
+ };
 
-namespace boost { namespace spirit { namespace traits
-{
     ///////////////////////////////////////////////////////////////////////////
- // lower_case and upper_case any_char and literal_char generators
+ // Generator generators: make_xxx function (objects)
     ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename Char>
- struct make_modified_component<
- Domain, karma::literal_char<Char>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
+ namespace detail
     {
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- char_type;
- typedef fusion::vector<char_type> vector_type;
-
- typedef component<
- karma::domain, karma::literal_char<Char>, vector_type>
- type;
-
- static type
- call(Elements const& elements)
- {
- typedef typename Modifier::char_set char_set;
-
- char_type ch = fusion::at_c<0>(elements);
- vector_type v(char_set::tolower(ch));
- return type(v);
+ template <typename Modifiers, typename Encoding>
+ struct basic_literal
+ {
+ 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 literal_char<
+ typename spirit::detail::get_encoding<
+ Modifiers, Encoding, lower || upper>::type
+ , typename get_casetag<Modifiers, lower || upper>::type
+ , true>
+ result_type;
+
+ template <typename Char>
+ result_type operator()(Char ch, unused_type) const
+ {
+ return result_type(ch);
+ }
+
+ template <typename Char>
+ result_type operator()(Char const* str, unused_type) const
+ {
+ return result_type(str[0]);
+ }
+ };
+ }
+
+ // literals: 'x', "x"
+ template <typename Modifiers>
+ struct make_primitive<char, Modifiers>
+ : detail::basic_literal<Modifiers, char_encoding::standard> {};
+
+ template <typename Modifiers>
+ struct make_primitive<char const(&)[2], Modifiers>
+ : detail::basic_literal<Modifiers, char_encoding::standard> {};
+
+ // literals: L'x', L"x"
+ template <typename Modifiers>
+ struct make_primitive<wchar_t, Modifiers>
+ : detail::basic_literal<Modifiers, char_encoding::standard_wide> {};
+
+ template <typename Modifiers>
+ struct make_primitive<wchar_t const(&)[2], Modifiers>
+ : detail::basic_literal<Modifiers, char_encoding::standard_wide> {};
+
+ // char_
+ template <typename CharEncoding, typename Modifiers>
+ struct make_primitive<tag::char_code<tag::char_, CharEncoding>, Modifiers>
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code<tag::lower, CharEncoding> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code<tag::upper, CharEncoding> >::value;
+
+ typedef any_char<
+ typename spirit::detail::get_encoding<
+ Modifiers, CharEncoding, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ > result_type;
+
+ result_type operator()(unused_type, unused_type) const
+ {
+ return result_type();
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename Char>
- struct make_modified_component<
- Domain, karma::literal_char<Char>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
+ // char_(...)
+ template <typename CharEncoding, typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::char_, CharEncoding>
+ , fusion::vector1<A0>
+ >
+ , Modifiers>
     {
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- char_type;
- typedef fusion::vector<char_type> vector_type;
-
- typedef
- component<karma::domain, karma::literal_char<Char>, vector_type>
- type;
-
- static type
- call(Elements const& elements)
- {
- typedef typename Modifier::char_set char_set;
-
- char_type ch = fusion::at_c<0>(elements);
- vector_type v(char_set::toupper(ch));
- return type(v);
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code<tag::lower, CharEncoding> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code<tag::upper, CharEncoding> >::value;
+
+ typedef typename spirit::detail::get_encoding<
+ Modifiers, CharEncoding, lower || upper>::type encoding;
+ typedef typename detail::get_casetag<
+ Modifiers, lower || upper>::type tag;
+
+ typedef typename mpl::if_<
+ traits::is_string<A0>
+ , char_set<encoding, tag>
+ , literal_char<encoding, tag, false>
+ >::type result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
         }
     };
 
- ///////////////////////////////////////////////////////////////////////////
- // lower_case and upper case_any_char conversions
- ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename Char>
- struct make_modified_component<
- Domain, karma::any_char<Char>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
+ // char_("x")
+ template <typename CharEncoding, typename Modifiers, typename Char>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::char_, CharEncoding>
+ , fusion::vector1<Char(&)[2]> // For single char strings
+ >
+ , Modifiers>
     {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::lower char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef component<
- karma::domain, karma::case_any_char<Char, key_tag>, fusion::nil>
- type;
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code<tag::lower, CharEncoding> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code<tag::upper, CharEncoding> >::value;
+
+ typedef literal_char<
+ typename spirit::detail::get_encoding<
+ Modifiers, CharEncoding, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , false
+ > result_type;
 
- static type
- call(Elements const&)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return type(fusion::nil());
+ return result_type(fusion::at_c<0>(term.args)[0]);
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename Char>
- struct make_modified_component<
- Domain, karma::any_char<Char>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
+ // char_('a', 'z')
+ template <typename CharEncoding, typename Modifiers, typename A0, typename A1>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::char_, CharEncoding>
+ , fusion::vector2<A0, A1>
+ >
+ , Modifiers>
     {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::upper char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef component<
- karma::domain, karma::case_any_char<Char, key_tag>, fusion::nil>
- type;
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code<tag::lower, CharEncoding> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code<tag::upper, CharEncoding> >::value;
+
+ typedef char_range<
+ typename spirit::detail::get_encoding<
+ Modifiers, CharEncoding, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ > result_type;
 
- static type
- call(Elements const&)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return type(fusion::nil());
+ return result_type(fusion::at_c<0>(term.args)
+ , fusion::at_c<1>(term.args));
         }
     };
 
-}}} // namespace boost::spirit::traits
+}}} // namespace boost::spirit::karma
 
-#endif // !defined(BOOST_SPIRIT_KARMA_CHAR_FEB_21_2007_0543PM)
+#endif

Deleted: branches/release/boost/spirit/home/karma/char/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/char/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,230 +0,0 @@
-// Copyright (c) 2001-2007 Joel de Guzman
-// Copyright (c) 2001-2009 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_KARMA_META_GRAMMAR_FEB_21_2007_0742AM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_FEB_21_2007_0742AM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/placeholders.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/spirit/home/support/char_class.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/bool.hpp>
-
-namespace boost { namespace spirit
-{
- ///////////////////////////////////////////////////////////////////////////
- // test if a tag is a character literal type
- ///////////////////////////////////////////////////////////////////////////
- template <typename CharSet>
- struct is_char_tag<
- spirit::char_class::key<CharSet, char_class::tag::space>,
- karma::domain
- >
- : mpl::true_
- {};
-}}
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forward declarations
- ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
- struct any_char;
-
- template <typename Char>
- struct literal_char;
-
- struct lazy_char;
-
- template <typename Tag, typename Char>
- struct any_space_char;
-
- template <typename Tag, typename Char>
- struct literal_space_char;
-
- struct char_meta_grammar;
-
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of a character literal type
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag, typename T>
- struct extract_literal_char_director;
-
- template <typename T>
- struct extract_literal_char_director<tag::char_, T>
- {
- typedef literal_char<T> type;
- };
-
- template <typename T>
- struct extract_literal_char_director<tag::wchar, T>
- {
- typedef literal_char<wchar_t> type;
- };
-
- template <typename T>
- struct extract_literal_char_director<tag::lit, T>
- {
- typedef literal_char<T> type;
- };
-
- template <typename T>
- struct extract_literal_char_director<tag::wlit, T>
- {
- typedef literal_char<wchar_t> type;
- };
-
- template <typename CharSet, typename T>
- struct extract_literal_char_director<
- spirit::char_class::key<CharSet, char_class::tag::space>, T
- >
- {
- typedef
- spirit::char_class::key<CharSet, char_class::tag::space>
- key_type;
- typedef literal_space_char<key_type, T> type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of a plain character type
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag>
- struct extract_any_char_director;
-
- template <>
- struct extract_any_char_director<tag::char_>
- {
- typedef any_char<char> type;
- };
-
- template <>
- struct extract_any_char_director<tag::wchar>
- {
- typedef any_char<wchar_t> type;
- };
-
- template <typename CharSet>
- struct extract_any_char_director<
- spirit::char_class::key<CharSet, char_class::tag::space>
- >
- {
- typedef typename CharSet::char_type char_type;
- typedef
- spirit::char_class::key<CharSet, char_class::tag::space>
- key_type;
- typedef any_space_char<key_type, char_type> type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // char generator meta-grammars
- ///////////////////////////////////////////////////////////////////////////
-
- // literals: 'x', L'x'
- struct char_literal_meta_grammar
- : proto::or_<
- meta_grammar::terminal_rule<
- karma::domain, char, literal_char<char>
- >,
- meta_grammar::terminal_rule<
- karma::domain, wchar_t, literal_char<wchar_t>
- >
- >
- {
- };
-
- // literals: 'x', L'x'
- struct basic_char_literal_meta_grammar
- : proto::or_<
- proto::terminal<char>,
- proto::terminal<wchar_t>
- >
- {
- };
-
- // char_, wchar, space
- // char_('x'), char_(L'x'), wchar('x'), wchar(L'x'), space(' ')
- struct char_meta_grammar1
- : proto::or_<
- // char_, wchar, space
- meta_grammar::compose_empty<
- proto::if_<
- is_char_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_any_char_director<mpl::_> >
- >,
- // char_('x'), wchar(L'x'), space(' ')
- meta_grammar::compose_function1_eval<
- proto::function<
- proto::if_<
- is_char_tag<proto::_child, karma::domain>()
- >,
- basic_char_literal_meta_grammar
- >,
- karma::domain,
- mpl::identity<extract_literal_char_director<mpl::_, mpl::_> >
- >,
- // lit('x'), wlit('x')
- meta_grammar::compose_function1_eval<
- proto::function<
- proto::if_<
- is_lit_tag<proto::_child, karma::domain>()
- >,
- basic_char_literal_meta_grammar
- >,
- karma::domain,
- mpl::identity<extract_literal_char_director<mpl::_, mpl::_> >
- >,
- // char_(val('y'))
- meta_grammar::function1_rule<
- karma::domain, tag::char_, lazy_char
- >
- >
- {
- };
-
- // main char_meta_grammar
- struct char_meta_grammar
- : proto::or_<
- char_literal_meta_grammar,
- char_meta_grammar1
- >
- {
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hook into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<Expr,
- typename enable_if<proto::matches<Expr, char_meta_grammar> >::type>
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<Expr,
- typename enable_if<proto::matches<Expr, char_meta_grammar> >::type>
- : mpl::identity<char_meta_grammar>
- {
- };
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/karma/char/space.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/char/space.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,116 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_SPACE_MAR_06_2007_0934PM)
-#define BOOST_SPIRIT_KARMA_SPACE_MAR_06_2007_0934PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
-#include <boost/spirit/home/karma/detail/generate_to.hpp>
-#include <boost/spirit/home/support/char_class.hpp>
-#include <boost/spirit/home/support/detail/to_narrow.hpp>
-#include <boost/spirit/home/support/iso8859_1.hpp>
-#include <boost/spirit/home/support/ascii.hpp>
-#include <boost/spirit/home/support/standard.hpp>
-#include <boost/spirit/home/support/standard_wide.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- //
- // space
- // generates a single character from the associated parameter
- //
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag, typename Char>
- struct any_space_char
- {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef Char type;
- };
-
- typedef typename Tag::char_set char_set;
- typedef typename Tag::char_class char_class_;
-
- // space has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& ch)
- {
- using spirit::char_class::classify;
- BOOST_ASSERT(classify<char_set>::is(char_class_(), ch));
- detail::generate_to(sink, ch);
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
-
- // this space has no parameter attached, just generate a single ' '
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
- static bool
- generate(Component const&, OutputIterator& sink, Context&,
- Delimiter const& d, unused_type)
- {
- detail::generate_to(sink, ' '); // generate a single space
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- return "any-space";
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // space(...)
- // generates a single space character given by a literal it was
- // initialized from
- //
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag, typename Char>
- struct literal_space_char
- {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef unused_type type;
- };
-
- // any_char has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
- {
- detail::generate_to(sink, fusion::at_c<0>(component.elements));
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- return std::string("space('")
- + spirit::detail::to_narrow_char(
- fusion::at_c<0>(component.elements))
- + "')";
- }
- };
-
-}}} // namespace boost::spirit::karma
-
-#endif // !defined(BOOST_SPIRIT_KARMA_CHAR_FEB_21_2007_0543PM)

Deleted: branches/release/boost/spirit/home/karma/delimit.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/delimit.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,35 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_DELIMIT_FEB_20_2007_1208PM)
-#define BOOST_SPIRIT_KARMA_DELIMIT_FEB_20_2007_1208PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/unused.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // Do delimiting. This is equivalent to p << d. The function is a
- // no-op if spirit::unused is passed as the delimiter-generator.
- ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Delimiter>
- inline void delimit(OutputIterator& sink, Delimiter const& d)
- {
- Delimiter::director::generate(d, sink, unused, unused, unused);
- }
-
- template <typename OutputIterator>
- inline void delimit(OutputIterator&, unused_type)
- {
- }
-
-}}}
-
-#endif
-

Modified: branches/release/boost/spirit/home/karma/detail/generate_to.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/generate_to.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/generate_to.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -3,56 +3,65 @@
 // 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_KARMA_DETAIL_EXTRACT_FROM_FEB_20_2007_0417PM)
-#define BOOST_SPIRIT_KARMA_DETAIL_EXTRACT_FROM_FEB_20_2007_0417PM
+#if !defined(BOOST_SPIRIT_KARMA_DETAIL_GENERATE_TO_FEB_20_2007_0417PM)
+#define BOOST_SPIRIT_KARMA_DETAIL_GENERATE_TO_FEB_20_2007_0417PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/support/char_class.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
 
 namespace boost { namespace spirit { namespace karma { namespace detail
 {
     ///////////////////////////////////////////////////////////////////////////
     // These utility functions insert the given parameter into the supplied
     // output iterator.
- // If the parameter is spirit's unused_type, this is a no_op.
+ // If the attribute is spirit's unused_type, this is a no_op.
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Parameter, typename Tag>
+ template <
+ typename OutputIterator, typename Attribute, typename CharEncoding
+ , typename Tag>
     inline bool
- generate_to(OutputIterator& sink, Parameter const& p, Tag)
+ generate_to(OutputIterator& sink, Attribute const& p, CharEncoding, Tag)
     {
- typedef typename Tag::char_set char_set;
- typedef typename Tag::char_class char_class;
-
- *sink = spirit::char_class::convert<char_set>::to(char_class(), p);
+ *sink = spirit::char_class::convert<CharEncoding>::to(Tag(), p);
         ++sink;
- return true;
+ return detail::sink_is_good(sink);
     }
 
- template <typename OutputIterator, typename Parameter>
+ template <typename OutputIterator, typename Attribute>
     inline bool
- generate_to(OutputIterator& sink, Parameter const& p, unused_type = unused)
+ generate_to(OutputIterator& sink, Attribute const& p, unused_type, unused_type)
     {
         *sink = p;
         ++sink;
- return true;
+ return detail::sink_is_good(sink);
     }
 
- template <typename OutputIterator, typename Tag>
- inline bool generate_to(OutputIterator& sink, unused_type, Tag)
+ template <typename OutputIterator, typename CharEncoding, typename Tag>
+ inline bool generate_to(OutputIterator&, unused_type, CharEncoding, Tag)
     {
         return true;
     }
-
+
+ template <typename OutputIterator, typename Attribute>
+ inline bool
+ generate_to(OutputIterator& sink, Attribute const& p)
+ {
+ *sink = p;
+ ++sink;
+ return detail::sink_is_good(sink);
+ }
+
     template <typename OutputIterator>
- inline bool generate_to(OutputIterator& sink, unused_type)
+ inline bool generate_to(OutputIterator&, unused_type)
     {
         return true;
     }
-
+
 }}}} // namespace boost::spirit::karma::detail
 
 #endif // KARMA_CORE_DETAIL_INSERT_TO_HPP

Deleted: branches/release/boost/spirit/home/karma/detail/ostream_iterator.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/ostream_iterator.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,57 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_OSTREAM_ITERATOR_MAY_26_2007_1016PM)
-#define BOOST_SPIRIT_KARMA_OSTREAM_ITERATOR_MAY_26_2007_1016PM
-
-#include <iterator>
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace karma { namespace detail
-{
- ///////////////////////////////////////////////////////////////////////////
- // We need our own implementation of an ostream_iterator just to be able
- // to access the wrapped ostream, which is necessary for the
- // stream_director, where we must generate the output using the original
- // ostream to retain possibly registered facets.
- ///////////////////////////////////////////////////////////////////////////
- template <
- typename T, typename Elem = char,
- typename Traits = std::char_traits<Elem>
- >
- class ostream_iterator
- : public std::iterator<std::output_iterator_tag, void, void, void, void>
- {
- public:
- typedef Elem char_type;
- typedef Traits traits_type;
- typedef std::basic_ostream<Elem, Traits> ostream_type;
- typedef ostream_iterator<T, Elem, Traits> self_type;
-
- ostream_iterator(ostream_type& os_, Elem const* delim_ = 0)
- : os(&os_), delim(delim_) {}
-
- self_type& operator= (T const& val)
- {
- *os << val;
- if (0 != delim)
- *os << delim;
- return *this;
- }
-
- self_type& operator*() { return *this; }
- self_type& operator++() { return *this; }
- self_type operator++(int) { return *this; }
-
- ostream_type& get_ostream() { return *os; }
-
- protected:
- ostream_type *os;
- Elem const* delim;
- };
-
-}}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/detail/output_iterator.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/output_iterator.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/output_iterator.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,16 +6,21 @@
 #if !defined(BOOST_SPIRIT_KARMA_OUTPUT_ITERATOR_MAY_26_2007_0506PM)
 #define BOOST_SPIRIT_KARMA_OUTPUT_ITERATOR_MAY_26_2007_0506PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <iterator>
 #include <vector>
 #include <algorithm>
 
+#include <boost/config.hpp>
 #include <boost/noncopyable.hpp>
-#include <boost/spirit/home/karma/detail/ostream_iterator.hpp>
+#include <boost/mpl/if.hpp>
+
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/stream/ostream_iterator.hpp>
+#include <boost/spirit/home/support/unused.hpp>
 
 namespace boost { namespace spirit { namespace karma { namespace detail
 {
@@ -25,9 +30,9 @@
     class position_sink
     {
     public:
- position_sink() : count(0), line(1), column(0) {}
- void tidy() { count = 0; line = 1; column = 0; }
-
+ position_sink() : count(0), line(1), column(1) {}
+ void tidy() { count = 0; line = 1; column = 1; }
+
         template <typename T>
         void output(T const& value)
         {
@@ -51,22 +56,114 @@
     };
 
     ///////////////////////////////////////////////////////////////////////////
- // This class is used to count the umber of characters streamed into the
+ struct position_policy
+ {
+ position_policy() {}
+ position_policy(position_policy const& rhs)
+ : track_position_data(rhs.track_position_data) {}
+
+ template <typename T>
+ void output(T const& value)
+ {
+ // track position in the output
+ track_position_data.output(value);
+ }
+
+ // return the current count in the output
+ std::size_t get_out_count() const
+ {
+ return track_position_data.get_count();
+ }
+
+ private:
+ position_sink track_position_data; // for position tracking
+ };
+
+ struct no_position_policy
+ {
+ no_position_policy() {}
+ no_position_policy(no_position_policy const& rhs) {}
+
+ template <typename T>
+ void output(T const& value) {}
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // This class is used to count the number of characters streamed into the
     // output.
     ///////////////////////////////////////////////////////////////////////////
- class counting_sink
+ template <typename OutputIterator>
+ class counting_sink : boost::noncopyable
     {
     public:
- counting_sink() : count(0) {}
-
- void init(std::size_t count_) { count = count_; }
- void tidy() { count = 0; }
-
- void output() { ++count; }
+ counting_sink(OutputIterator& sink_, std::size_t count_ = 0
+ , bool enabled = true)
+ : count(count_), initial_count(count), prev_count(0), sink(sink_)
+ {
+ prev_count = sink.chain_counting(enabled ? this : NULL);
+ }
+ ~counting_sink()
+ {
+ if (prev_count) // propagate count
+ prev_count->update_count(count-initial_count);
+ sink.chain_counting(prev_count);
+ }
+
+ void output()
+ {
+ ++count;
+ }
         std::size_t get_count() const { return count; }
 
+ // propagate count from embedded counters
+ void update_count(std::size_t c)
+ {
+ count += c;
+ }
+
     private:
         std::size_t count;
+ std::size_t initial_count;
+ counting_sink* prev_count; // previous counter in chain
+ OutputIterator& sink;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename OutputIterator>
+ struct counting_policy
+ {
+ public:
+ counting_policy() : count(NULL) {}
+ counting_policy(counting_policy const& rhs) : count(rhs.count) {}
+
+ // functions related to counting
+ counting_sink<OutputIterator>* chain_counting(
+ counting_sink<OutputIterator>* count_data)
+ {
+ counting_sink<OutputIterator>* prev_count = count;
+ count = count_data;
+ return prev_count;
+ }
+
+ template <typename T>
+ void output(T const&)
+ {
+ // count characters, if appropriate
+ if (NULL != count)
+ count->output();
+ }
+
+ private:
+ counting_sink<OutputIterator>* count; // for counting
+ };
+
+ struct no_counting_policy
+ {
+ no_counting_policy() {}
+ no_counting_policy(no_counting_policy const& rhs) {}
+
+ template <typename T>
+ void output(T const& value) {}
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -82,10 +179,10 @@
     {
         virtual ~abstract_container() {}
         virtual void output(void const *item) = 0;
- virtual void copy(OutputIterator& sink) = 0;
- virtual std::size_t buffer_size() = 0;
+ virtual bool copy(OutputIterator& sink, std::size_t maxwidth) const = 0;
+ virtual std::size_t buffer_size() const = 0;
     };
-
+
     template <typename OutputIterator, typename T>
     class concrete_container : public abstract_container<OutputIterator>
     {
@@ -96,40 +193,69 @@
         }
         ~concrete_container() {}
 
+ private:
         void output(void const *item)
         {
             buffer.push_back(*static_cast<T const*>(item));
         }
- void copy(OutputIterator& sink)
+ bool copy(OutputIterator& sink, std::size_t maxwidth) const
         {
- std::copy(buffer.begin(), buffer.end(), sink);
+#if defined(BOOST_MSVC)
+#pragma warning(push)
+#pragma warning(disable: 4267)
+#endif
+ typename std::basic_string<T>::const_iterator end =
+ buffer.begin() + (std::min)(buffer.size(), maxwidth);
+
+#if defined(BOOST_MSVC)
+#pragma warning(pop)
+#endif
+
+ std::copy(buffer.begin(), end, sink);
+ return true;
         }
- std::size_t buffer_size()
+// template <typename RestIterator>
+// bool copy_rest(RestIterator& restsink, std::size_t start_at) const
+// {
+// typename std::basic_string<T>::const_iterator begin =
+// buffer.begin() + (std::min)(buffer.size(), start_at);
+//
+// std::copy(begin, buffer.end(), restsink);
+// return true;
+// }
+ std::size_t buffer_size() const
         {
             return buffer.size();
         }
-
+
     private:
- std::vector<T> buffer;
+ std::basic_string<T> buffer;
     };
-
+
     ///////////////////////////////////////////////////////////////////////////
     template <typename OutputIterator>
     class buffer_sink : boost::noncopyable
     {
     public:
         buffer_sink()
- : width(0), buffer(0)
- {}
-
+ : width(0), buffer(0) {}
+
         ~buffer_sink()
         {
- delete buffer;
+ tidy();
         }
-
- void init(std::size_t width_) { width = width_; }
- void tidy() { delete buffer; buffer = 0; width = 0; }
-
+
+ void enable(std::size_t width_)
+ {
+ tidy(); // release existing buffer
+ width = (width_ == std::size_t(-1)) ? 0 : width_;
+ }
+
+ void tidy()
+ {
+ delete buffer; buffer = 0; width = 0;
+ }
+
         template <typename T>
         void output(T const& value)
         {
@@ -140,13 +266,17 @@
             }
             buffer->output(&value);
         }
-
- void copy(OutputIterator& sink) const
+
+ bool copy(OutputIterator& sink, std::size_t maxwidth) const
         {
- if (buffer)
- buffer->copy(sink);
+ return buffer ? buffer->copy(sink, maxwidth) : false;
         }
-
+// template <typename RestIterator>
+// bool copy_rest(RestIterator& sink, std::size_t start_at) const
+// {
+// return buffer ? buffer->copy_rest(sink, start_at) : false;
+// }
+
         std::size_t buffer_size() const
         {
             return buffer ? buffer->buffer_size() : 0;
@@ -158,13 +288,116 @@
     };
 
     ///////////////////////////////////////////////////////////////////////////
+ template <typename OutputIterator>
+ struct buffering_policy
+ {
+ public:
+ buffering_policy() : buffer(NULL) {}
+ buffering_policy(buffering_policy const& rhs) : buffer(rhs.buffer) {}
+
+ // functions related to buffering
+ buffer_sink<OutputIterator>* chain_buffering(
+ buffer_sink<OutputIterator>* buffer_data)
+ {
+ buffer_sink<OutputIterator>* prev_buffer = buffer;
+ buffer = buffer_data;
+ return prev_buffer;
+ }
+
+ template <typename T>
+ bool output(T const& value)
+ {
+ // buffer characters, if appropriate
+ if (NULL != buffer) {
+ buffer->output(value);
+ return false;
+ }
+ return true;
+ }
+
+ bool has_buffer() const { return NULL != buffer; }
+
+ private:
+ buffer_sink<OutputIterator>* buffer;
+ };
+
+ struct no_buffering_policy
+ {
+ no_buffering_policy() {}
+ no_buffering_policy(no_counting_policy const& rhs) {}
+
+ template <typename T>
+ bool output(T const& value)
+ {
+ return true;
+ }
+
+ bool has_buffer() const { return false; }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
     // forward declaration only
+ template <typename OutputIterator>
+ struct enable_buffering;
+
+ template <typename OutputIterator, typename Properties
+ , typename Derived = unused_type>
+ class output_iterator;
+
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator> struct enable_counting;
- template <typename OutputIterator> struct enable_buffering;
+ template <typename Buffering, typename Counting, typename Tracking>
+ struct output_iterator_base : Buffering, Counting, Tracking
+ {
+ typedef Buffering buffering_policy;
+ typedef Counting counting_policy;
+ typedef Tracking tracking_policy;
+
+ output_iterator_base() {}
+ output_iterator_base(output_iterator_base const& rhs)
+ : buffering_policy(rhs), counting_policy(rhs), tracking_policy(rhs)
+ {}
+
+ template <typename T>
+ bool output(T const& value)
+ {
+ this->counting_policy::output(value);
+ this->tracking_policy::output(value);
+ return this->buffering_policy::output(value);
+ }
+ };
+
+ template <typename OutputIterator, typename Properties, typename Derived>
+ struct make_output_iterator
+ {
+ // get the most derived type of this class
+ typedef typename mpl::if_<
+ traits::is_not_unused<Derived>, Derived
+ , output_iterator<OutputIterator, Properties, Derived>
+ >::type most_derived_type;
+
+ enum { properties = Properties::value };
+
+ typedef typename mpl::if_c<
+ properties & generator_properties::tracking ? true : false
+ , position_policy, no_position_policy
+ >::type tracking_type;
+
+ typedef typename mpl::if_c<
+ properties & generator_properties::buffering ? true : false
+ , buffering_policy<most_derived_type>, no_buffering_policy
+ >::type buffering_type;
+
+ typedef typename mpl::if_c<
+ properties & generator_properties::counting ? true : false
+ , counting_policy<most_derived_type>, no_counting_policy
+ >::type counting_type;
+
+ typedef output_iterator_base<
+ buffering_type, counting_type, tracking_type> type;
+ };
 
     ///////////////////////////////////////////////////////////////////////////
- // Karma uses a output iterator wrapper for all output operations. This
+ // Karma uses an output iterator wrapper for all output operations. This
     // is necessary to avoid the dreaded 'scanner business' problem, i.e. the
     // dependency of rules and grammars on the used output iterator.
     //
@@ -175,76 +408,16 @@
     // supplied iterator. But it is possible to enable additional functionality
     // on demand, such as counting, buffering, and position tracking.
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Enable = void>
- class output_iterator : boost::noncopyable
+ template <typename OutputIterator, typename Properties, typename Derived>
+ class output_iterator
+ : public make_output_iterator<OutputIterator, Properties, Derived>::type
+ , boost::noncopyable
     {
     private:
- enum output_mode
- {
- output_characters = 0, // just hand through character
- count_characters = 1, // additionally count characters
- buffer_characters = 2 // buffer all characters, no output
- };
-
- struct output_proxy
- {
- output_proxy(output_iterator& parent)
- : parent(parent)
- {}
-
- template <typename T>
- output_proxy& operator=(T const& value)
- {
- parent.output(value);
- return *this;
- }
+ // base iterator type
+ typedef typename make_output_iterator<
+ OutputIterator, Properties, Derived>::type base_iterator;
 
- private:
- output_iterator& parent;
-
- // suppress warning about assignment operator not being generated
- output_proxy& operator=(output_proxy const&);
- };
-
-#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
-private:
- friend struct enable_counting<output_iterator<OutputIterator> >;
- friend struct enable_buffering<output_iterator<OutputIterator> >;
- friend struct enable_counting<output_iterator<OutputIterator, int> >;
- friend struct enable_buffering<output_iterator<OutputIterator, int> >;
-#else
-public:
-#endif
- // functions related to counting
- void enable_counting(std::size_t count = 0)
- {
- count_data.init(count);
- mode = output_mode(mode | count_characters);
- }
- void disable_counting()
- {
- mode = output_mode(mode & ~count_characters);
- }
- void reset_counting()
- {
- count_data.tidy();
- }
-
- // functions related to buffering
- void enable_buffering(std::size_t width = 0)
- {
- buffer_data.init(width);
- mode = output_mode(mode | buffer_characters);
- }
- void disable_buffering()
- {
- mode = output_mode(mode & ~buffer_characters);
- }
- void reset_buffering()
- {
- buffer_data.tidy();
- }
-
     public:
         typedef std::output_iterator_tag iterator_category;
         typedef void value_type;
@@ -252,85 +425,71 @@
         typedef void pointer;
         typedef void reference;
 
- output_iterator(OutputIterator& sink_)
- : sink(sink_), mode(output_characters)
+ explicit output_iterator(OutputIterator& sink_)
+ : sink(sink_)
+ {}
+ output_iterator(output_iterator const& rhs)
+ : base_iterator(rhs), sink(rhs.sink)
         {}
 
- output_proxy operator*() { return output_proxy(*this); }
- output_iterator& operator++() { ++sink; return *this; }
- output_iterator& operator++(int) { sink++; return *this; }
-
- template <typename T>
- void output(T const& value)
+ output_iterator& operator*() { return *this; }
+ output_iterator& operator++()
         {
- if (mode & count_characters) // count characters, if appropriate
- count_data.output();
-
- // always track position in the output (this is needed by different
- // generators, such as indent, pad, etc.)
- track_position_data.output(value);
+ if (!this->base_iterator::has_buffer())
+ ++sink; // increment only if not buffering
+ return *this;
+ }
+ output_iterator operator++(int)
+ {
+ if (!this->base_iterator::has_buffer()) {
+ output_iterator t(*this);
+ ++sink;
+ return t;
+ }
+ return *this;
+ }
 
- if (mode & buffer_characters) // buffer output, if appropriate
- buffer_data.output(value);
- else
+ template <typename T>
+ void operator=(T const& value)
+ {
+ if (this->base_iterator::output(value))
                 *sink = value;
         }
 
- // functions related to counting
- std::size_t count() const
- {
- return count_data.get_count();
- }
-
- // functions related to buffering
- std::size_t buffer_size() const
- {
- return buffer_data.buffer_size();
- }
- void buffer_copy()
- {
- buffer_data.copy(sink);
- }
-
- // return the current count in the output
- std::size_t get_out_count() const
- {
- return track_position_data.get_count();
- }
-
+ // plain output iterators are considered to be good all the time
+ bool good() const { return true; }
+
     protected:
         // this is the wrapped user supplied output iterator
         OutputIterator& sink;
 
     private:
- // these are the hooks providing optional functionality
- counting_sink count_data; // for counting
- buffer_sink<OutputIterator> buffer_data; // for buffering
- position_sink track_position_data; // for position tracking
- int mode;
-
         // suppress warning about assignment operator not being generated
         output_iterator& operator=(output_iterator const&);
     };
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename T, typename Elem, typename Traits>
- class output_iterator<ostream_iterator<T, Elem, Traits> >
- : public output_iterator<ostream_iterator<T, Elem, Traits>, int>
+ template <typename T, typename Elem, typename Traits, typename Properties>
+ class output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties>
+ : public output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties
+ , output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties> >
     {
     private:
- typedef
- output_iterator<ostream_iterator<T, Elem, Traits>, int>
- base_type;
- typedef ostream_iterator<T, Elem, Traits> base_iterator_type;
+ typedef output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties
+ , output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties>
+ > base_type;
+ typedef karma::ostream_iterator<T, Elem, Traits> base_iterator_type;
         typedef std::basic_ostream<Elem, Traits> ostream_type;
 
     public:
         output_iterator(base_iterator_type& sink)
- : base_type(sink)
- {}
+ : base_type(sink) {}
 
         ostream_type& get_ostream() { return this->sink.get_ostream(); }
+ ostream_type const& get_ostream() const { return this->sink.get_ostream(); }
+
+ // expose good bit of underlying stream object
+ bool good() const { return this->sink.get_ostream().good(); }
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -341,24 +500,28 @@
     struct enable_counting
     {
         enable_counting(OutputIterator& sink_, std::size_t count = 0)
- : sink(sink_)
- {
- sink.enable_counting(count);
- }
- ~enable_counting()
- {
- sink.disable_counting();
- sink.reset_counting();
- }
-
- void disable()
+ : count_data(sink_, count) {}
+
+ // get number of characters counted since last enable
+ std::size_t count() const
         {
- sink.disable_counting();
+ return count_data.get_count();
         }
 
- OutputIterator& sink;
+ private:
+ counting_sink<OutputIterator> count_data; // for counting
+ };
+
+ template <typename OutputIterator>
+ struct disable_counting
+ {
+ disable_counting(OutputIterator& sink_)
+ : count_data(sink_, 0, false) {}
+
+ private:
+ counting_sink<OutputIterator> count_data;
     };
-
+
     ///////////////////////////////////////////////////////////////////////////
     // Helper class for exception safe enabling of character buffering in the
     // output iterator
@@ -366,25 +529,68 @@
     template <typename OutputIterator>
     struct enable_buffering
     {
- enable_buffering(OutputIterator& sink_, std::size_t width = 0)
- : sink(sink_)
- {
- sink.enable_buffering(width);
+ enable_buffering(OutputIterator& sink_
+ , std::size_t width = std::size_t(-1))
+ : sink(sink_), prev_buffer(NULL), enabled(false)
+ {
+ buffer_data.enable(width);
+ prev_buffer = sink.chain_buffering(&buffer_data);
+ enabled = true;
         }
         ~enable_buffering()
         {
- sink.disable_buffering();
- sink.reset_buffering();
+ disable();
         }
-
+
+ // reset buffer chain to initial state
         void disable()
         {
- sink.disable_buffering();
+ if (enabled) {
+ BOOST_VERIFY(&buffer_data == sink.chain_buffering(prev_buffer));
+ enabled = false;
+ }
+ }
+
+ // copy to the underlying sink whatever is in the local buffer
+ bool buffer_copy(std::size_t maxwidth = std::size_t(-1)
+ , bool disable_ = true)
+ {
+ if (disable_)
+ disable();
+ return buffer_data.copy(sink, maxwidth) && sink.good();
+ }
+
+ // return number of characters stored in the buffer
+ std::size_t buffer_size() const
+ {
+ return buffer_data.buffer_size();
         }
-
+
+// bool buffer_copy_rest(std::size_t start_at = 0)
+// {
+// return buffer_data.copy_rest(sink, start_at);
+// }
+
+ private:
         OutputIterator& sink;
+ buffer_sink<OutputIterator> buffer_data; // for buffering
+ buffer_sink<OutputIterator>* prev_buffer; // previous buffer in chain
+ bool enabled;
     };
-
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Sink>
+ bool sink_is_good(Sink const& sink)
+ {
+ return true; // the general case is always good
+ }
+
+ template <typename OutputIterator, typename Derived>
+ bool sink_is_good(output_iterator<OutputIterator, Derived> const& sink)
+ {
+ return sink.good(); // our own output iterators are handled separately
+ }
+
 }}}}
 
 #endif

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,74 +6,122 @@
 #if !defined(BOOST_SPIRIT_KARMA_STRING_GENERATE_FEB_23_2007_1232PM)
 #define BOOST_SPIRIT_KARMA_STRING_GENERATE_FEB_23_2007_1232PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <string>
-#include <boost/spirit/home/karma/detail/generate_to.hpp>
 #include <boost/spirit/home/support/char_class.hpp>
+#include <boost/spirit/home/karma/detail/generate_to.hpp>
+#include <boost/range/iterator_range.hpp>
 
 namespace boost { namespace spirit { namespace karma { namespace detail
 {
     ///////////////////////////////////////////////////////////////////////////
     // generate a string given by a pointer
     template <typename OutputIterator, typename Char>
- inline bool
- string_generate(OutputIterator& sink, Char const* str, unused_type = unused)
+ inline bool string_generate(OutputIterator& sink, Char const* str)
     {
         for (Char ch = *str; ch != 0; ch = *++str)
- detail::generate_to(sink, ch);
- return true;
+ {
+ *sink = ch;
+ ++sink;
+ }
+ return detail::sink_is_good(sink);
     }
 
     ///////////////////////////////////////////////////////////////////////////
     // generate a string given by a std::string
- template <typename OutputIterator, typename Char>
- inline bool
- string_generate(OutputIterator& sink, std::basic_string<Char> const& str,
- unused_type = unused)
- {
- typedef std::basic_string<Char> string_type;
-
- typename string_type::const_iterator end = str.end();
- for (typename string_type::const_iterator it = str.begin();
- it != end; ++it)
+ template <typename OutputIterator, typename Char, typename Traits
+ , typename Allocator>
+ inline bool string_generate(OutputIterator& sink
+ , std::basic_string<Char, Traits, Allocator> const& str)
+ {
+ return string_generate(sink, str.c_str());
+ }
+
+ template <typename OutputIterator, typename Iterator>
+ inline bool string_generate(OutputIterator& sink
+ , boost::iterator_range<Iterator> const& r)
+ {
+ Iterator end = r.end();
+ for (Iterator it = r.begin(); it != end; ++it)
         {
- detail::generate_to(sink, *it);
+ *sink = *it;
+ ++sink;
         }
- return true;
+ return detail::sink_is_good(sink);
     }
 
     ///////////////////////////////////////////////////////////////////////////
     // generate a string given by a pointer, converting according using a
- // given character class tag
- template <typename OutputIterator, typename Char, typename Tag>
- inline bool
- string_generate(OutputIterator& sink, Char const* str, Tag tag)
+ // given character class and case tag
+ template <typename OutputIterator, typename Char, typename CharEncoding
+ , typename Tag>
+ inline bool string_generate(OutputIterator& sink, Char const* str
+ , CharEncoding ce, Tag tag)
     {
         for (Char ch = *str; ch != 0; ch = *++str)
- detail::generate_to(sink, ch, tag);
- return true;
+ {
+ *sink = spirit::char_class::convert<CharEncoding>::to(Tag(), ch);
+ ++sink;
+ }
+ return detail::sink_is_good(sink);
+ }
+
+ template <typename OutputIterator, typename Char>
+ inline bool string_generate(OutputIterator& sink, Char const* str
+ , unused_type, unused_type)
+ {
+ return string_generate(sink, str);
     }
 
     ///////////////////////////////////////////////////////////////////////////
     // generate a string given by a std::string, converting according using a
- // given character class tag
- template <typename OutputIterator, typename Char, typename Tag>
- inline bool
- string_generate(OutputIterator& sink, std::basic_string<Char> const& str,
- Tag tag)
- {
- typedef std::basic_string<Char> string_type;
-
- typename string_type::const_iterator end = str.end();
- for (typename string_type::const_iterator it = str.begin();
- it != end; ++it)
+ // given character class and case tag
+ template <typename OutputIterator, typename Char, typename CharEncoding
+ , typename Tag, typename Traits, typename Allocator>
+ inline bool string_generate(OutputIterator& sink
+ , std::basic_string<Char, Traits, Allocator> const& str
+ , CharEncoding ce, Tag tag)
+ {
+ return string_generate(sink, str.c_str(), ce, tag);
+ }
+
+ template <typename OutputIterator, typename Iterator, typename CharEncoding
+ , typename Tag>
+ inline bool string_generate(OutputIterator& sink
+ , boost::iterator_range<Iterator> const& r, CharEncoding ce, Tag tag)
+ {
+ Iterator end = r.end();
+ for (Iterator it = r.begin(); it != end; ++it)
+ {
+ *sink = spirit::char_class::convert<CharEncoding>::to(Tag(), *it);
+ ++sink;
+ }
+ return detail::sink_is_good(sink);
+ }
+
+ template <typename OutputIterator, typename Char, typename Traits
+ , typename Allocator>
+ inline bool string_generate(OutputIterator& sink
+ , std::basic_string<Char, Traits, Allocator> const& str
+ , unused_type, unused_type)
+ {
+ return string_generate(sink, str.c_str());
+ }
+
+ template <typename OutputIterator, typename Iterator>
+ inline bool string_generate(OutputIterator& sink
+ , boost::iterator_range<Iterator> const& r, unused_type, unused_type)
+ {
+ Iterator end = r.end();
+ for (Iterator it = r.begin(); it != end; ++it)
         {
- detail::generate_to(sink, *it, tag);
+ *sink = *it;
+ ++sink;
         }
- return true;
+ return detail::sink_is_good(sink);
     }
 
 }}}}

Modified: branches/release/boost/spirit/home/karma/directive.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive.hpp (original)
+++ branches/release/boost/spirit/home/karma/directive.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,8 +6,8 @@
 #if !defined(BOOST_SPIRIT_KARMA_DIRECTIVE_FEB_21_2007_0833PM)
 #define BOOST_SPIRIT_KARMA_DIRECTIVE_FEB_21_2007_0833PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -17,13 +17,18 @@
 #include <boost/spirit/home/karma/directive/left_alignment.hpp>
 #include <boost/spirit/home/karma/directive/right_alignment.hpp>
 #include <boost/spirit/home/karma/directive/center_alignment.hpp>
-#include <boost/spirit/home/karma/directive/alignment_meta_grammar.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+// directives related to truncating length
+// maxwidth[...]
+///////////////////////////////////////////////////////////////////////////////
+#include <boost/spirit/home/karma/directive/maxwidth.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 // directives related to character case
 // lower[...] and upper[...]
 ///////////////////////////////////////////////////////////////////////////////
-#include <boost/spirit/home/karma/directive/case_meta_grammar.hpp>
+#include <boost/spirit/home/karma/directive/upper_lower_case.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 // directives related to delimiting generators
@@ -31,6 +36,23 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include <boost/spirit/home/karma/directive/verbatim.hpp>
 #include <boost/spirit/home/karma/directive/delimit.hpp>
-#include <boost/spirit/home/karma/directive/delimiter_meta_grammar.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+// repeat directives
+// repeat[...]
+///////////////////////////////////////////////////////////////////////////////
+#include <boost/spirit/home/karma/directive/repeat.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+// omit directive
+// omit[...]
+///////////////////////////////////////////////////////////////////////////////
+#include <boost/spirit/home/karma/directive/omit.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+// buffer directive
+// buffer[...]
+///////////////////////////////////////////////////////////////////////////////
+#include <boost/spirit/home/karma/directive/buffer.hpp>
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/directive/alignment_meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/alignment_meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,171 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_ALIGNMENT_META_GRAMMAR_FEB_21_2007_0826PM)
-#define BOOST_SPIRIT_KARMA_ALIGNMENT_META_GRAMMAR_FEB_21_2007_0826PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/modifier.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/or.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- struct main_meta_grammar;
-
- struct simple_left_aligment;
- struct simple_right_aligment;
- struct simple_center_aligment;
-
- struct width_left_aligment;
- struct width_right_aligment;
- struct width_center_aligment;
-
- struct padding_left_aligment;
- struct padding_right_aligment;
- struct padding_center_aligment;
-
- struct full_left_aligment;
- struct full_right_aligment;
- struct full_center_aligment;
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // left, right and center directive meta-grammars
- ///////////////////////////////////////////////////////////////////////////
- struct simple_align_directive_meta_grammar
- : proto::or_<
- meta_grammar::binary_rule<
- karma::domain, proto::tag::subscript, simple_left_aligment,
- proto::terminal<tag::left_align>, main_meta_grammar
- >,
- meta_grammar::binary_rule<
- karma::domain, proto::tag::subscript, simple_right_aligment,
- proto::terminal<tag::right_align>, main_meta_grammar
- >,
- meta_grammar::binary_rule<
- karma::domain, proto::tag::subscript, simple_center_aligment,
- proto::terminal<tag::center>, main_meta_grammar
- >
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- // matches alignment directives defining the width only:
- // left_align(width)[...], right_align(width)[...], center(width)[...]
- ///////////////////////////////////////////////////////////////////////////
- struct width_align_directive_meta_grammar
- : proto::or_<
- meta_grammar::subscript_function1_rule<
- karma::domain, tag::left_align, width_left_aligment,
- proto::terminal<int>, main_meta_grammar
- >,
- meta_grammar::subscript_function1_rule<
- karma::domain, tag::right_align, width_right_aligment,
- proto::terminal<int>, main_meta_grammar
- >,
- meta_grammar::subscript_function1_rule<
- karma::domain, tag::center, width_center_aligment,
- proto::terminal<int>, main_meta_grammar
- >
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- // matches alignment directives defining the padding generator only:
- // left_align(padding)[...], right_align(padding)[...], center(padding)[...]
- ///////////////////////////////////////////////////////////////////////////
- struct padding_align_directive_meta_grammar
- : proto::or_<
- meta_grammar::subscript_function1_rule<
- karma::domain, tag::left_align, padding_left_aligment,
- main_meta_grammar, main_meta_grammar
- >,
- meta_grammar::subscript_function1_rule<
- karma::domain, tag::right_align, padding_right_aligment,
- main_meta_grammar, main_meta_grammar
- >,
- meta_grammar::subscript_function1_rule<
- karma::domain, tag::center, padding_center_aligment,
- main_meta_grammar, main_meta_grammar
- >
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- // matches full alignment directives: left_align(width, padding)[...],
- // right_align(width, padding)[...], center(width, padding)[...]
- ///////////////////////////////////////////////////////////////////////////
- struct full_align_directive_meta_grammar
- : proto::or_<
- meta_grammar::subscript_function2_rule<
- karma::domain, tag::left_align, full_left_aligment,
- proto::terminal<int>, main_meta_grammar, main_meta_grammar
- >,
- meta_grammar::subscript_function2_rule<
- karma::domain, tag::right_align, full_right_aligment,
- proto::terminal<int>, main_meta_grammar, main_meta_grammar
- >,
- meta_grammar::subscript_function2_rule<
- karma::domain, tag::center, full_center_aligment,
- proto::terminal<int>, main_meta_grammar, main_meta_grammar
- >
- >
- {};
-
- // main alignment_directive_meta_grammar
- struct alignment_directive_meta_grammar
- : proto::or_<
- simple_align_directive_meta_grammar,
- width_align_directive_meta_grammar,
- padding_align_directive_meta_grammar,
- full_align_directive_meta_grammar
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hooks into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<
- Expr,
- typename enable_if<
- proto::matches<Expr, alignment_directive_meta_grammar>
- >::type
- >
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<
- Expr,
- typename enable_if<
- proto::matches<Expr, alignment_directive_meta_grammar>
- >::type
- >
- : mpl::identity<alignment_directive_meta_grammar>
- {
- };
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/karma/directive/case_meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/case_meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,133 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_CASE_META_GRAMMAR_FEB_21_2007_0826PM)
-#define BOOST_SPIRIT_KARMA_CASE_META_GRAMMAR_FEB_21_2007_0826PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/modifier.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/iso8859_1.hpp>
-#include <boost/spirit/home/support/ascii.hpp>
-#include <boost/spirit/home/support/standard.hpp>
-#include <boost/spirit/home/support/standard_wide.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/or.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- struct main_meta_grammar;
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // lower and upper directive meta-grammars
- ///////////////////////////////////////////////////////////////////////////
- struct lower_case_directive_meta_grammar
- : meta_grammar::deep_directive_meta_grammar<
- spirit::char_class::lower_case_tag<proto::_>,
- main_meta_grammar
- >
- {};
-
- struct upper_case_directive_meta_grammar
- : meta_grammar::deep_directive_meta_grammar<
- spirit::char_class::upper_case_tag<proto::_>,
- main_meta_grammar
- >
- {};
-
- // main directive_meta_grammar
- struct directive_meta_grammar
- : proto::or_<
- lower_case_directive_meta_grammar,
- upper_case_directive_meta_grammar
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hooks into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<Expr,
- typename enable_if<proto::matches<Expr, directive_meta_grammar> >::type>
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<Expr,
- typename enable_if<proto::matches<Expr, directive_meta_grammar> >::type>
- : mpl::identity<directive_meta_grammar>
- {
- };
-
-}}}
-
-namespace boost { namespace spirit
-{
- ///////////////////////////////////////////////////////////////////////////
- // The following specializations for the add_modifier template are added
- // to allow for special handling of the lower[] and upper[] directives
- // which are mutually exclusive. Since the first of these directives
- // added to the modifier corresponds to the outermost one in the generator
- // expression, we just ignore the request to add a tag if one of the two
- // has been already added.
- template <typename Modifier, typename Tag>
- struct add_modifier<Modifier, spirit::char_class::lower_case_tag<Tag> >
- {
- // add the new tag to the modifier (if it isn't already)
- typedef spirit::char_class::upper_case_tag<Tag> reciprocal_tag;
- typedef spirit::char_class::lower_case_tag<Tag> tag;
-
- typedef typename
- mpl::if_<
- mpl::or_<
- is_member_of_modifier<Modifier, reciprocal_tag>,
- is_member_of_modifier<Modifier, tag>
- >,
- Modifier,
- modifier<Modifier, tag>
- >::type
- type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Modifier, typename Tag>
- struct add_modifier<Modifier, spirit::char_class::upper_case_tag<Tag> >
- {
- // add the new tag to the modifier (if it isn't already)
- typedef spirit::char_class::lower_case_tag<Tag> reciprocal_tag;
- typedef spirit::char_class::upper_case_tag<Tag> tag;
-
- typedef typename
- mpl::if_<
- mpl::or_<
- is_member_of_modifier<Modifier, reciprocal_tag>,
- is_member_of_modifier<Modifier, tag>
- >,
- Modifier,
- modifier<Modifier, tag>
- >::type
- type;
- };
-
-}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/directive/center_alignment.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/center_alignment.hpp (original)
+++ branches/release/boost/spirit/home/karma/directive/center_alignment.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,221 +6,289 @@
 #if !defined(BOOST_SPIRIT_KARMA_CENTER_ALIGNMENT_FEB_27_2007_1216PM)
 #define BOOST_SPIRIT_KARMA_CENTER_ALIGNMENT_FEB_27_2007_1216PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/directive/detail/center_alignment_generate.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
+#include <boost/spirit/home/karma/detail/default_width.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/fusion/include/vector.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/integer_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
-//
-// The BOOST_KARMA_DEFAULT_FIELD_LENGTH specifies the default field length
-// to be used for padding.
-//
-///////////////////////////////////////////////////////////////////////////////
-#if !defined(BOOST_KARMA_DEFAULT_FIELD_LENGTH)
-#define BOOST_KARMA_DEFAULT_FIELD_LENGTH 10
-#endif
-
-namespace boost { namespace spirit { namespace karma
+namespace boost { namespace spirit
 {
     ///////////////////////////////////////////////////////////////////////////
- // The simple center alignment directive is used for center[...]
- // generators. It uses default values for the generated width (defined via
- // the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant) and for the padding
- // generator (always spaces).
+ // Enablers
     ///////////////////////////////////////////////////////////////////////////
- struct simple_center_aligment
- {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::argument1<Component>::type,
- Context
- >
- {
- };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
- {
- return detail::center_generate(sink, ctx, d, param,
- argument1(component), BOOST_KARMA_DEFAULT_FIELD_LENGTH,
- spirit::as_component(karma::domain(), ' '));
- }
+ // enables center[]
+ template <>
+ struct use_directive<karma::domain, tag::center>
+ : mpl::true_ {};
+
+ // enables center(d)[g] and center(w)[g], where d is a generator
+ // and w is a maximum width
+ template <typename T>
+ struct use_directive<karma::domain
+ , terminal_ex<tag::center, fusion::vector1<T> > >
+ : mpl::true_ {};
+
+ // enables *lazy* delimit(d)[g], where d provides a generator
+ template <>
+ struct use_lazy_directive<karma::domain, tag::center, 1>
+ : mpl::true_ {};
+
+ // enables center(w, d)[g], where d is a generator and w is a maximum
+ // width
+ template <typename Width, typename Padding>
+ struct use_directive<karma::domain
+ , terminal_ex<tag::center, fusion::vector2<Width, Padding> > >
+ : spirit::traits::matches<karma::domain, Padding> {};
+
+ // enables *lazy* delimit(w, d)[g], where d provides a generator and w is
+ // a maximum width
+ template <>
+ struct use_lazy_directive<karma::domain, tag::center, 2>
+ : mpl::true_ {};
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- std::string result = "center[";
+}}
 
- typedef typename
- spirit::result_of::argument1<Component>::type::director
- director;
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace karma
+{
+ using spirit::center;
+ using spirit::center_type;
 
- result += director::what(spirit::argument1(component), ctx);
- result += "]";
- return result;
+ namespace detail
+ {
+ ///////////////////////////////////////////////////////////////////////
+ // The center_generate template function is used for all the
+ // different flavors of the center[] directive.
+ ///////////////////////////////////////////////////////////////////////
+ template <typename OutputIterator, typename Context, typename Delimiter,
+ typename Attribute, typename Embedded, typename Padding>
+ inline static bool
+ center_generate(OutputIterator& sink, Context& ctx,
+ Delimiter const& d, Attribute const& attr, Embedded const& e,
+ unsigned int const width, Padding const& p)
+ {
+ // wrap the given output iterator to allow left padding
+ detail::enable_buffering<OutputIterator> buffering(sink, width);
+ bool r = false;
+
+ // first generate the embedded output
+ {
+ detail::disable_counting<OutputIterator> nocounting(sink);
+ r = e.generate(sink, ctx, d, attr);
+ } // re-enable counting
+
+ buffering.disable(); // do not perform buffering any more
+
+ // generate the left padding
+ detail::enable_counting<OutputIterator> counting(sink);
+
+ std::size_t const pre = width - (buffering.buffer_size() + width)/2;
+ while (r && counting.count() < pre)
+ r = p.generate(sink, ctx, unused, unused);
+
+ if (r) {
+ // copy the embedded output to the target output iterator
+ buffering.buffer_copy();
+
+ // generate the right padding
+ while (r && counting.count() < width)
+ r = p.generate(sink, ctx, unused, unused);
+ }
+ return r;
         }
- };
+ }
 
     ///////////////////////////////////////////////////////////////////////////
- // The center alignment with width directive, is used for generators
- // like center(width)[...]. It uses a default value for the padding
+ // The simple left alignment directive is used for center[...]
+ // generators. It uses default values for the generated width (defined via
+ // the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant) and for the padding
     // generator (always spaces).
     ///////////////////////////////////////////////////////////////////////////
- struct width_center_aligment
+ template <typename Subject, typename Width = detail::default_width>
+ struct simple_center_alignment
+ : unary_generator<simple_center_alignment<Subject, Width> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+
+ typedef mpl::int_<
+ generator_properties::countingbuffer | subject_type::properties::value
+ > properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
- {
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ simple_center_alignment(Subject const& subject, Width width = Width())
+ : subject(subject), width(width) {}
+
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
         {
- return detail::center_generate(sink, ctx, d, param,
- subject(component), proto::child_c<0>(argument1(component)), ' ');
+ return detail::center_generate(sink, ctx, d, attr,
+ subject, width, compile<karma::domain>(' '));
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "center(";
-
- result += boost::lexical_cast<std::string>(
- proto::child_c<0>(argument1(component)));
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ return info("center", subject.what(context));
         }
+
+ Subject subject;
+ Width width;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- // The center alignment directive with padding, is used for generators like
+ // The left alignment directive with padding, is used for generators like
     // center(padding)[...], where padding is a arbitrary generator
     // expression. It uses a default value for the generated width (defined
     // via the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant).
     ///////////////////////////////////////////////////////////////////////////
- struct padding_center_aligment
+ template <typename Subject, typename Padding
+ , typename Width = detail::default_width>
+ struct padding_center_alignment
+ : unary_generator<padding_center_alignment<Subject, Padding, Width> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+ typedef Padding padding_type;
+
+ typedef mpl::int_<
+ generator_properties::countingbuffer |
+ subject_type::properties::value | padding_type::properties::value
+ > properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
- {
- };
+ : traits::attribute_of<Subject, Context, Iterator>::type
+ {};
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ padding_center_alignment(Subject const& subject, Padding const& padding
+ , Width width = Width())
+ : subject(subject), padding(padding), width(width) {}
+
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
         {
- return detail::center_generate(sink, ctx, d, param,
- subject(component), BOOST_KARMA_DEFAULT_FIELD_LENGTH,
- argument1(component));
+ return detail::center_generate(sink, ctx, d, attr,
+ subject, width, padding);
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "center(";
-
- typedef typename
- spirit::result_of::argument1<Component>::type::director
- padding;
-
- result += padding::what(spirit::argument1(component), ctx);
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ return info("center", subject.what(context));
         }
+
+ Subject subject;
+ Padding padding;
+ Width width;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- // The full center alignment directive, is used for generators like
- // center(width, padding)[...], where width is a integer value to be
- // used as the field width and padding is a arbitrary generator
- // expression.
+ // Generator generators: make_xxx function (objects)
     ///////////////////////////////////////////////////////////////////////////
- struct full_center_aligment
+
+ // creates center[] directive generator
+ template <typename Subject, typename Modifiers>
+ struct make_directive<tag::center, Subject, Modifiers>
     {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
+ typedef simple_center_alignment<Subject> result_type;
+ result_type operator()(unused_type, Subject const& subject
+ , unused_type) const
         {
- };
+ return result_type(subject);
+ }
+ };
+
+ // creates center(width)[] directive generator
+ template <typename Width, typename Subject, typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::center, fusion::vector1<Width> >
+ , Subject, Modifiers
+ , typename enable_if_c< integer_traits<Width>::is_integral >::type>
+ {
+ typedef simple_center_alignment<Subject, Width> result_type;
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , unused_type) const
         {
- return detail::center_generate(sink, ctx, d, param,
- subject(component), proto::child_c<0>(argument1(component)),
- argument2(component));
+ return result_type(subject, fusion::at_c<0>(term.args));
         }
+ };
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ // creates center(pad)[] directive generator
+ template <typename Padding, typename Subject, typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::center, fusion::vector1<Padding> >
+ , Subject, Modifiers
+ , typename enable_if<
+ mpl::and_<
+ spirit::traits::matches<karma::domain, Padding>,
+ mpl::not_<mpl::bool_<integer_traits<Padding>::is_integral> >
+ >
+ >::type>
+ {
+ typedef typename
+ result_of::compile<karma::domain, Padding, Modifiers>::type
+ padding_type;
+
+ typedef padding_center_alignment<Subject, padding_type> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , Modifiers const& modifiers) const
         {
- std::string result = "center(";
-
- result += boost::lexical_cast<std::string>(
- proto::child_c<0>(argument1(component)));
- result += ", ";
-
- typedef typename
- spirit::result_of::argument2<Component>::type::director
- padding;
-
- result += padding::what(spirit::argument2(component), ctx);
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
+ return result_type(subject
+ , compile<karma::domain>(fusion::at_c<0>(term.args), modifiers));
+ }
+ };
 
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ // creates center(pad, width)[] directive generator
+ template <typename Width, typename Padding, typename Subject
+ , typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::center, fusion::vector2<Width, Padding> >
+ , Subject, Modifiers>
+ {
+ typedef typename
+ result_of::compile<karma::domain, Padding, Modifiers>::type
+ padding_type;
+
+ typedef padding_center_alignment<Subject, padding_type, Width> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , Modifiers const& modifiers) const
+ {
+ return result_type(subject
+ , compile<karma::domain>(fusion::at_c<1>(term.args), modifiers)
+ , fusion::at_c<0>(term.args));
         }
     };
 

Modified: branches/release/boost/spirit/home/karma/directive/delimit.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/delimit.hpp (original)
+++ branches/release/boost/spirit/home/karma/directive/delimit.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,118 +6,163 @@
 #if !defined(BOOST_SPIRIT_KARMA_DELIMIT_MAR_02_2007_0217PM)
 #define BOOST_SPIRIT_KARMA_DELIMIT_MAR_02_2007_0217PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/detail/unused_delimiter.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/fusion/include/at.hpp>
-#include <boost/fusion/include/value_at.hpp>
+#include <boost/fusion/include/vector.hpp>
+
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_directive<karma::domain, tag::delimit> // enables delimit[]
+ : mpl::true_ {};
+
+ // enables delimit(d)[g], where d is a generator
+ template <typename T>
+ struct use_directive<karma::domain
+ , terminal_ex<tag::delimit, fusion::vector1<T> > >
+ : boost::spirit::traits::matches<karma::domain, T> {};
+
+ // enables *lazy* delimit(d)[g]
+ template <>
+ struct use_lazy_directive<karma::domain, tag::delimit, 1>
+ : mpl::true_ {};
+
+}}
 
 namespace boost { namespace spirit { namespace karma
 {
+ using spirit::delimit;
+ using spirit::delimit_type;
+
     ///////////////////////////////////////////////////////////////////////////
- // The delimit_space generator is used for delimit[...] directives.
+ // The redelimit_generator generator is used for delimit[...] directives.
     ///////////////////////////////////////////////////////////////////////////
- struct delimit_space
+ template <typename Subject>
+ struct redelimit_generator : unary_generator<redelimit_generator<Subject> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+
+ typedef typename subject_type::properties properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::right<Component>::type,
- Context
- >
- {
- };
-
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& /*d*/, Parameter const& param)
- {
- // the delimit_space generator simply dispatches to the embedded
- // generator while supplying a single space as the new delimiter
- // to use
- typedef typename
- result_of::right<Component>::type::director
- director;
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
 
- return director::generate(spirit::right(component),
- sink, ctx, spirit::as_component(karma::domain(), ' '), param);
+ redelimit_generator(Subject const& subject)
+ : subject(subject) {}
+
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ // The delimit_space generator simply dispatches to the embedded
+ // generator while supplying either the delimiter which has been
+ // used before a surrounding verbatim[] directive or a single
+ // space as the new delimiter to use (if no surrounding verbatim[]
+ // was specified).
+ return subject.generate(sink, ctx
+ , detail::get_delimiter(d, compile<karma::domain>(' ')), attr);
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "delimit[";
-
- typedef typename
- spirit::result_of::right<Component>::type::director
- director;
-
- result += director::what(spirit::right(component), ctx);
- result += "]";
- return result;
+ return info("delimit", subject.what(context));
         }
+
+ Subject subject;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- // The delimit_ generator is used for delimit(d)[...] directives.
+ // The delimit_generator is used for delimit(d)[...] directives.
     ///////////////////////////////////////////////////////////////////////////
- struct delimit_
+ template <typename Subject, typename Delimiter>
+ struct delimit_generator
+ : unary_generator<delimit_generator<Subject, Delimiter> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+ typedef Delimiter delimiter_type;
+
+ typedef typename subject_type::properties properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
- {
- };
-
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& /*d*/, Parameter const& param)
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
+
+ delimit_generator(Subject const& subject, Delimiter const& delimiter)
+ : subject(subject), delimiter(delimiter) {}
+
+ template <typename OutputIterator, typename Context
+ , typename Delimiter_, typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter_ const&
+ , Attribute const& attr) const
         {
             // the delimit generator simply dispatches to the embedded
             // generator while supplying it's argument as the new delimiter
             // to use
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- return director::generate(spirit::subject(component), sink, ctx,
- spirit::as_component(
- karma::domain(), spirit::argument1(component)),
- param);
+ return subject.generate(sink, ctx, delimiter, attr);
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "delimit(";
-
- typedef typename
- spirit::result_of::argument1<Component>::type::director
- delimiter;
+ return info("delimit", subject.what(context));
+ }
 
- result += delimiter::what(spirit::argument1(component), ctx);
- result +=")[";
+ Subject subject;
+ Delimiter delimiter;
+ };
 
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Subject, typename Modifiers>
+ struct make_directive<tag::delimit, Subject, Modifiers>
+ {
+ typedef redelimit_generator<Subject> result_type;
+ result_type operator()(unused_type, Subject const& subject
+ , unused_type) const
+ {
+ return result_type(subject);
+ }
+ };
 
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ template <typename Delimiter, typename Subject, typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::delimit, fusion::vector1<Delimiter> >
+ , Subject, Modifiers>
+ {
+ typedef typename
+ result_of::compile<karma::domain, Delimiter, Modifiers>::type
+ delimiter_type;
+
+ typedef delimit_generator<Subject, delimiter_type> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , unused_type) const
+ {
+ return result_type(subject
+ , compile<karma::domain>(fusion::at_c<0>(term.args)));
         }
     };
 

Deleted: branches/release/boost/spirit/home/karma/directive/delimiter_meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/delimiter_meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,87 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_DELIMITER_META_GRAMMAR_FEB_21_2007_0826PM)
-#define BOOST_SPIRIT_KARMA_DELIMITER_META_GRAMMAR_FEB_21_2007_0826PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/modifier.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/or.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- struct main_meta_grammar;
-
- struct delimit_;
- struct delimit_space;
- struct verbatim;
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // delimit and verbatim directive meta-grammars
- // delimit[...], delimit(delimiter)[...] and verbatim[...]
- ///////////////////////////////////////////////////////////////////////////
- struct delimiter_directive_meta_grammar
- : proto::or_<
- meta_grammar::binary_rule<
- karma::domain, proto::tag::subscript, verbatim,
- proto::terminal<tag::verbatim>, main_meta_grammar
- >,
- meta_grammar::binary_rule<
- karma::domain, proto::tag::subscript, delimit_space,
- proto::terminal<tag::delimit>, main_meta_grammar
- >,
- meta_grammar::subscript_function1_rule<
- karma::domain, tag::delimit, delimit_,
- main_meta_grammar, main_meta_grammar
- >
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hook into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<
- Expr,
- typename enable_if<
- proto::matches<Expr, delimiter_directive_meta_grammar>
- >::type
- >
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<
- Expr,
- typename enable_if<
- proto::matches<Expr, delimiter_directive_meta_grammar>
- >::type
- >
- : mpl::identity<delimiter_directive_meta_grammar>
- {
- };
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/directive/left_alignment.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/left_alignment.hpp (original)
+++ branches/release/boost/spirit/home/karma/directive/left_alignment.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,115 +6,142 @@
 #if !defined(BOOST_SPIRIT_KARMA_LEFT_ALIGNMENT_FEB_27_2007_1216PM)
 #define BOOST_SPIRIT_KARMA_LEFT_ALIGNMENT_FEB_27_2007_1216PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/directive/detail/left_alignment_generate.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
+#include <boost/spirit/home/karma/detail/default_width.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/fusion/include/vector.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/integer_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
-//
-// The BOOST_KARMA_DEFAULT_FIELD_LENGTH specifies the default field length
-// to be used for padding.
-//
-///////////////////////////////////////////////////////////////////////////////
-#if !defined(BOOST_KARMA_DEFAULT_FIELD_LENGTH)
-#define BOOST_KARMA_DEFAULT_FIELD_LENGTH 10
-#endif
-
-namespace boost { namespace spirit { namespace karma
+namespace boost { namespace spirit
 {
     ///////////////////////////////////////////////////////////////////////////
- // The simple left alignment directive is used for left_align[...]
- // generators. It uses default values for the generated width (defined via
- // the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant) and for the padding
- // generator (always spaces).
+ // Enablers
     ///////////////////////////////////////////////////////////////////////////
- struct simple_left_aligment
- {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::argument1<Component>::type,
- Context
- >
- {
- };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
- {
- return detail::left_align_generate(sink, ctx, d, param,
- argument1(component), BOOST_KARMA_DEFAULT_FIELD_LENGTH, ' ');
- }
+ // enables left_align[]
+ template <>
+ struct use_directive<karma::domain, tag::left_align>
+ : mpl::true_ {};
+
+ // enables left_align(d)[g] and left_align(w)[g], where d is a generator
+ // and w is a maximum width
+ template <typename T>
+ struct use_directive<karma::domain
+ , terminal_ex<tag::left_align, fusion::vector1<T> > >
+ : mpl::true_ {};
+
+ // enables *lazy* left_align(d)[g], where d provides a generator
+ template <>
+ struct use_lazy_directive<karma::domain, tag::left_align, 1>
+ : mpl::true_ {};
+
+ // enables left_align(w, d)[g], where d is a generator and w is a maximum
+ // width
+ template <typename Width, typename Padding>
+ struct use_directive<karma::domain
+ , terminal_ex<tag::left_align, fusion::vector2<Width, Padding> > >
+ : spirit::traits::matches<karma::domain, Padding> {};
+
+ // enables *lazy* left_align(w, d)[g], where d provides a generator and w
+ // is a maximum width
+ template <>
+ struct use_lazy_directive<karma::domain, tag::left_align, 2>
+ : mpl::true_ {};
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- std::string result = "left_align[";
+}}
 
- typedef typename
- spirit::result_of::argument1<Component>::type::director
- director;
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace karma
+{
+ using spirit::left_align;
+ using spirit::left_align_type;
+
+ namespace detail
+ {
+ ///////////////////////////////////////////////////////////////////////
+ // The left_align_generate template function is used for all the
+ // different flavors of the left_align[] directive.
+ ///////////////////////////////////////////////////////////////////////
+ template <typename OutputIterator, typename Context, typename Delimiter,
+ typename Attribute, typename Embedded, typename Padding>
+ inline static bool
+ left_align_generate(OutputIterator& sink, Context& ctx,
+ Delimiter const& d, Attribute const& attr, Embedded const& e,
+ unsigned int const width, Padding const& p)
+ {
+ // wrap the given output iterator to allow counting
+ detail::enable_counting<OutputIterator> counting(sink);
+
+ // first generate the underlying output
+ bool r = e.generate(sink, ctx, d, attr);
+
+ // pad the output until the max width is reached
+ while(r && counting.count() < width)
+ r = p.generate(sink, ctx, unused, unused);
 
- result += director::what(spirit::argument1(component), ctx);
- result += "]";
- return result;
+ return r;
         }
- };
+ }
 
     ///////////////////////////////////////////////////////////////////////////
- // The left alignment with width directive, is used for generators
- // like left_align(width)[...]. It uses a default value for the padding
+ // The simple left alignment directive is used for left_align[...]
+ // generators. It uses default values for the generated width (defined via
+ // the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant) and for the padding
     // generator (always spaces).
     ///////////////////////////////////////////////////////////////////////////
- struct width_left_aligment
+ template <typename Subject, typename Width = detail::default_width>
+ struct simple_left_alignment
+ : unary_generator<simple_left_alignment<Subject, Width> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+
+ typedef mpl::int_<
+ generator_properties::counting | subject_type::properties::value
+ > properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
- {
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
+
+ simple_left_alignment(Subject const& subject, Width width = Width())
+ : subject(subject), width(width) {}
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
         {
- return detail::left_align_generate(sink, ctx, d, param,
- subject(component), proto::child_c<0>(argument1(component)), ' ');
+ return detail::left_align_generate(sink, ctx, d, attr,
+ subject, width, compile<karma::domain>(' '));
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "left_align(";
-
- result += boost::lexical_cast<std::string>(
- proto::child_c<0>(argument1(component)));
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ return info("left_align", subject.what(context));
         }
+
+ Subject subject;
+ Width width;
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -123,103 +150,128 @@
     // expression. It uses a default value for the generated width (defined
     // via the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant).
     ///////////////////////////////////////////////////////////////////////////
- struct padding_left_aligment
+ template <typename Subject, typename Padding
+ , typename Width = detail::default_width>
+ struct padding_left_alignment
+ : unary_generator<padding_left_alignment<Subject, Padding, Width> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+ typedef Padding padding_type;
+
+ typedef mpl::int_<
+ generator_properties::counting |
+ subject_type::properties::value | padding_type::properties::value
+ > properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
- {
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ padding_left_alignment(Subject const& subject, Padding const& padding
+ , Width width = Width())
+ : subject(subject), padding(padding), width(width) {}
+
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
         {
- return detail::left_align_generate(sink, ctx, d, param,
- subject(component), BOOST_KARMA_DEFAULT_FIELD_LENGTH,
- argument1(component));
+ return detail::left_align_generate(sink, ctx, d, attr,
+ subject, width, padding);
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "left_align(";
-
- typedef typename
- spirit::result_of::argument1<Component>::type::director
- padding;
-
- result += padding::what(spirit::argument1(component), ctx);
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ return info("left_align", subject.what(context));
         }
+
+ Subject subject;
+ Padding padding;
+ Width width;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- // The full left alignment directive, is used for generators like
- // left_align(width, padding)[...], where width is a integer value to be
- // used as the field width and padding is a arbitrary generator
- // expression.
+ // Generator generators: make_xxx function (objects)
     ///////////////////////////////////////////////////////////////////////////
- struct full_left_aligment
+
+ // creates left_align[] directive generator
+ template <typename Subject, typename Modifiers>
+ struct make_directive<tag::left_align, Subject, Modifiers>
     {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
+ typedef simple_left_alignment<Subject> result_type;
+ result_type operator()(unused_type, Subject const& subject
+ , unused_type) const
         {
- };
+ return result_type(subject);
+ }
+ };
+
+ // creates left_align(width)[] directive generator
+ template <typename Width, typename Subject, typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::left_align, fusion::vector1<Width> >
+ , Subject, Modifiers
+ , typename enable_if_c< integer_traits<Width>::is_integral >::type>
+ {
+ typedef simple_left_alignment<Subject, Width> result_type;
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , unused_type) const
         {
- return detail::left_align_generate(sink, ctx, d, param,
- subject(component), proto::child_c<0>(argument1(component)),
- argument2(component));
+ return result_type(subject, fusion::at_c<0>(term.args));
         }
+ };
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ // creates left_align(pad)[] directive generator
+ template <typename Padding, typename Subject, typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::left_align, fusion::vector1<Padding> >
+ , Subject, Modifiers
+ , typename enable_if<
+ mpl::and_<
+ spirit::traits::matches<karma::domain, Padding>,
+ mpl::not_<mpl::bool_<integer_traits<Padding>::is_integral> >
+ >
+ >::type>
+ {
+ typedef typename
+ result_of::compile<karma::domain, Padding, Modifiers>::type
+ padding_type;
+
+ typedef padding_left_alignment<Subject, padding_type> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , Modifiers const& modifiers) const
         {
- std::string result = "left_align(";
-
- result += boost::lexical_cast<std::string>(
- proto::child_c<0>(argument1(component)));
- result += ", ";
-
- typedef typename
- spirit::result_of::argument2<Component>::type::director
- padding;
-
- result += padding::what(spirit::argument2(component), ctx);
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
+ return result_type(subject
+ , compile<karma::domain>(fusion::at_c<0>(term.args), modifiers));
+ }
+ };
 
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ // creates left_align(pad, width)[] directive generator
+ template <typename Width, typename Padding, typename Subject
+ , typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::left_align, fusion::vector2<Width, Padding> >
+ , Subject, Modifiers>
+ {
+ typedef typename
+ result_of::compile<karma::domain, Padding, Modifiers>::type
+ padding_type;
+
+ typedef padding_left_alignment<Subject, padding_type, Width> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , unused_type) const
+ {
+ return result_type(subject
+ , compile<karma::domain>(fusion::at_c<1>(term.args))
+ , fusion::at_c<0>(term.args));
         }
     };
 

Modified: branches/release/boost/spirit/home/karma/directive/right_alignment.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/right_alignment.hpp (original)
+++ branches/release/boost/spirit/home/karma/directive/right_alignment.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,221 +6,282 @@
 #if !defined(BOOST_SPIRIT_KARMA_RIGHT_ALIGNMENT_FEB_27_2007_1216PM)
 #define BOOST_SPIRIT_KARMA_RIGHT_ALIGNMENT_FEB_27_2007_1216PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/directive/detail/right_alignment_generate.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
+#include <boost/spirit/home/karma/detail/default_width.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/fusion/include/vector.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/integer_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
-//
-// The BOOST_KARMA_DEFAULT_FIELD_LENGTH specifies the default field length
-// to be used for padding.
-//
-///////////////////////////////////////////////////////////////////////////////
-#if !defined(BOOST_KARMA_DEFAULT_FIELD_LENGTH)
-#define BOOST_KARMA_DEFAULT_FIELD_LENGTH 10
-#endif
-
-namespace boost { namespace spirit { namespace karma
+namespace boost { namespace spirit
 {
     ///////////////////////////////////////////////////////////////////////////
- // The simple right alignment directive is used for right_align[...]
- // generators. It uses default values for the generated width (defined via
- // the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant) and for the padding
- // generator (always spaces).
+ // Enablers
     ///////////////////////////////////////////////////////////////////////////
- struct simple_right_aligment
- {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::argument1<Component>::type,
- Context
- >
- {
- };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
- {
- return detail::right_align_generate(sink, ctx, d, param,
- argument1(component), BOOST_KARMA_DEFAULT_FIELD_LENGTH,
- spirit::as_component(karma::domain(), ' '));
- }
+ // enables right_align[]
+ template <>
+ struct use_directive<karma::domain, tag::right_align>
+ : mpl::true_ {};
+
+ // enables right_align(d)[g] and right_align(w)[g], where d is a generator
+ // and w is a maximum width
+ template <typename T>
+ struct use_directive<karma::domain
+ , terminal_ex<tag::right_align, fusion::vector1<T> > >
+ : mpl::true_ {};
+
+ // enables *lazy* delimit(d)[g], where d provides a generator
+ template <>
+ struct use_lazy_directive<karma::domain, tag::right_align, 1>
+ : mpl::true_ {};
+
+ // enables right_align(w, d)[g], where d is a generator and w is a maximum
+ // width
+ template <typename Width, typename Padding>
+ struct use_directive<karma::domain
+ , terminal_ex<tag::right_align, fusion::vector2<Width, Padding> > >
+ : spirit::traits::matches<karma::domain, Padding> {};
+
+ // enables *lazy* delimit(w, d)[g], where d provides a generator and w is
+ // a maximum width
+ template <>
+ struct use_lazy_directive<karma::domain, tag::right_align, 2>
+ : mpl::true_ {};
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- std::string result = "right_align[";
+}}
 
- typedef typename
- spirit::result_of::argument1<Component>::type::director
- director;
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace karma
+{
+ using spirit::right_align;
+ using spirit::right_align_type;
 
- result += director::what(spirit::argument1(component), ctx);
- result += "]";
- return result;
+ namespace detail
+ {
+ ///////////////////////////////////////////////////////////////////////
+ // The right_align_generate template function is used for all the
+ // different flavors of the right_align[] directive.
+ ///////////////////////////////////////////////////////////////////////
+ template <typename OutputIterator, typename Context, typename Delimiter,
+ typename Attribute, typename Embedded, typename Padding>
+ inline static bool
+ right_align_generate(OutputIterator& sink, Context& ctx,
+ Delimiter const& d, Attribute const& attr, Embedded const& e,
+ unsigned int const width, Padding const& p)
+ {
+ // wrap the given output iterator to allow left padding
+ detail::enable_buffering<OutputIterator> buffering(sink, width);
+ bool r = false;
+
+ // first generate the embedded output
+ {
+ detail::disable_counting<OutputIterator> nocounting(sink);
+ r = e.generate(sink, ctx, d, attr);
+ } // re-enable counting
+
+ buffering.disable(); // do not perform buffering any more
+
+ // generate the left padding
+ detail::enable_counting<OutputIterator> counting(sink, buffering.buffer_size());
+ while(r && counting.count() < width)
+ r = p.generate(sink, ctx, unused, unused);
+
+ // copy the buffered output to the target output iterator
+ if (r)
+ buffering.buffer_copy();
+ return r;
         }
- };
+ }
 
     ///////////////////////////////////////////////////////////////////////////
- // The right alignment with width directive, is used for generators
- // like right_align(width)[...]. It uses a default value for the padding
+ // The simple left alignment directive is used for right_align[...]
+ // generators. It uses default values for the generated width (defined via
+ // the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant) and for the padding
     // generator (always spaces).
     ///////////////////////////////////////////////////////////////////////////
- struct width_right_aligment
+ template <typename Subject, typename Width = detail::default_width>
+ struct simple_right_alignment
+ : unary_generator<simple_right_alignment<Subject, Width> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+
+ typedef mpl::int_<
+ generator_properties::countingbuffer | subject_type::properties::value
+ > properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
- {
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ simple_right_alignment(Subject const& subject, Width width = Width())
+ : subject(subject), width(width) {}
+
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
         {
- return detail::right_align_generate(sink, ctx, d, param,
- subject(component), proto::child_c<0>(argument1(component)), ' ');
+ return detail::right_align_generate(sink, ctx, d, attr,
+ subject, width, compile<karma::domain>(' '));
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "right_align(";
-
- result += boost::lexical_cast<std::string>(
- proto::child_c<0>(argument1(component)));
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ return info("right_align", subject.what(context));
         }
+
+ Subject subject;
+ Width width;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- // The right alignment directive with padding, is used for generators like
+ // The left alignment directive with padding, is used for generators like
     // right_align(padding)[...], where padding is a arbitrary generator
     // expression. It uses a default value for the generated width (defined
     // via the BOOST_KARMA_DEFAULT_FIELD_LENGTH constant).
     ///////////////////////////////////////////////////////////////////////////
- struct padding_right_aligment
+ template <typename Subject, typename Padding
+ , typename Width = detail::default_width>
+ struct padding_right_alignment
+ : unary_generator<padding_right_alignment<Subject, Padding, Width> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+ typedef Padding padding_type;
+
+ typedef mpl::int_<
+ generator_properties::countingbuffer |
+ subject_type::properties::value | padding_type::properties::value
+ > properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
- {
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ padding_right_alignment(Subject const& subject, Padding const& padding
+ , Width width = Width())
+ : subject(subject), padding(padding), width(width) {}
+
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
         {
- return detail::right_align_generate(sink, ctx, d, param,
- subject(component), BOOST_KARMA_DEFAULT_FIELD_LENGTH,
- argument1(component));
+ return detail::right_align_generate(sink, ctx, d, attr,
+ subject, width, padding);
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "right_align(";
-
- typedef typename
- spirit::result_of::argument1<Component>::type::director
- padding;
-
- result += padding::what(spirit::argument1(component), ctx);
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ return info("right_align", subject.what(context));
         }
+
+ Subject subject;
+ Padding padding;
+ Width width;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- // The full right alignment directive, is used for generators like
- // right_align(width, padding)[...], where width is a integer value to be
- // used as the field width and padding is a arbitrary generator
- // expression.
+ // Generator generators: make_xxx function (objects)
     ///////////////////////////////////////////////////////////////////////////
- struct full_right_aligment
+
+ // creates right_align[] directive generator
+ template <typename Subject, typename Modifiers>
+ struct make_directive<tag::right_align, Subject, Modifiers>
     {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::subject<Component>::type,
- Context
- >
+ typedef simple_right_alignment<Subject> result_type;
+ result_type operator()(unused_type, Subject const& subject
+ , unused_type) const
         {
- };
+ return result_type(subject);
+ }
+ };
+
+ // creates right_align(width)[] directive generator
+ template <typename Width, typename Subject, typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::right_align, fusion::vector1<Width> >
+ , Subject, Modifiers
+ , typename enable_if_c< integer_traits<Width>::is_integral >::type>
+ {
+ typedef simple_right_alignment<Subject, Width> result_type;
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , unused_type) const
         {
- return detail::right_align_generate(sink, ctx, d, param,
- subject(component), proto::child_c<0>(argument1(component)),
- argument2(component));
+ return result_type(subject, fusion::at_c<0>(term.args));
         }
+ };
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ // creates right_align(pad)[] directive generator
+ template <typename Padding, typename Subject, typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::right_align, fusion::vector1<Padding> >
+ , Subject, Modifiers
+ , typename enable_if<
+ mpl::and_<
+ spirit::traits::matches<karma::domain, Padding>,
+ mpl::not_<mpl::bool_<integer_traits<Padding>::is_integral> >
+ >
+ >::type>
+ {
+ typedef typename
+ result_of::compile<karma::domain, Padding, Modifiers>::type
+ padding_type;
+
+ typedef padding_right_alignment<Subject, padding_type> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , Modifiers const& modifiers) const
         {
- std::string result = "right_align(";
-
- result += boost::lexical_cast<std::string>(
- proto::child_c<0>(argument1(component)));
- result += ", ";
-
- typedef typename
- spirit::result_of::argument2<Component>::type::director
- padding;
-
- result += padding::what(spirit::argument2(component), ctx);
- result += ")[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
+ return result_type(subject
+ , compile<karma::domain>(fusion::at_c<0>(term.args), modifiers));
+ }
+ };
 
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ // creates right_align(pad, width)[] directive generator
+ template <typename Width, typename Padding, typename Subject
+ , typename Modifiers>
+ struct make_directive<
+ terminal_ex<tag::right_align, fusion::vector2<Width, Padding> >
+ , Subject, Modifiers>
+ {
+ typedef typename
+ result_of::compile<karma::domain, Padding, Modifiers>::type
+ padding_type;
+
+ typedef padding_right_alignment<Subject, padding_type, Width> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, Subject const& subject
+ , Modifiers const& modifiers) const
+ {
+ return result_type(subject
+ , compile<karma::domain>(fusion::at_c<1>(term.args), modifiers)
+ , fusion::at_c<0>(term.args));
         }
     };
 

Modified: branches/release/boost/spirit/home/karma/directive/verbatim.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/verbatim.hpp (original)
+++ branches/release/boost/spirit/home/karma/directive/verbatim.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,67 +6,87 @@
 #if !defined(BOOST_SPIRIT_KARMA_VERBATIM_MAR_02_2007_0303PM)
 #define BOOST_SPIRIT_KARMA_VERBATIM_MAR_02_2007_0303PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/fusion/include/at.hpp>
-#include <boost/fusion/include/value_at.hpp>
+#include <boost/spirit/home/karma/detail/unused_delimiter.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/support/info.hpp>
+
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_directive<karma::domain, tag::verbatim> // enables verbatim[]
+ : mpl::true_ {};
+
+}}
 
 namespace boost { namespace spirit { namespace karma
 {
+ using spirit::verbatim;
+ using spirit::verbatim_type;
+
     ///////////////////////////////////////////////////////////////////////////
     // The verbatim generator is used for verbatim[...] directives.
     ///////////////////////////////////////////////////////////////////////////
- struct verbatim
+ template <typename Subject>
+ struct verbatim_generator : unary_generator<verbatim_generator<Subject> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef Subject subject_type;
+ typedef typename subject_type::properties properties;
+
+ template <typename Context, typename Iterator>
         struct attribute
- : traits::attribute_of<
- karma::domain,
- typename result_of::right<Component>::type,
- Context
- >
- {
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ verbatim_generator(Subject const& subject)
+ : subject(subject) {}
+
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
         {
             // the verbatim generator simply dispatches to the embedded
- // generator while supplying unused as the new delimiter
+ // generator while supplying unused_delimiter as the new delimiter
             // to avoid delimiting down the generator stream
- typedef typename
- spirit::result_of::right<Component>::type::director
- director;
-
- if (director::generate(spirit::right(component), sink, ctx,
- unused, param))
- {
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
- return false;
+ typedef detail::unused_delimiter<Delimiter> unused_delimiter;
+
+ return subject.generate(sink, ctx, unused_delimiter(d), attr) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "verbatim[";
+ return info("verbatim", subject.what(context));
+ }
+
+ Subject subject;
+ };
 
- typedef typename
- spirit::result_of::right<Component>::type::director
- director;
-
- result += director::what(spirit::right(component), ctx);
- result += "]";
- return result;
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Subject, typename Modifiers>
+ struct make_directive<tag::verbatim, Subject, Modifiers>
+ {
+ typedef verbatim_generator<Subject> result_type;
+ result_type operator()(unused_type, Subject const& subject, unused_type) const
+ {
+ return result_type(subject);
         }
     };
 

Modified: branches/release/boost/spirit/home/karma/domain.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/domain.hpp (original)
+++ branches/release/boost/spirit/home/karma/domain.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,5 +1,5 @@
-// Copyright (c) 2001-2007 Joel de Guzman
 // Copyright (c) 2001-2009 Hartmut Kaiser
+// Copyright (c) 2001-2009 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)
@@ -7,15 +7,51 @@
 #if !defined(BOOST_SPIRIT_KARMA_DOMAIN_FEB_20_2007_0943AM)
 #define BOOST_SPIRIT_KARMA_DOMAIN_FEB_20_2007_0943AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/meta_compiler.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/argument.hpp>
+#include <boost/spirit/home/support/context.hpp>
+
+#include <boost/preprocessor/repeat.hpp>
+#include <boost/preprocessor/cat.hpp>
+
 namespace boost { namespace spirit { namespace karma
 {
- struct domain
- {};
-
+ // karma's domain
+ struct domain {};
+
+ // bring in some of spirit parts into spirit::karma
+ using spirit::unused;
+ using spirit::unused_type;
+ using spirit::compile;
+ using spirit::info;
+
+ // You can bring these in with the using directive
+ // without worrying about bringing in too much.
+ namespace labels
+ {
+ BOOST_PP_REPEAT(SPIRIT_ARGUMENTS_LIMIT, SPIRIT_USING_ARGUMENT, _)
+ BOOST_PP_REPEAT(SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_USING_ATTRIBUTE, _)
+
+ using spirit::_pass;
+ using spirit::_val;
+ using spirit::_a;
+ using spirit::_b;
+ using spirit::_c;
+ using spirit::_d;
+ using spirit::_e;
+ using spirit::_f;
+ using spirit::_g;
+ using spirit::_h;
+ using spirit::_i;
+ using spirit::_j;
+ }
+
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/karma/generate.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/generate.hpp (original)
+++ branches/release/boost/spirit/home/karma/generate.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,262 +1,227 @@
 // Copyright (c) 2001-2009 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_KARMA_GENERATE_FEB_20_2007_0959AM)
 #define BOOST_SPIRIT_KARMA_GENERATE_FEB_20_2007_0959AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/karma/meta_grammar.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
 #include <boost/spirit/home/karma/detail/output_iterator.hpp>
 #include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/detail/scoped_enum_emulation.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/mpl/bool.hpp>
 
-///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
     ///////////////////////////////////////////////////////////////////////////
+ BOOST_SCOPED_ENUM_START(delimit_flag)
+ {
+ predelimit, // force predelimiting in generate_delimited()
+ dont_predelimit // inhibit predelimiting in generate_delimited()
+ };
+ BOOST_SCOPED_ENUM_END
+
+ ///////////////////////////////////////////////////////////////////////////
     template <typename OutputIterator, typename Expr>
     inline bool
- generate(OutputIterator target_sink, Expr const& xpr)
- {
- typedef spirit::traits::is_component<karma::domain, Expr> is_component;
-
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (OutputIterator, Expr));
+ generate(
+ OutputIterator& target_sink
+ , Expr const& expr)
+ {
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+
+ typedef traits::properties_of<
+ typename result_of::compile<karma::domain, Expr>::type
+ > properties;
 
         // wrap user supplied iterator into our own output iterator
- detail::output_iterator<OutputIterator> sink(target_sink);
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
-
- component c = spirit::as_component(karma::domain(), xpr);
- return director::generate(c, sink, unused, unused, unused);
+ detail::output_iterator<OutputIterator
+ , mpl::int_<properties::value> > sink(target_sink);
+ return compile<karma::domain>(expr).generate(sink, unused, unused, unused);
     }
 
- ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Expr>
+ template <typename OutputIterator, typename Properties, typename Expr>
     inline bool
- generate(detail::output_iterator<OutputIterator>& sink, Expr const& xpr)
+ generate(
+ detail::output_iterator<OutputIterator, Properties>& sink
+ , Expr const& expr)
     {
- typedef spirit::traits::is_component<karma::domain, Expr> is_component;
-
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (OutputIterator, Expr));
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
-
- component c = spirit::as_component(karma::domain(), xpr);
- return director::generate(c, sink, unused, unused, unused);
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ return compile<karma::domain>(expr).generate(sink, unused, unused, unused);
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Expr, typename Parameter>
+ template <typename OutputIterator, typename Expr, typename Attr>
     inline bool
- generate(OutputIterator target_sink, Expr const& xpr, Parameter const& param)
+ generate(
+ OutputIterator& target_sink
+ , Expr const& expr
+ , Attr const& attr)
     {
- typedef spirit::traits::is_component<karma::domain, Expr> is_component;
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
 
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Parameter));
+ typedef traits::properties_of<
+ typename result_of::compile<karma::domain, Expr>::type
+ > properties;
 
         // wrap user supplied iterator into our own output iterator
- detail::output_iterator<OutputIterator> sink(target_sink);
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
-
- component c = spirit::as_component(karma::domain(), xpr);
- return director::generate(c, sink, unused, unused, param);
+ detail::output_iterator<OutputIterator
+ , mpl::int_<properties::value> > sink(target_sink);
+ return compile<karma::domain>(expr).generate(sink, unused, unused, attr);
+ }
+
+ template <typename OutputIterator, typename Properties, typename Expr
+ , typename Attr>
+ inline bool
+ generate(
+ detail::output_iterator<OutputIterator, Properties>& sink
+ , Expr const& expr
+ , Attr const& attr)
+ {
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ return compile<karma::domain>(expr).generate(sink, unused, unused, attr);
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Expr, typename Parameter>
- inline bool
- generate(detail::output_iterator<OutputIterator>& sink, Expr const& xpr,
- Parameter const& param)
- {
- typedef spirit::traits::is_component<karma::domain, Expr> is_component;
-
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Parameter));
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
+ template <typename OutputIterator, typename Properties, typename Expr
+ , typename Delimiter>
+ inline bool
+ generate_delimited(
+ detail::output_iterator<OutputIterator, Properties>& sink
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit =
+ delimit_flag::dont_predelimit)
+ {
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then either the expression (expr) or skipper is not a valid
+ // spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
+
+ typename result_of::compile<karma::domain, Delimiter>::type const
+ delimiter_ = compile<karma::domain>(delimiter);
+
+ if (pre_delimit == delimit_flag::predelimit &&
+ !karma::delimit_out(sink, delimiter_))
+ {
+ return false;
+ }
 
- component c = spirit::as_component(karma::domain(), xpr);
- return director::generate(c, sink, unused, unused, param);
+ return compile<karma::domain>(expr).
+ generate(sink, unused, delimiter_, unused);
     }
 
- ///////////////////////////////////////////////////////////////////////////
     template <typename OutputIterator, typename Expr, typename Delimiter>
     inline bool
- generate_delimited(OutputIterator target_sink, Expr const& xpr,
- Delimiter const& delimiter)
- {
- typedef
- spirit::traits::is_component<karma::domain, Expr>
- expr_is_component;
- typedef
- spirit::traits::is_component<karma::domain, Delimiter>
- delimiter_is_component;
-
- // report invalid expression errors as early as possible
- BOOST_MPL_ASSERT_MSG(expr_is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Delimiter));
-
- BOOST_MPL_ASSERT_MSG(delimiter_is_component::value,
- delimiter_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Delimiter));
-
+ generate_delimited(
+ OutputIterator& target_sink
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit =
+ delimit_flag::dont_predelimit)
+ {
+ typedef traits::properties_of<
+ typename result_of::compile<karma::domain, Expr>::type
+ > properties;
+ typedef traits::properties_of<
+ typename result_of::compile<karma::domain, Delimiter>::type
+ > delimiter_properties;
+
         // wrap user supplied iterator into our own output iterator
- detail::output_iterator<OutputIterator> sink(target_sink);
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
- typedef
- typename result_of::as_component<karma::domain, Delimiter>::type
- delim_component;
-
- component c = spirit::as_component(karma::domain(), xpr);
- delim_component d = spirit::as_component(karma::domain(), delimiter);
- return director::generate(c, sink, unused, d, unused);
+ detail::output_iterator<OutputIterator
+ , mpl::int_<properties::value | delimiter_properties::value>
+ > sink(target_sink);
+ return generate_delimited(sink, expr, delimiter, pre_delimit);
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Expr, typename Delimiter>
- inline bool
- generate_delimited(detail::output_iterator<OutputIterator>& sink,
- Expr const& xpr, Delimiter const& delimiter)
- {
- typedef
- spirit::traits::is_component<karma::domain, Expr>
- expr_is_component;
- typedef
- spirit::traits::is_component<karma::domain, Delimiter>
- delimiter_is_component;
-
- // report invalid expression errors as early as possible
- BOOST_MPL_ASSERT_MSG(expr_is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Delimiter));
-
- BOOST_MPL_ASSERT_MSG(delimiter_is_component::value,
- delimiter_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Delimiter));
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
- typedef
- typename result_of::as_component<karma::domain, Delimiter>::type
- delim_component;
-
- component c = spirit::as_component(karma::domain(), xpr);
- delim_component d = spirit::as_component(karma::domain(), delimiter);
- return director::generate(c, sink, unused, d, unused);
+ template <typename OutputIterator, typename Properties, typename Expr
+ , typename Delimiter, typename Attribute>
+ inline bool
+ generate_delimited(
+ detail::output_iterator<OutputIterator, Properties>& sink
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
+ , Attribute const& attr)
+ {
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then either the expression (expr) or skipper is not a valid
+ // spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
+
+ typename result_of::compile<karma::domain, Delimiter>::type const
+ delimiter_ = compile<karma::domain>(delimiter);
+
+ if (pre_delimit == delimit_flag::predelimit &&
+ !karma::delimit_out(sink, delimiter_))
+ {
+ return false;
+ }
+
+ return compile<karma::domain>(expr).
+ generate(sink, unused, delimiter_, attr);
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Expr, typename Parameter,
- typename Delimiter>
- inline bool
- generate_delimited(OutputIterator target_sink, Expr const& xpr,
- Parameter const& param, Delimiter const& delimiter)
- {
- typedef
- spirit::traits::is_component<karma::domain, Expr>
- expr_is_component;
- typedef
- spirit::traits::is_component<karma::domain, Delimiter>
- delimiter_is_component;
-
- // report invalid expression errors as early as possible
- BOOST_MPL_ASSERT_MSG(expr_is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Parameter, Delimiter));
-
- BOOST_MPL_ASSERT_MSG(delimiter_is_component::value,
- delimiter_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Parameter, Delimiter));
-
- // wrap user supplied iterator into our own output iterator
- detail::output_iterator<OutputIterator> sink(target_sink);
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
- typedef
- typename result_of::as_component<karma::domain, Delimiter>::type
- delim_component;
-
- component c = spirit::as_component(karma::domain(), xpr);
- delim_component d = spirit::as_component(karma::domain(), delimiter);
- return director::generate(c, sink, unused, d, param);
- }
+ template <typename OutputIterator, typename Expr, typename Delimiter
+ , typename Attribute>
+ inline bool
+ generate_delimited(
+ OutputIterator& target_sink
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
+ , Attribute const& attr)
+ {
+ typedef traits::properties_of<
+ typename result_of::compile<karma::domain, Expr>::type
+ > properties;
+ typedef traits::properties_of<
+ typename result_of::compile<karma::domain, Delimiter>::type
+ > delimiter_properties;
 
- ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Expr, typename Parameter,
- typename Delimiter>
- inline bool
- generate_delimited(detail::output_iterator<OutputIterator>& sink,
- Expr const& xpr, Parameter const& param, Delimiter const& delimiter)
+ // wrap user supplied iterator into our own output iterator
+ detail::output_iterator<OutputIterator
+ , mpl::int_<properties::value | delimiter_properties::value>
+ > sink(target_sink);
+ return generate_delimited(sink, expr, delimiter, pre_delimit, attr);
+ }
+
+ template <typename OutputIterator, typename Expr, typename Attribute
+ , typename Delimiter>
+ inline bool
+ generate_delimited(
+ OutputIterator& sink
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , Attribute const& attr)
     {
- typedef
- spirit::traits::is_component<karma::domain, Expr>
- expr_is_component;
- typedef
- spirit::traits::is_component<karma::domain, Delimiter>
- delimiter_is_component;
-
- // report invalid expression errors as early as possible
- BOOST_MPL_ASSERT_MSG(expr_is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Parameter, Delimiter));
-
- BOOST_MPL_ASSERT_MSG(delimiter_is_component::value,
- delimiter_is_not_convertible_to_a_generator,
- (OutputIterator, Expr, Parameter, Delimiter));
-
- typedef
- typename result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
- typedef
- typename result_of::as_component<karma::domain, Delimiter>::type
- delim_component;
-
- component c = spirit::as_component(karma::domain(), xpr);
- delim_component d = spirit::as_component(karma::domain(), delimiter);
- return director::generate(c, sink, unused, d, param);
+ return generate_delimited(sink, expr, delimiter
+ , delimit_flag::dont_predelimit, attr);
     }
 
 }}}

Deleted: branches/release/boost/spirit/home/karma/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,53 +0,0 @@
-// Copyright (c) 2001-2007 Joel de Guzman
-// Copyright (c) 2001-2009 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_KARMA_META_GRAMMAR_FEB_20_2007_0939AM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_FEB_20_2007_0939AM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/meta_grammar/grammar.hpp>
-#include <boost/spirit/home/support/meta_grammar/basic_transforms.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/placeholders.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- // Check if Expr is a valid Karma expression
- template <typename Expr, typename Enable = void>
- struct is_valid_expr : mpl::false_ {};
-
- // Return a suitable transform for the given Expr
- template <typename Expr, typename Enable = void>
- struct expr_transform;
-
- struct main_meta_grammar
- : meta_grammar::if_transform<
- is_valid_expr<proto::_>(),
- expr_transform<proto::_>
- >
- {
- };
-
-}}}
-
-namespace boost { namespace spirit { namespace meta_grammar
-{
- ///////////////////////////////////////////////////////////////////////////
- // The spirit karma domain meta-grammar
- ///////////////////////////////////////////////////////////////////////////
- template <>
- struct grammar<karma::domain>
- {
- typedef karma::main_meta_grammar type;
- };
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/nonterminal.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal.hpp (original)
+++ branches/release/boost/spirit/home/karma/nonterminal.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,12 +6,11 @@
 #if !defined(BOOST_SPIRIT_KARMA_NONTERMINAL_MAR_05_2007_0539PM)
 #define BOOST_SPIRIT_KARMA_NONTERMINAL_MAR_05_2007_0539PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/nonterminal/rule.hpp>
 #include <boost/spirit/home/karma/nonterminal/grammar.hpp>
-#include <boost/spirit/home/karma/nonterminal/meta_grammar.hpp>
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/nonterminal/detail/rule.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/detail/rule.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,174 +0,0 @@
-// Copyright (c) 2001-2007 Joel de Guzman
-// Copyright (c) 2001-2009 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_KARMA_RULE_MAR_05_2007_0519PM)
-#define BOOST_SPIRIT_KARMA_RULE_MAR_05_2007_0519PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/intrusive_ptr.hpp>
-#include <boost/detail/atomic_count.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/identity.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/not.hpp>
-#include <boost/mpl/and.hpp>
-#include <boost/mpl/equal_to.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/add_const.hpp>
-#include <boost/type_traits/remove_reference.hpp>
-#include <boost/function_types/is_function.hpp>
-#include <boost/assert.hpp>
-#include <boost/fusion/include/pop_front.hpp>
-#include <boost/fusion/include/is_sequence.hpp>
-
-namespace boost { namespace spirit { namespace karma { namespace detail
-{
- struct no_delimiter
- {
- // this struct accepts only unused types and
- // nothing else. This is used by the second
- // pure virtual parse member function of
- // virtual_component_base below.
-
- no_delimiter(unused_type) {}
- };
-
- template <typename OutputIterator, typename Context, typename Delimiter>
- struct virtual_component_base
- {
- struct take_no_delimiter {};
-
- typedef typename
- mpl::eval_if<
- is_same<Delimiter, unused_type>,
- mpl::identity<take_no_delimiter>,
- result_of::as_component<karma::domain, Delimiter>
- >::type
- delimiter_type;
-
- virtual_component_base()
- : use_count(0)
- {
- }
-
- virtual ~virtual_component_base()
- {
- }
-
- virtual bool
- generate(OutputIterator& sink, Context& context,
- delimiter_type const& delim) = 0;
-
- virtual bool
- generate(OutputIterator& sink, Context& context, no_delimiter) = 0;
-
- boost::detail::atomic_count use_count;
- };
-
- template <typename OutputIterator, typename Context, typename Delimiter>
- inline void
- intrusive_ptr_add_ref(
- virtual_component_base<OutputIterator, Context, Delimiter>* p)
- {
- ++p->use_count;
- }
-
- template <typename OutputIterator, typename Context, typename Delimiter>
- inline void
- intrusive_ptr_release(
- virtual_component_base<OutputIterator, Context, Delimiter>* p)
- {
- if (--p->use_count == 0)
- delete p;
- }
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Component, typename Context,
- typename Delimiter, typename Auto>
- struct virtual_component
- : virtual_component_base<OutputIterator, Context, Delimiter>
- {
- typedef
- virtual_component_base<OutputIterator, Context, Delimiter>
- base_type;
- typedef typename base_type::delimiter_type delimiter_type;
- typedef typename base_type::take_no_delimiter take_no_delimiter;
-
- virtual_component(Component const& component)
- : component(component)
- {
- }
-
- virtual ~virtual_component()
- {
- }
-
- template <typename Delimiter_>
- bool generate_main(OutputIterator& sink, Context& context,
- Delimiter_ const& delim, mpl::false_)
- {
- // If Auto is false, we synthesize a new (default constructed)
- // attribute instance based on the attributes of the embedded
- // generator.
- typename traits::attribute_of<
- karma::domain, Component, Context
- >::type param;
-
- typedef typename Component::director director;
- return director::generate(component, sink, context, delim, param);
- }
-
- template <typename Delimiter_>
- bool generate_main(OutputIterator& sink, Context& context,
- Delimiter_ const& delim, mpl::true_)
- {
- // If Auto is true, we pass the rule's attribute on to the
- // component.
- typedef typename Component::director director;
- return director::generate(component, sink, context, delim,
- fusion::at_c<0>(fusion::at_c<0>(context)));
- }
-
- bool
- generate_main(OutputIterator&, Context&, take_no_delimiter, mpl::false_)
- {
- BOOST_ASSERT(false); // this should never be called
- return false;
- }
-
- bool
- generate_main(OutputIterator&, Context&, take_no_delimiter, mpl::true_)
- {
- BOOST_ASSERT(false); // this should never be called
- return false;
- }
-
- virtual bool
- generate(OutputIterator& sink, Context& context,
- delimiter_type const& delim)
- {
- return generate_main(sink, context, delim, Auto());
- }
-
- virtual bool
- generate(OutputIterator& sink, Context& context, no_delimiter)
- {
- return generate_main(sink, context, unused, Auto());
- }
-
- Component component;
- };
-
-}}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/nonterminal/grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/grammar.hpp (original)
+++ branches/release/boost/spirit/home/karma/nonterminal/grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 Joel de Guzman
 // Copyright (c) 2001-2009 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -7,34 +7,55 @@
 #if !defined(BOOST_SPIRIT_KARMA_GRAMMAR_MAR_05_2007_0542PM)
 #define BOOST_SPIRIT_KARMA_GRAMMAR_MAR_05_2007_0542PM
 
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
 #include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/karma/nonterminal/nonterminal.hpp>
-#include <boost/spirit/home/karma/nonterminal/grammar_fwd.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
 #include <boost/spirit/home/karma/nonterminal/rule.hpp>
-#include <boost/spirit/home/karma/nonterminal/nonterminal_director.hpp>
-#include <boost/function_types/is_function.hpp>
+#include <boost/spirit/home/karma/reference.hpp>
 #include <boost/noncopyable.hpp>
 
 namespace boost { namespace spirit { namespace karma
 {
- template <typename Iterator, typename T0 , typename T1 , typename T2>
+ template <
+ typename OutputIterator
+ , typename T1 = unused_type
+ , typename T2 = unused_type
+ , typename T3 = unused_type
+ >
     struct grammar
- : nonterminal<
- grammar<Iterator, T0, T1, T2>,
- typename karma::rule<Iterator, T0, T1, T2>::sig_type,
- typename karma::rule<Iterator, T0, T1, T2>::locals_type
- >, noncopyable
+ : proto::extends<
+ typename proto::terminal<
+ reference<rule<OutputIterator, T1, T2, T3> const>
+ >::type
+ , grammar<OutputIterator, T1, T2, T3>
+ >
+ , generator<grammar<OutputIterator, T1, T2, T3> >
+ , noncopyable
     {
- typedef Iterator iterator_type;
- typedef karma::rule<Iterator, T0, T1, T2> start_type;
+ typedef OutputIterator iterator_type;
+ typedef rule<OutputIterator, T1, T2, T3> start_type;
+ typedef typename start_type::properties properties;
         typedef typename start_type::sig_type sig_type;
         typedef typename start_type::locals_type locals_type;
         typedef typename start_type::delimiter_type delimiter_type;
- typedef grammar<Iterator, T0, T1, T2> base_type;
-
- grammar(start_type const& start, std::string const& name_ = std::string())
- : start_(start), name_(name_)
+ typedef grammar<OutputIterator, T1, T2, T3> base_type;
+ typedef reference<start_type const> reference_;
+ typedef typename proto::terminal<reference_>::type terminal;
+
+ static size_t const params_size = start_type::params_size;
+
+ // the output iterator is always wrapped by karma
+ typedef detail::output_iterator<OutputIterator, properties>
+ output_iterator;
+
+ grammar(start_type const& start
+ , std::string const& name_ = "unnamed-grammar")
+ : proto::extends<terminal, base_type>(terminal::make(start.alias()))
+ , name_(name_)
         {}
 
         std::string name() const
@@ -42,35 +63,32 @@
             return name_;
         }
 
- void name(std::string const& name__)
+ void name(std::string const& str)
         {
- name_ = name__;
+ name_ = str;
         }
 
- start_type const& start_;
- std::string name_;
-
- private:
- template <typename OutputIterator, typename Context, typename Delimiter>
- bool generate(OutputIterator& sink, Context& context,
- Delimiter const& delim) const
+ template <typename Context, typename Delimiter, typename Attribute>
+ bool generate(output_iterator& sink, Context& context
+ , Delimiter const& delim, Attribute const& attr) const
         {
- return start_.generate(sink, context, delim);
+ return this->proto_base().child0.generate(
+ sink, context, delim, attr);
         }
 
- std::string what() const
+ template <typename Context>
+ info what(Context& context) const
         {
- if (name().empty())
- {
- return start_.what();
- }
- else
- {
- return name();
- }
+ return info(name_);
         }
 
- friend struct nonterminal_director;
+ // bring in the operator() overloads
+ start_type const& get_parameterized_subject() const
+ { return this->proto_base().child0.ref.get(); }
+ typedef start_type parameterized_subject_type;
+ #include <boost/spirit/home/karma/nonterminal/detail/fcall.hpp>
+
+ std::string name_;
     };
 
 }}}

Deleted: branches/release/boost/spirit/home/karma/nonterminal/grammar_fwd.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/grammar_fwd.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,26 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2008 Joel de Guzman
- Copyright (c) 2001-2008 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_KARMA_GRAMMAR_FWD_JULY_13_2008_0924AM)
-#define BOOST_SPIRIT_KARMA_GRAMMAR_FWD_JULY_13_2008_0924AM
-
-#include <boost/spirit/home/support/unused.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- // forward declaration
- template <
- typename Iterator,
- typename T0 = unused_type,
- typename T1 = unused_type,
- typename T2 = unused_type
- >
- struct grammar;
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/karma/nonterminal/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,72 +0,0 @@
-// Copyright (c) 2001-2009 Hartmut Kaiser
-// Copyright (c) 2001-2007 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_KARMA_META_GRAMMAR_MAR_05_2007_0436PM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_MAR_05_2007_0436PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/nonterminal/nonterminal.hpp>
-#include <boost/spirit/home/karma/nonterminal/nonterminal.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/utility/enable_if.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- struct nonterminal_director;
-
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // nonterminal meta-grammar
- ///////////////////////////////////////////////////////////////////////////
- struct nonterminal_meta_grammar
- : meta_grammar::terminal_rule<
- karma::domain,
- nonterminal_holder<proto::_, proto::_>,
- nonterminal_director
- >
- {
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hook into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<
- Expr,
- typename enable_if<
- proto::matches<Expr, nonterminal_meta_grammar>
- >::type
- >
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<
- Expr,
- typename enable_if<
- proto::matches<Expr, nonterminal_meta_grammar>
- >::type
- >
- : mpl::identity<nonterminal_meta_grammar>
- {
- };
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/karma/nonterminal/nonterminal.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/nonterminal.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,154 +0,0 @@
-// Copyright (c) 2001-2007 Joel de Guzman
-// Copyright (c) 2001-2009 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_KARMA_NONTERMINAL_MAR_06_2007_0750AM)
-#define BOOST_SPIRIT_KARMA_NONTERMINAL_MAR_06_2007_0750AM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/nonterminal/nonterminal.hpp>
-#include <boost/spirit/home/support/nonterminal/locals.hpp>
-#include <boost/spirit/home/support/argument.hpp>
-
-#include <boost/proto/core.hpp>
-#include <boost/function_types/result_type.hpp>
-#include <boost/function_types/parameter_types.hpp>
-#include <boost/function_types/is_function.hpp>
-#include <boost/fusion/include/as_vector.hpp>
-#include <boost/fusion/include/mpl.hpp>
-#include <boost/fusion/include/joint_view.hpp>
-#include <boost/fusion/include/single_view.hpp>
-
-#include <boost/type_traits/add_reference.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/copy_if.hpp>
-#include <boost/mpl/filter_view.hpp>
-#include <boost/mpl/find_if.hpp>
-#include <boost/mpl/not.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/preprocessor/enum_params.hpp>
-#include <boost/preprocessor/enum_params_with_a_default.hpp>
-#include <boost/utility/enable_if.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- template <typename Derived, typename Sig, typename Locals>
- struct nonterminal
- : proto::extends<
- typename make_nonterminal_holder<
- Derived const*, Derived
- >::type,
- Derived
- >
- {
- typedef Sig sig_type;
- typedef typename
- function_types::result_type<sig_type>::type
- result_type_;
-
- // This is the nonterminal return type
- typedef typename
- mpl::if_<
- is_same<result_type_, void>, unused_type, result_type_
- >::type
- attribute_type;
-
- // param_types is a sequence of types passed as parameters to the
- // nonterminal
- typedef typename
- function_types::parameter_types<sig_type>::type
- param_types;
-
- // the parameter tuple has the attribute value pre-pended
- typedef typename
- fusion::result_of::as_vector<
- fusion::joint_view<
- fusion::single_view<attribute_type const&>,
- param_types
- >
- >::type
- retval_param_types;
-
- // locals_type is a sequence of types to be used as local variables
- typedef typename
- fusion::result_of::as_vector<Locals>::type
- locals_type;
-
- // The overall context_type consists of a tuple with:
- // 1) a tuple of the return value and parameters
- // 2) the locals
- typedef fusion::vector<retval_param_types, locals_type> context_type;
-
- typedef nonterminal<Derived, Sig, Locals> self_type;
- typedef nonterminal_holder<Derived const*, Derived> nonterminal_holder_;
- typedef typename proto::terminal<nonterminal_holder_>::type nonterminal_tag;
- typedef proto::extends<nonterminal_tag, Derived> base_type;
-
- explicit nonterminal()
- : base_type(make_tag())
- {
- }
-
- // bring in the operator() overloads
- #include <boost/spirit/home/support/nonterminal/detail/nonterminal_fcall.hpp>
-
- private:
-
- nonterminal_tag make_tag() const
- {
- nonterminal_tag xpr = {{static_cast<Derived const*>(this)}};
- return xpr;
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Derived, typename T0, typename T1, typename T2>
- struct make_nonterminal
- {
- typedef mpl::vector<T0, T1, T2> types;
- typedef function_types::is_function<mpl::_> is_function;
- typedef spirit::detail::is_locals<mpl::_> is_locals;
- typedef spirit::traits::is_component<karma::domain, mpl::_> is_delimiter;
-
- typedef typename mpl::find_if<types, is_function>::type sig_;
- typedef typename mpl::find_if<types, is_locals>::type locals_;
- typedef typename mpl::find_if<types, is_delimiter>::type delimiter_;
-
- typedef typename
- mpl::eval_if<
- is_same<sig_, typename mpl::end<types>::type>,
- mpl::identity<unused_type()>,
- mpl::deref<sig_>
- >::type
- sig_type;
-
- typedef typename
- mpl::eval_if<
- is_same<locals_, typename mpl::end<types>::type>,
- mpl::identity<locals<> >,
- mpl::deref<locals_>
- >::type
- locals_type;
-
- typedef typename
- mpl::eval_if<
- is_same<delimiter_, typename mpl::end<types>::type>,
- mpl::identity<unused_type>,
- mpl::deref<delimiter_>
- >::type
- delimiter_type;
-
- typedef nonterminal<Derived, sig_type, locals_type> type;
- };
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/karma/nonterminal/nonterminal_director.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/nonterminal_director.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,160 +0,0 @@
-// Copyright (c) 2001-2007 Joel de Guzman
-// Copyright (c) 2001-2009 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_KARMA_NONTERMINAL_DIRECTOR_MAR_05_2007_0524PM)
-#define BOOST_SPIRIT_KARMA_NONTERMINAL_DIRECTOR_MAR_05_2007_0524PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/nonterminal/nonterminal.hpp>
-#include <boost/spirit/home/support/nonterminal/detail/expand_arg.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/attribute_transform.hpp>
-#include <boost/spirit/home/support/detail/values.hpp>
-#include <boost/fusion/include/transform.hpp>
-#include <boost/fusion/include/join.hpp>
-#include <boost/fusion/include/single_view.hpp>
-#include <boost/intrusive_ptr.hpp>
-#include <boost/mpl/at.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/remove_const.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- struct nonterminal_director
- {
- // The attribute (parameter) of nonterminals is the type given to them
- // as the return value of the function signature.
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef typename
- result_of::subject<Component>::type
- nonterminal_holder;
- typedef typename
- nonterminal_holder::nonterminal_type::attribute_type
- type;
- };
-
- // the nonterminal_holder holds an actual nonterminal_object
- template <
- typename NonterminalContext, typename Nonterminal,
- typename OutputIterator, typename Context, typename Delimiter,
- typename Parameter>
- static bool generate_nonterminal(
- nonterminal_object<Nonterminal> const& x,
- OutputIterator& sink, Context&, Delimiter const& delim,
- Parameter const& param)
- {
- typedef typename Nonterminal::locals_type locals_type;
- fusion::vector<Parameter const&> front(param);
- NonterminalContext context(front, locals_type());
- return x.obj.generate(sink, context, delim);
- }
-
- // the nonterminal_holder holds a pointer to a nonterminal
- template <
- typename NonterminalContext, typename Nonterminal,
- typename OutputIterator, typename Context, typename Delimiter,
- typename Parameter>
- static bool generate_nonterminal(
- Nonterminal const* ptr,
- OutputIterator& sink, Context&, Delimiter const& delim,
- Parameter const& param)
- {
- typedef typename Nonterminal::locals_type locals_type;
- fusion::vector<Parameter const&> front(param);
- NonterminalContext context(front, locals_type());
- return ptr->generate(sink, context, delim);
- }
-
- // the nonterminal_holder holds a parameterized_nonterminal
- template <
- typename NonterminalContext, typename Nonterminal,
- typename FSequence, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool generate_nonterminal(
- parameterized_nonterminal<Nonterminal, FSequence> const& x,
- OutputIterator& sink, Context& context_, Delimiter const& delim,
- Parameter const& param)
- {
- typedef typename Nonterminal::locals_type locals_type;
- fusion::single_view<Parameter const&> front(param);
- NonterminalContext context(
- fusion::join(
- front,
- fusion::transform(
- x.fseq,
- spirit::detail::expand_arg<Context>(context_)
- )
- ),
- locals_type()
- );
- return x.ptr->generate(sink, context, delim);
- }
-
- ///////////////////////////////////////////////////////////////////////
- // main entry point
- ///////////////////////////////////////////////////////////////////////
- template <
- typename Component, typename OutputIterator, typename Context,
- typename Delimiter, typename Parameter>
- static bool generate(
- Component const& component, OutputIterator& sink,
- Context& context, Delimiter const& delim, Parameter const& param)
- {
- typedef typename
- result_of::subject<Component>::type
- nonterminal_holder;
-
- // The overall context_type consists of a tuple with:
- // 1) a tuple of the attribute and parameters
- // 2) the locals
- // if no signature is specified the first tuple contains
- // the attribute at position zero only.
- typedef typename
- nonterminal_holder::nonterminal_type::context_type
- context_type;
-
- return generate_nonterminal<context_type>(
- subject(component).held, sink, context, delim, param);
- }
-
- template <typename Nonterminal>
- static std::string what_nonterminal(nonterminal_object<Nonterminal> const& x)
- {
- // the nonterminal_holder holds an actual nonterminal_object
- return x.obj.what();
- }
-
- template <typename Nonterminal>
- static std::string what_nonterminal(Nonterminal const* ptr)
- {
- // the nonterminal_holder holds a pointer to a nonterminal
- return ptr->what();
- }
-
- template <typename Nonterminal, typename FSequence>
- static std::string what_nonterminal(
- parameterized_nonterminal<Nonterminal, FSequence> const& x)
- {
- // the nonterminal_holder holds a parameterized_nonterminal
- return x.ptr->what();
- }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- return what_nonterminal(subject(component).held);
- }
- };
-
-}}}
-
-#endif

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,204 +1,301 @@
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 Joel de Guzman
 // Copyright (c) 2001-2009 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_KARMA_RULE_MAR_05_2007_0455PM)
 #define BOOST_SPIRIT_KARMA_RULE_MAR_05_2007_0455PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
+#include <boost/assert.hpp>
+#include <boost/function.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/add_reference.hpp>
+#include <boost/utility/enable_if.hpp>
+
+#include <boost/fusion/include/vector.hpp>
+#include <boost/fusion/include/size.hpp>
+#include <boost/fusion/include/make_vector.hpp>
+#include <boost/fusion/include/cons.hpp>
+#include <boost/fusion/include/as_list.hpp>
+#include <boost/fusion/include/as_vector.hpp>
+
 #include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/karma/nonterminal/nonterminal.hpp>
-#include <boost/spirit/home/karma/nonterminal/grammar_fwd.hpp>
-#include <boost/spirit/home/karma/nonterminal/detail/rule.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/support/argument.hpp>
+#include <boost/spirit/home/support/context.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
+#include <boost/spirit/home/support/nonterminal/extract_param.hpp>
+#include <boost/spirit/home/support/nonterminal/locals.hpp>
+#include <boost/spirit/home/karma/reference.hpp>
 #include <boost/spirit/home/karma/detail/output_iterator.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/assert.hpp>
-
-#if defined(BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4355) // 'this' : used in base member initializer list warning
-#endif
+#include <boost/spirit/home/karma/nonterminal/detail/generator_binder.hpp>
+#include <boost/spirit/home/karma/nonterminal/detail/parameterized.hpp>
 
 namespace boost { namespace spirit { namespace karma
 {
- template <typename OutputIterator, typename T0 = unused_type,
- typename T1 = unused_type, typename T2 = unused_type>
+ BOOST_PP_REPEAT(SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_USING_ATTRIBUTE, _)
+
+ using spirit::_pass;
+ using spirit::_val;
+ using spirit::_a;
+ using spirit::_b;
+ using spirit::_c;
+ using spirit::_d;
+ using spirit::_e;
+ using spirit::_f;
+ using spirit::_g;
+ using spirit::_h;
+ using spirit::_i;
+ using spirit::_j;
+
+ using spirit::info;
+ using spirit::locals;
+
+ template <
+ typename OutputIterator
+ , typename T1 = unused_type
+ , typename T2 = unused_type
+ , typename T3 = unused_type
+ >
     struct rule
- : make_nonterminal<rule<OutputIterator, T0, T1, T2>, T0, T1, T2>::type
+ : proto::extends<
+ typename proto::terminal<
+ reference<rule<OutputIterator, T1, T2, T3> const>
+ >::type
+ , rule<OutputIterator, T1, T2, T3>
+ >
+ , generator<rule<OutputIterator, T1, T2, T3> >
     {
- typedef
- make_nonterminal<rule<OutputIterator, T0, T1, T2>, T0, T1, T2>
- make_nonterminal_;
-
- typedef typename make_nonterminal_::delimiter_type delimiter_type;
- typedef typename make_nonterminal_::type base_type;
- typedef detail::output_iterator<OutputIterator> iterator_type;
- typedef rule<OutputIterator, T0, T1, T2> self_type;
-
- typedef
- detail::virtual_component_base<
- iterator_type,
- typename base_type::context_type,
- delimiter_type
- >
- virtual_component;
-
- typedef intrusive_ptr<virtual_component> pointer_type;
+ typedef mpl::int_<generator_properties::all_properties> properties;
 
- rule() {}
- ~rule() {}
+ typedef OutputIterator iterator_type;
+ typedef rule<OutputIterator, T1, T2, T3> this_type;
+ typedef reference<this_type const> reference_;
+ typedef typename proto::terminal<reference_>::type terminal;
+ typedef proto::extends<terminal, this_type> base_type;
+ typedef mpl::vector<T1, T2, T3> template_params;
+
+ // the output iterator is always wrapped by karma
+ typedef detail::output_iterator<OutputIterator, properties>
+ output_iterator;
+
+ // locals_type is a sequence of types to be used as local variables
+ typedef typename
+ spirit::detail::extract_locals<template_params>::type
+ locals_type;
+
+ // The delimiter-generator type
+ typedef typename
+ spirit::detail::extract_component<
+ karma::domain, template_params>::type
+ delimiter_type;
+
+ typedef typename
+ spirit::detail::extract_sig<template_params>::type
+ sig_type;
+
+ // This is the rule's attribute type
+ typedef typename
+ spirit::detail::attr_from_sig<sig_type>::type
+ attr_type;
+ typedef typename add_reference<
+ typename add_const<attr_type>::type>::type
+ attr_reference_type;
+
+ // parameter_types is a sequence of types passed as parameters to the rule
+ typedef typename
+ spirit::detail::params_from_sig<sig_type>::type
+ parameter_types;
+
+ static size_t const params_size =
+ fusion::result_of::size<parameter_types>::type::value;
+
+ // the context passed to the right hand side of a rule contains
+ // the attribute and the parameters for this particular rule invocation
+ typedef context<
+ fusion::cons<attr_reference_type, parameter_types>
+ , locals_type>
+ context_type;
+
+ typedef function<
+ bool(output_iterator&, context_type&, delimiter_type const&)>
+ function_type;
+
+ explicit rule(std::string const& name_ = "unnamed-rule")
+ : base_type(terminal::make(alias()))
+ , name_(name_)
+ {
+ }
 
         rule(rule const& rhs)
- : ptr(rhs.ptr)
+ : base_type(rhs)
+ , name_(rhs.name_)
+ , f(rhs.f)
         {
         }
 
+ template <typename Expr>
+ rule (Expr const& expr, std::string const& name_ = "unnamed-rule")
+ : base_type(terminal::make(alias()))
+ , name_(name_)
+ {
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here, then
+ // the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+
+ f = detail::bind_generator<mpl::true_>(compile<karma::domain>(expr));
+ }
+
         rule& operator=(rule const& rhs)
         {
- ptr = rhs.ptr;
+ // The following assertion fires when you try to initialize a rule
+ // from an uninitialized one. Did you mean to refer to the right
+ // hand side rule instead of assigning from it? In this case you
+ // should write lhs = rhs.alias();
+ BOOST_ASSERT(rhs.f);
+
+ f = rhs.f;
+ name_ = rhs.name_;
             return *this;
         }
 
- template <typename Expr>
- rule& operator=(Expr const& xpr)
+ std::string const& name() const
         {
- typedef
- spirit::traits::is_component<karma::domain, Expr>
- is_component;
+ return name_;
+ }
 
- // report invalid expression error as early as possible
-// BOOST_MPL_ASSERT_MSG(
-// is_component::value,
-// xpr_is_not_convertible_to_a_generator, ());
+ void name(std::string const& str)
+ {
+ name_ = str;
+ }
 
- // temp workaround for mpl problem
- BOOST_STATIC_ASSERT(is_component::value);
+ template <typename Expr>
+ rule& operator=(Expr const& expr)
+ {
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here, then
+ // the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
 
- define(xpr, mpl::false_());
+ f = detail::bind_generator<mpl::false_>(compile<karma::domain>(expr));
             return *this;
         }
 
+ // g++ 3.3 barfs if this is a member function :(
         template <typename Expr>
- friend rule& operator%=(rule& r, Expr const& xpr)
+ friend rule& operator%=(rule& r, Expr const& expr)
         {
- typedef
- spirit::traits::is_component<karma::domain, Expr>
- is_component;
-
- // report invalid expression error as early as possible
-// BOOST_MPL_ASSERT_MSG(
-// is_component::value,
-// xpr_is_not_convertible_to_a_generator, ());
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here, then
+ // the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
 
- // temp workaround for mpl problem
- BOOST_STATIC_ASSERT(is_component::value);
-
- r.define(xpr, mpl::true_());
+ r.f = detail::bind_generator<mpl::true_>(compile<karma::domain>(expr));
             return r;
         }
 
- self_type alias() const
+ // non-const version needed to suppress proto's %= kicking in
+ template <typename Expr>
+ friend rule& operator%=(rule& r, Expr& expr)
         {
- self_type result;
- result.define(*this, mpl::false_());
- return result;
+ return r %= static_cast<Expr const&>(expr);
         }
 
- typename
- make_nonterminal_holder<
- nonterminal_object<self_type>
- , self_type
- >::type
- copy() const
+ template <typename Context, typename Unused>
+ struct attribute
         {
- typename
- make_nonterminal_holder<
- nonterminal_object<self_type>
- , self_type
- >::type
- result = {{*this}};
- return result;
- }
+ typedef attr_type type;
+ };
 
- std::string name() const
+ template <typename Context, typename Delimiter, typename Attribute>
+ bool generate(output_iterator& sink, Context&, Delimiter const& delim
+ , Attribute const& attr) const
         {
- return name_;
+ if (f)
+ {
+ // Create an attribute if none is supplied.
+ typedef traits::make_attribute<attr_type, Attribute>
+ make_attribute;
+
+ // 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(make_attribute::call(attr));
+
+ // If you are seeing a compilation error here stating that the
+ // third parameter can't be converted to a karma::reference
+ // then you are probably trying to use a rule or a grammar with
+ // an incompatible delimiter type.
+ if (f(sink, context, delim))
+ {
+ return true;
+ }
+ }
+ return false;
         }
 
- void name(std::string const& str)
+ template <typename Context, typename Delimiter, typename Attribute
+ , typename Params>
+ bool generate(output_iterator& sink, Context& caller_context
+ , Delimiter const& delim, Attribute const& attr
+ , Params const& params) const
         {
- name_ = str;
+ if (f)
+ {
+ // Create an attribute if none is supplied.
+ typedef traits::make_attribute<attr_type, Attribute>
+ make_attribute;
+
+ // 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(make_attribute::call(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
+ // then you are probably trying to use a rule or a grammar with
+ // an incompatible delimiter type.
+ if (f(sink, context, delim))
+ {
+ return true;
+ }
+ }
+ return false;
         }
 
- private:
-
- template <typename Iterator_, typename T0_, typename T1_, typename T2_>
- friend struct grammar;
+ template <typename Context>
+ info what(Context& context) const
+ {
+ return info(name_);
+ }
 
- template <typename Expr, typename Auto>
- void define(Expr const& xpr, Auto)
+ reference_ alias() const
         {
- typedef typename
- result_of::as_component<karma::domain, Expr>::type
- component;
- typedef
- detail::virtual_component<
- iterator_type,
- component,
- typename base_type::context_type,
- delimiter_type,
- Auto
- >
- virtual_component;
- ptr = new virtual_component(spirit::as_component(karma::domain(), xpr));
- }
-
- template <typename OutputIterator_, typename Context, typename Delimiter>
- bool generate(
- OutputIterator_& sink, Context& context, Delimiter const& delim) const
- {
- // If the following line produces a compilation error stating the
- // 3rd parameter is not convertible to the expected type, then you
- // are probably trying to use this rule instance with a delimiter
- // which is not compatible with the delimiter type used while
- // defining the type of this rule instance.
- return ptr->generate(sink, context, delim);
+ return reference_(*this);
         }
 
- std::string what() const
+ typename proto::terminal<this_type>::type copy() const
         {
- if (name_.empty())
- {
- if (ptr)
- {
- return "unnamed-rule";
- }
- else
- {
- return "empty-rule";
- }
- }
- else
- {
- return name_;
- }
+ typename proto::terminal<this_type>::type result = {*this};
+ return result;
         }
 
- friend struct nonterminal_director;
- pointer_type ptr;
+ // bring in the operator() overloads
+ rule const& get_parameterized_subject() const { return *this; }
+ typedef rule parameterized_subject_type;
+ #include <boost/spirit/home/karma/nonterminal/detail/fcall.hpp>
+
         std::string name_;
+ function_type f;
     };
 
 }}}
 
-#if defined(BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
 #endif

Modified: branches/release/boost/spirit/home/karma/numeric.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric.hpp (original)
+++ branches/release/boost/spirit/home/karma/numeric.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,14 +6,12 @@
 #if !defined(BOOST_SPIRIT_KARMA_NUMERIC_FEB_23_2007_0507PM)
 #define BOOST_SPIRIT_KARMA_NUMERIC_FEB_23_2007_0507PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/karma/numeric/numeric_fwd.hpp>
 #include <boost/spirit/home/karma/numeric/int.hpp>
 #include <boost/spirit/home/karma/numeric/uint.hpp>
 #include <boost/spirit/home/karma/numeric/real.hpp>
-#include <boost/spirit/home/karma/numeric/meta_grammar.hpp>
 
 #endif

Modified: branches/release/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp (original)
+++ branches/release/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2008 Hartmut Kaiser
+// Copyright (c) 2001-2009 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)
@@ -6,22 +6,21 @@
 #if !defined(BOOST_SPIRIT_KARMA_NUMERIC_UTILS_FEB_23_2007_0841PM)
 #define BOOST_SPIRIT_KARMA_NUMERIC_UTILS_FEB_23_2007_0841PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
+#include <boost/config.hpp>
 #include <boost/config/no_tr1/cmath.hpp>
 #include <limits>
 
 #include <boost/type_traits/is_integral.hpp>
 #include <boost/spirit/home/support/char_class.hpp>
-#include <boost/spirit/home/support/iso8859_1.hpp>
-#include <boost/spirit/home/support/ascii.hpp>
 #include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/detail/pow10.hpp>
+#include <boost/spirit/home/support/detail/sign.hpp>
 #include <boost/spirit/home/karma/detail/generate_to.hpp>
 #include <boost/spirit/home/karma/detail/string_generate.hpp>
-#include <boost/spirit/home/support/detail/math/fpclassify.hpp>
-#include <boost/spirit/home/support/detail/math/signbit.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 //
@@ -38,11 +37,11 @@
 #endif
 
 #if BOOST_KARMA_NUMERICS_LOOP_UNROLL < 0
-#error "Please set the BOOST_KARMA_NUMERICS_LOOP_UNROLL to a positive value!"
+#error "Please set the BOOST_KARMA_NUMERICS_LOOP_UNROLL to a non-negative value!"
 #endif
 
-namespace boost { namespace spirit { namespace karma {
-
+namespace boost { namespace spirit { namespace karma
+{
     namespace detail
     {
         ///////////////////////////////////////////////////////////////////////
@@ -51,97 +50,136 @@
         // underflow
         //
         ///////////////////////////////////////////////////////////////////////
- inline unsigned short absolute_value (short n)
- {
- return (n >= 0) ? n : (unsigned short)(-n);
- }
-
- inline unsigned int absolute_value (int n)
+ template <typename T>
+ struct absolute_value_helper
         {
- return (n >= 0) ? n : (unsigned int)(-n);
- }
+ typedef T result_type;
+ static T call (T n)
+ {
+ // allow for ADL to find the correct overloads for fabs
+ using namespace std;
+ return fabs(n);
+ }
+ };
 
- inline unsigned long absolute_value (long n)
- {
- return (n >= 0) ? n : (unsigned long)(-n);
- }
+#define BOOST_SPIRIT_ABSOLUTE_VALUE(type, unsignedtype) \
+ template <> \
+ struct absolute_value_helper<type> \
+ { \
+ typedef unsignedtype result_type; \
+ static result_type call(type n) \
+ { \
+ return (n >= 0) ? n : (unsignedtype)(-n); \
+ } \
+ } \
+ /**/
+#define BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(type) \
+ template <> \
+ struct absolute_value_helper<type> \
+ { \
+ typedef type result_type; \
+ static result_type call(type n) \
+ { \
+ return n; \
+ } \
+ } \
+ /**/
 
+ BOOST_SPIRIT_ABSOLUTE_VALUE(short, unsigned short);
+ BOOST_SPIRIT_ABSOLUTE_VALUE(int, unsigned int);
+ BOOST_SPIRIT_ABSOLUTE_VALUE(long, unsigned long);
+ BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(unsigned short);
+ BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(unsigned int);
+ BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(unsigned long);
 #ifdef BOOST_HAS_LONG_LONG
- inline boost::ulong_long_type absolute_value (boost::long_long_type n)
- {
- return (n >= 0) ? n : (boost::ulong_long_type)(-n);
- }
+ BOOST_SPIRIT_ABSOLUTE_VALUE(boost::long_long_type, boost::ulong_long_type);
+ BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(boost::ulong_long_type);
 #endif
-
- inline float absolute_value (float n)
+
+#undef BOOST_SPIRIT_ABSOLUTE_VALUE
+#undef BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED
+
+ template <>
+ struct absolute_value_helper<float>
         {
- return boost::spirit::math::signbit(n) ?
- boost::spirit::math::changesign(n) : n;
- }
-
- inline double absolute_value (double n)
+ typedef long double result_type;
+ static result_type call(float n)
+ {
+ return (spirit::detail::signbit)(n) ? -n : n;
+ }
+ };
+
+ template <>
+ struct absolute_value_helper<double>
         {
- return boost::spirit::math::signbit(n) ?
- boost::spirit::math::changesign(n) : n;
- }
-
- inline long double absolute_value (long double n)
+ typedef long double result_type;
+ static result_type call(double n)
+ {
+ return (spirit::detail::signbit)(n) ? -n : n;
+ }
+ };
+
+ template <>
+ struct absolute_value_helper<long double>
         {
- return boost::spirit::math::signbit(n) ?
- boost::spirit::math::changesign(n) : n;
- }
-
+ typedef long double result_type;
+ static result_type call(long double n)
+ {
+ return (spirit::detail::signbit)(n) ? -n : n;
+ }
+ };
+
         template <typename T>
- inline T absolute_value (T n)
+ typename absolute_value_helper<T>::result_type
+ absolute_value(T n)
         {
- using namespace std;
- return fabs(n);
+ return absolute_value_helper<T>::call(n);
         }
 
         ///////////////////////////////////////////////////////////////////////
         inline bool is_negative(float n)
         {
- return boost::spirit::math::signbit(n);
+ return (spirit::detail::signbit)(n) ? true : false;
         }
-
+
         inline bool is_negative(double n)
         {
- return boost::spirit::math::signbit(n);
+ return (spirit::detail::signbit)(n) ? true : false;
         }
-
+
         inline bool is_negative(long double n)
         {
- return boost::spirit::math::signbit(n);
+ return (spirit::detail::signbit)(n) ? true : false;
         }
-
+
         template <typename T>
         inline bool is_negative(T n)
         {
             return (n < 0) ? true : false;
         }
-
+
         ///////////////////////////////////////////////////////////////////////
         inline bool is_zero(float n)
         {
- return boost::spirit::math::fpclassify(n) == FP_ZERO;
+ return (math::fpclassify)(n) == FP_ZERO;
         }
-
+
         inline bool is_zero(double n)
         {
- return boost::spirit::math::fpclassify(n) == FP_ZERO;
+ return (math::fpclassify)(n) == FP_ZERO;
         }
-
+
         inline bool is_zero(long double n)
         {
- return boost::spirit::math::fpclassify(n) == FP_ZERO;
+ return (math::fpclassify)(n) == FP_ZERO;
         }
-
+
         template <typename T>
         inline bool is_zero(T n)
         {
             return (n == 0) ? true : false;
         }
-
+
         ///////////////////////////////////////////////////////////////////////
         struct cast_to_long
         {
@@ -149,17 +187,17 @@
             {
                 return static_cast<long>(std::floor(n));
             }
-
+
             static long call(double n, mpl::false_)
             {
                 return static_cast<long>(std::floor(n));
             }
-
+
             static long call(long double n, mpl::false_)
             {
                 return static_cast<long>(std::floor(n));
             }
-
+
             template <typename T>
             static long call(T n, mpl::false_)
             {
@@ -181,30 +219,34 @@
                 return call(n, mpl::bool_<is_integral<T>::value>());
             }
         };
-
+
         ///////////////////////////////////////////////////////////////////////
- struct round_to_long
+ struct truncate_to_long
         {
             static long call(float n, mpl::false_)
             {
- return static_cast<long>(std::floor(n + 0.5f));
+ return is_negative(n) ? static_cast<long>(std::ceil(n)) :
+ static_cast<long>(std::floor(n));
             }
-
+
             static long call(double n, mpl::false_)
             {
- return static_cast<long>(std::floor(n + 0.5));
+ return is_negative(n) ? static_cast<long>(std::ceil(n)) :
+ static_cast<long>(std::floor(n));
             }
-
+
             static long call(long double n, mpl::false_)
             {
- return static_cast<long>(std::floor(n + 0.5l));
+ return is_negative(n) ? static_cast<long>(std::ceil(n)) :
+ static_cast<long>(std::floor(n));
             }
-
+
             template <typename T>
             static long call(T n, mpl::false_)
             {
+ // allow for ADL to find the correct overloads for ltrunc
                 using namespace std;
- return lround(n);
+ return ltrunc(n);
             }
 
             template <typename T>
@@ -219,7 +261,7 @@
                 return call(n, mpl::bool_<is_integral<T>::value>());
             }
         };
-
+
         ///////////////////////////////////////////////////////////////////////
         //
         // Traits class for radix specific number conversion
@@ -230,12 +272,12 @@
         // static int digit(unsigned n);
         //
         ///////////////////////////////////////////////////////////////////////
- template<unsigned Radix, typename Tag>
+ template<unsigned Radix, typename CharEncoding, typename Tag>
         struct radix_traits;
 
         // Binary
- template<typename Tag>
- struct radix_traits<2, Tag>
+ template<typename CharEncoding, typename Tag>
+ struct radix_traits<2, CharEncoding, Tag>
         {
             static int digit(unsigned n)
             {
@@ -244,8 +286,8 @@
         };
 
         // Octal
- template<typename Tag>
- struct radix_traits<8, Tag>
+ template<typename CharEncoding, typename Tag>
+ struct radix_traits<8, CharEncoding, Tag>
         {
             static int digit(unsigned n)
             {
@@ -254,8 +296,8 @@
         };
 
         // Decimal
- template<typename Tag>
- struct radix_traits<10, Tag>
+ template<typename CharEncoding, typename Tag>
+ struct radix_traits<10, CharEncoding, Tag>
         {
             static int digit(unsigned n)
             {
@@ -265,7 +307,7 @@
 
         // Hexadecimal, lower case
         template<>
- struct radix_traits<16, unused_type>
+ struct radix_traits<16, unused_type, unused_type>
         {
             static int digit(unsigned n)
             {
@@ -276,19 +318,16 @@
         };
 
         // Hexadecimal, upper case
- template<typename Tag>
- struct radix_traits<16, Tag>
+ template<typename CharEncoding, typename Tag>
+ struct radix_traits<16, CharEncoding, Tag>
         {
- typedef typename Tag::char_set char_set;
- typedef typename Tag::char_class char_class_;
-
             static int digit(unsigned n)
             {
                 if (n <= 9)
                     return n + '0';
 
                 using spirit::char_class::convert;
- return convert<char_set>::to(char_class_(), n - 10 + 'a');
+ return convert<CharEncoding>::to(Tag(), n - 10 + 'a');
             }
         };
 
@@ -301,7 +340,7 @@
             {
                 return n / Radix;
             }
-
+
             template <typename T>
             static T call(T& n, mpl::false_)
             {
@@ -309,14 +348,51 @@
                 using namespace std;
                 return floor(n / Radix);
             }
-
+
+ template <typename T>
+ static T call(T& n, T const&, int)
+ {
+ return call(n, mpl::bool_<is_integral<T>::value>());
+ }
+
             template <typename T>
             static T call(T& n)
             {
                 return call(n, mpl::bool_<is_integral<T>::value>());
             }
         };
-
+
+ // specialization for division by 10
+ template <>
+ struct divide<10>
+ {
+ template <typename T>
+ static T call(T& n, T, int, mpl::true_)
+ {
+ return n / 10;
+ }
+
+ template <typename T>
+ static T call(T, T& num, int exp, mpl::false_)
+ {
+ // Allow ADL to find the correct overload for floor
+ using namespace std;
+ return floor(num / spirit::detail::pow10<T>(exp));
+ }
+
+ template <typename T>
+ static T call(T& n, T& num, int exp)
+ {
+ return call(n, num, exp, mpl::bool_<is_integral<T>::value>());
+ }
+
+ template <typename T>
+ static T call(T& n)
+ {
+ return call(n, n, 1, mpl::bool_<is_integral<T>::value>());
+ }
+ };
+
         ///////////////////////////////////////////////////////////////////////
         template <unsigned Radix>
         struct remainder
@@ -328,7 +404,7 @@
                 // than Radix
                 return static_cast<long>(n % Radix);
             }
-
+
             template <typename T>
             static long call(T n, mpl::false_)
             {
@@ -336,16 +412,16 @@
                 using namespace std;
                 return cast_to_long::call(fmod(n, T(Radix)));
             }
-
+
             template <typename T>
             static long call(T n)
             {
                 return call(n, mpl::bool_<is_integral<T>::value>());
             }
         };
-
+
     } // namespace detail
-
+
     ///////////////////////////////////////////////////////////////////////////
     //
     // The int_inserter template takes care of the integer to string
@@ -360,7 +436,7 @@
 #define BOOST_KARMA_NUMERICS_INNER_LOOP_PREFIX(z, x, data) \
         if (!detail::is_zero(n)) { \
             int ch = radix_type::digit(remainder_type::call(n)); \
- n = divide_type::call(n); \
+ n = divide_type::call(n, num, ++exp); \
     /**/
 
 #define BOOST_KARMA_NUMERICS_INNER_LOOP_SUFFIX(z, x, data) \
@@ -369,28 +445,29 @@
         } \
     /**/
 
- template <unsigned Radix, typename Tag = unused_type>
+ template <
+ unsigned Radix, typename CharEncoding = unused_type
+ , typename Tag = unused_type>
     struct int_inserter
     {
- typedef detail::radix_traits<Radix, Tag> radix_type;
+ typedef detail::radix_traits<Radix, CharEncoding, Tag> radix_type;
         typedef detail::divide<Radix> divide_type;
         typedef detail::remainder<Radix> remainder_type;
-
- // Common code for integer string representations
+
         template <typename OutputIterator, typename T>
         static bool
- call(OutputIterator& sink, T n)
+ call(OutputIterator& sink, T n, T& num, int exp)
         {
             // remainder_type::call returns n % Radix
             int ch = radix_type::digit(remainder_type::call(n));
- n = divide_type::call(n);
+ n = divide_type::call(n, num, ++exp);
 
             BOOST_PP_REPEAT(
                 BOOST_KARMA_NUMERICS_LOOP_UNROLL,
                 BOOST_KARMA_NUMERICS_INNER_LOOP_PREFIX, _);
 
             if (!detail::is_zero(n))
- call(sink, n);
+ call(sink, n, num, exp);
 
             BOOST_PP_REPEAT(
                 BOOST_KARMA_NUMERICS_LOOP_UNROLL,
@@ -400,6 +477,68 @@
             ++sink;
             return true;
         }
+
+ // Common code for integer string representations
+ template <typename OutputIterator, typename T>
+ static bool
+ call(OutputIterator& sink, T n)
+ {
+ return call(sink, n, n, 0);
+ }
+
+ private:
+ // helper function returning the biggest number representable either in
+ // a boost::long_long_type (if this does exist) or in a plain long
+ // otherwise
+#if defined(BOOST_HAS_LONG_LONG)
+ typedef boost::long_long_type biggest_long_type;
+#else
+ typedef long biggest_long_type;
+#endif
+
+ static biggest_long_type max_long()
+ {
+ return (std::numeric_limits<biggest_long_type>::max)();
+ }
+
+ public:
+ // Specialization for doubles and floats, falling back to long integers
+ // for representable values. These specializations speed up formatting
+ // of floating point numbers considerably as all the required
+ // arithmetics will be executed using integral data types.
+ template <typename OutputIterator>
+ static bool
+ call(OutputIterator& sink, long double n)
+ {
+ if (std::fabs(n) < max_long())
+ {
+ biggest_long_type l((biggest_long_type)n);
+ return call(sink, l, l, 0);
+ }
+ return call(sink, n, n, 0);
+ }
+ template <typename OutputIterator>
+ static bool
+ call(OutputIterator& sink, double n)
+ {
+ if (std::fabs(n) < max_long())
+ {
+ biggest_long_type l((biggest_long_type)n);
+ return call(sink, l, l, 0);
+ }
+ return call(sink, n, n, 0);
+ }
+ template <typename OutputIterator>
+ static bool
+ call(OutputIterator& sink, float n)
+ {
+ if (std::fabs(n) < max_long())
+ {
+ biggest_long_type l((biggest_long_type)n);
+ return call(sink, l, l, 0);
+ }
+ return call(sink, n, n, 0);
+ }
     };
 
 #undef BOOST_KARMA_NUMERICS_INNER_LOOP_PREFIX
@@ -409,16 +548,15 @@
     //
     // The sign_inserter template generates a sign for a given numeric value.
     //
- // The parameter ForceSign allows to generate a sign even for positive
+ // The parameter forcesign allows to generate a sign even for positive
     // numbers.
     //
     ///////////////////////////////////////////////////////////////////////////
- template <bool ForceSign>
     struct sign_inserter
     {
         template <typename OutputIterator>
         static bool
- call(OutputIterator& sink, bool /*is_zero*/, bool is_negative)
+ call_noforce(OutputIterator& sink, bool /*is_zero*/, bool is_negative)
         {
             // generate a sign for negative numbers only
             if (is_negative) {
@@ -427,210 +565,30 @@
             }
             return true;
         }
- };
-
- template <>
- struct sign_inserter<true>
- {
+
         template <typename OutputIterator>
         static bool
- call(OutputIterator& sink, bool is_zero, bool is_negative)
+ call_force(OutputIterator& sink, bool is_zero, bool is_negative)
         {
             // generate a sign for all numbers except zero
             if (!is_zero)
                 *sink = is_negative ? '-' : '+';
             else
                 *sink = ' ';
-
+
             ++sink;
             return true;
         }
- };
 
- ///////////////////////////////////////////////////////////////////////////
- // These are helper functions for the real policies allowing to generate
- // a single character and a string
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag = unused_type>
- struct char_inserter
- {
- template <typename OutputIterator, typename Char>
- static bool
- call(OutputIterator& sink, Char c)
- {
- return detail::generate_to(sink, c, Tag());
- }
- };
-
- template <typename Tag = unused_type>
- struct string_inserter
- {
- template <typename OutputIterator, typename String>
- static bool
- call(OutputIterator& sink, String str)
- {
- return detail::string_generate(sink, str, Tag());
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // The real_inserter template takes care of the floating point number to
- // string conversion. The RealPolicies template parameter is used to allow
- // customization of the formatting process
- //
- ///////////////////////////////////////////////////////////////////////////
- template <typename T, typename RealPolicies, typename Tag = unused_type>
- struct real_inserter
- {
- enum { force_sign = RealPolicies::force_sign };
-
- template <typename OutputIterator>
- static bool
- call (OutputIterator& sink, float n, RealPolicies const& p)
- {
- int fpclass = boost::spirit::math::fpclassify(n);
- if (FP_NAN == fpclass)
- return RealPolicies::template nan<force_sign, Tag>(sink, n);
- else if (FP_INFINITE == fpclass)
- return RealPolicies::template inf<force_sign, Tag>(sink, n);
- return call_n(sink, n, p);
- }
-
         template <typename OutputIterator>
         static bool
- call (OutputIterator& sink, double n, RealPolicies const& p)
+ call(OutputIterator& sink, bool is_zero, bool is_negative
+ , bool forcesign)
         {
- int fpclass = boost::spirit::math::fpclassify(n);
- if (FP_NAN == fpclass)
- return RealPolicies::template nan<force_sign, Tag>(sink, n);
- else if (FP_INFINITE == fpclass)
- return RealPolicies::template inf<force_sign, Tag>(sink, n);
- return call_n(sink, n, p);
+ return forcesign ?
+ call_force(sink, is_zero, is_negative) :
+ call_noforce(sink, is_zero, is_negative);
         }
-
- template <typename OutputIterator>
- static bool
- call (OutputIterator& sink, long double n, RealPolicies const& p)
- {
- int fpclass = boost::spirit::math::fpclassify(n);
- if (FP_NAN == fpclass)
- return RealPolicies::template nan<force_sign, Tag>(sink, n);
- else if (FP_INFINITE == fpclass)
- return RealPolicies::template inf<force_sign, Tag>(sink, n);
- return call_n(sink, n, p);
- }
-
- template <typename OutputIterator, typename U>
- static bool
- call (OutputIterator& sink, U n, RealPolicies const& p)
- {
- // we have no means of testing whether the number is normalized if
- // the type is not float, double or long double
- return call_n(sink, T(n), p);
- }
-
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
-# pragma warning(push)
-# pragma warning(disable: 4100) // 'p': unreferenced formal parameter
-# pragma warning(disable: 4127) // conditional expression is constant
-#endif
-
- ///////////////////////////////////////////////////////////////////////
- // This is the workhorse behind the real generator
- ///////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename U>
- static bool
- call_n (OutputIterator& sink, U n, RealPolicies const& p)
- {
- // prepare sign and get output format
- bool sign_val = false;
- int flags = p.floatfield(n);
- if (detail::is_negative(n))
- {
- n = -n;
- sign_val = true;
- }
-
- // The scientific representation requires the normalization of the
- // value to convert.
-
- // allow for ADL to find the correct overloads for log10 et.al.
- using namespace std;
-
- U dim = 0;
- if (0 == (p.fixed & flags) && !detail::is_zero(n))
- {
- dim = log10(n);
- if (dim > 0)
- n /= pow(U(10.0), (int)detail::round_to_long::call(dim));
- else if (n < 1.)
- n *= pow(U(10.0), (int)detail::round_to_long::call(-dim));
- }
-
- // prepare numbers (sign, integer and fraction part)
- unsigned precision = p.precision(n);
- U integer_part;
- U precexp = std::pow(10.0, (int)precision);
- U fractional_part = modf(n, &integer_part);
-
- fractional_part = floor(fractional_part * precexp + 0.5);
- if (fractional_part >= precexp)
- {
- fractional_part -= precexp;
- integer_part += 1; // handle rounding overflow
- }
-
- // if trailing zeros are to be omitted, normalize the precision and
- // fractional part
- U long_int_part = floor(integer_part);
- U long_frac_part = floor(fractional_part);
- if (!p.trailing_zeros)
- {
- if (0 != long_frac_part) {
- // remove the trailing zeros
- while (0 != precision &&
- 0 == detail::remainder<10>::call(long_frac_part))
- {
- long_frac_part = detail::divide<10>::call(long_frac_part);
- --precision;
- }
- }
- else {
- // if the fractional part is zero, we don't need to output
- // any additional digits
- precision = 0;
- }
- }
-
- // call the actual generating functions to output the different parts
- if (sign_val && detail::is_zero(long_int_part) &&
- detail::is_zero(long_frac_part))
- {
- sign_val = false; // result is zero, no sign please
- }
-
- // generate integer part
- bool r = p.template integer_part<force_sign>(
- sink, long_int_part, sign_val);
-
- // generate decimal point
- r = r && p.dot(sink, long_frac_part);
-
- // generate fractional part with the desired precision
- r = r && p.fraction_part(sink, long_frac_part, precision);
-
- if (r && 0 == (p.fixed & flags)) {
- return p.template exponent<Tag>(sink,
- detail::round_to_long::call(dim));
- }
- return r;
- }
-
-#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
-# pragma warning(pop)
-#endif
-
     };
 
 }}}

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,77 +6,221 @@
 #if !defined(BOOST_SPIRIT_KARMA_INT_FEB_23_2007_0840PM)
 #define BOOST_SPIRIT_KARMA_INT_FEB_23_2007_0840PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <limits>
 
-#include <boost/spirit/home/support/modifier.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/char_class.hpp>
+#include <boost/spirit/home/support/detail/get_encoding.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/karma/detail/get_casetag.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
-#include <boost/spirit/home/karma/numeric/numeric_fwd.hpp>
 #include <boost/spirit/home/karma/numeric/detail/numeric_utils.hpp>
 #include <boost/fusion/include/at.hpp>
 #include <boost/fusion/include/value_at.hpp>
 #include <boost/fusion/include/vector.hpp>
-#include <boost/mpl/assert.hpp>
 
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
+ namespace tag
+ {
+ template <typename T, unsigned Radix, bool force_sign>
+ struct int_tag {};
+ }
+
+ namespace karma
+ {
+ ///////////////////////////////////////////////////////////////////////
+ // This one is the class that the user can instantiate directly in
+ // order to create a customized int generator
+ template <typename T = int, unsigned Radix = 10, bool force_sign = false>
+ struct int_generator
+ : spirit::terminal<tag::int_tag<T, Radix, force_sign> >
+ {};
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, tag::short_> // enables short_
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::int_> // enables int_
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::long_> // enables long_
+ : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <>
+ struct use_terminal<karma::domain, tag::long_long> // enables long_long
+ : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, short> // enables lit(short(0))
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, int> // enables lit(0)
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, long> // enables lit(0L)
+ : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <>
+ struct use_terminal<karma::domain, boost::long_long_type> // enables lit(0LL)
+ : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename A0>
+ struct use_terminal<karma::domain // enables short_(...)
+ , terminal_ex<tag::short_, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables int_(...)
+ , terminal_ex<tag::int_, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables long_(...)
+ , terminal_ex<tag::long_, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename A0>
+ struct use_terminal<karma::domain // enables long_long(...)
+ , terminal_ex<tag::long_long, fusion::vector1<A0> >
+ > : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <> // enables *lazy* short_(...)
+ struct use_lazy_terminal<karma::domain, tag::short_, 1>
+ : mpl::true_ {};
+
+ template <> // enables *lazy* int_(...)
+ struct use_lazy_terminal<karma::domain, tag::int_, 1>
+ : mpl::true_ {};
+
+ template <> // enables *lazy* long_(...)
+ struct use_lazy_terminal<karma::domain, tag::long_, 1>
+ : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <> // enables *lazy* long_long(...)
+ struct use_lazy_terminal<karma::domain, tag::long_long, 1>
+ : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ // enables any custom int_generator
+ template <typename T, unsigned Radix, bool force_sign>
+ struct use_terminal<karma::domain, tag::int_tag<T, Radix, force_sign> >
+ : mpl::true_ {};
+
+ // enables any custom int_generator(...)
+ template <typename T, unsigned Radix, bool force_sign, typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::int_tag<T, Radix, force_sign>, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ // enables *lazy* custom int_generator
+ template <typename T, unsigned Radix, bool force_sign>
+ struct use_lazy_terminal<
+ karma::domain
+ , tag::int_tag<T, Radix, force_sign>
+ , 1 // arity
+ > : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
+ using spirit::short_;
+ using spirit::short__type;
+ using spirit::int_;
+ using spirit::int__type;
+ using spirit::long_;
+ using spirit::long__type;
+#ifdef BOOST_HAS_LONG_LONG
+ using spirit::long_long;
+ using spirit::long_long_type;
+#endif
+
+ using spirit::lit; // lit(1) is equivalent to 1
+
     ///////////////////////////////////////////////////////////////////////////
     // This specialization is used for int generators not having a direct
     // initializer: int_, long_ etc. These generators must be used in
- // conjunction with a parameter.
+ // conjunction with an Attribute.
     ///////////////////////////////////////////////////////////////////////////
- template <typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct int_generator<false, T, Radix, ForceSign, Tag>
+ template <
+ typename T, typename CharEncoding, typename Tag, unsigned Radix
+ , bool force_sign>
+ struct any_int_generator
+ : primitive_generator<any_int_generator<T, CharEncoding, Tag, Radix
+ , force_sign> >
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef T type;
         };
 
- // check template parameter 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ // check template Attribute 'Radix' for validity
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
- BOOST_MPL_ASSERT_MSG(std::numeric_limits<T>::is_signed,
+ BOOST_SPIRIT_ASSERT_MSG(std::numeric_limits<T>::is_signed,
             signed_unsigned_mismatch, ());
 
- // int has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
+ // int has a Attribute attached
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
         static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
+ generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr)
         {
- sign_inserter<ForceSign>::call(sink, detail::is_zero(param),
- detail::is_negative(param));
- bool result = int_inserter<Radix, Tag>::call(sink,
- detail::absolute_value(param));
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ return sign_inserter::call(sink, detail::is_zero(attr)
+ , detail::is_negative(attr), force_sign) &&
+ int_inserter<Radix, CharEncoding, Tag>::call(sink
+ , detail::absolute_value(attr)) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- // this int has no parameter attached, it needs to have been
+ // this int has no Attribute attached, it needs to have been
         // initialized from a direct literal
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
+ template <typename OutputIterator, typename Context, typename Delimiter>
         static bool
- generate(Component const&, OutputIterator&, Context&, Delimiter const&,
- unused_type)
+ generate(OutputIterator&, Context&, Delimiter const&, unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false, int__not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, int_not_usable_without_attribute, ());
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
- return "integer";
+ return info("integer");
         }
     };
 
@@ -84,157 +228,219 @@
     // This specialization is used for int generators having a direct
     // initializer: int_(10), long_(20) etc.
     ///////////////////////////////////////////////////////////////////////////
- template <typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct int_generator<true, T, Radix, ForceSign, Tag>
+ template <
+ typename T, typename CharEncoding, typename Tag, unsigned Radix
+ , bool force_sign, bool no_attribute>
+ struct literal_int_generator
+ : primitive_generator<literal_int_generator<T, CharEncoding, Tag, Radix
+ , force_sign, no_attribute> >
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
- {
- typedef unused_type type;
- };
+ : mpl::if_c<no_attribute, unused_type, T>
+ {};
+
+ literal_int_generator(typename add_const<T>::type n)
+ : n_(n) {}
 
- // check template parameter 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ // check template Attribute 'Radix' for validity
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
- BOOST_MPL_ASSERT_MSG(std::numeric_limits<T>::is_signed,
+ BOOST_SPIRIT_ASSERT_MSG(std::numeric_limits<T>::is_signed,
             signed_unsigned_mismatch, ());
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
- {
- T n = fusion::at_c<0>(component.elements);
- sign_inserter<ForceSign>::call(sink, detail::is_zero(n),
- detail::is_negative(n));
- bool result = int_inserter<Radix, Tag>::call(sink,
- detail::absolute_value(n));
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ // A int_(1) which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ if (n_ != attr)
+ return false;
+
+ return sign_inserter::call(sink, detail::is_zero(n_)
+ , detail::is_negative(n_), force_sign) &&
+ int_inserter<Radix, CharEncoding, Tag>::call(sink
+ , detail::absolute_value(n_)) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
+
+ // A int_(1) without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
+ {
+ return sign_inserter::call(sink, detail::is_zero(n_)
+ , detail::is_negative(n_), force_sign) &&
+ int_inserter<Radix, CharEncoding, Tag>::call(sink
+ , detail::absolute_value(n_)) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
- return "integer";
+ return info("integer");
         }
- };
 
-}}}
+ T n_;
+ };
 
-namespace boost { namespace spirit { namespace traits
-{
     ///////////////////////////////////////////////////////////////////////////
- // lower_case int_generator generator
+ // Generator generators: make_xxx function (objects)
     ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct make_modified_component<
- Domain, karma::int_generator<false, T, Radix, ForceSign, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::lower char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef karma::int_generator<false, T, Radix, ForceSign, key_tag> int_type;
- typedef component<karma::domain, int_type, fusion::nil> type;
+ template <typename T, typename Modifiers, unsigned Radix = 10
+ , bool force_sign = false>
+ struct make_int
+ {
+ 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 any_int_generator<
+ T
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , Radix
+ , force_sign
+ > result_type;
 
- static type
- call(Elements const&)
+ result_type operator()(unused_type, unused_type) const
         {
- return type(fusion::nil());
+ return result_type();
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct make_modified_component<
- Domain, karma::int_generator<true, T, Radix, ForceSign, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::lower char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- int_data_type;
- typedef fusion::vector<int_data_type> vector_type;
-
- typedef karma::int_generator<true, T, Radix, ForceSign, key_tag> int_type;
- typedef component<karma::domain, int_type, vector_type> type;
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers>
+ struct make_primitive<tag::short_, Modifiers>
+ : make_int<short, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::int_, Modifiers>
+ : make_int<int, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::long_, Modifiers>
+ : make_int<long, Modifiers> {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename Modifiers>
+ struct make_primitive<tag::long_long, Modifiers>
+ : make_int<boost::long_long_type, Modifiers> {};
+#endif
 
- static type
- call(Elements const& elements)
- {
- return type(elements);
- }
- };
+ template <typename T, unsigned Radix, bool force_sign, typename Modifiers>
+ struct make_primitive<tag::int_tag<T, Radix, force_sign>, Modifiers>
+ : make_int<T, Modifiers, Radix, force_sign> {};
 
     ///////////////////////////////////////////////////////////////////////////
- // upper_case int_generator generator
- ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct make_modified_component<
- Domain, karma::int_generator<false, T, Radix, ForceSign, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::upper char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef karma::int_generator<false, T, Radix, ForceSign, key_tag> int_type;
- typedef component<karma::domain, int_type, fusion::nil> type;
+ template <typename T, typename Modifiers, unsigned Radix = 10
+ , bool force_sign = false>
+ struct make_int_direct
+ {
+ 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 literal_int_generator<
+ T
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , Radix, force_sign, false
+ > result_type;
 
- static type
- call(Elements const&)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return type(fusion::nil());
+ return result_type(fusion::at_c<0>(term.args));
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct make_modified_component<
- Domain, karma::int_generator<true, T, Radix, ForceSign, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::upper char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- int_data_type;
- typedef fusion::vector<int_data_type> vector_type;
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::short_, fusion::vector1<A0> >, Modifiers>
+ : make_int_direct<short, Modifiers> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::int_, fusion::vector1<A0> >, Modifiers>
+ : make_int_direct<int, Modifiers> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::long_, fusion::vector1<A0> >, Modifiers>
+ : make_int_direct<long, Modifiers> {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::long_long, fusion::vector1<A0> >, Modifiers>
+ : make_int_direct<boost::long_long_type, Modifiers> {};
+#endif
 
- typedef karma::int_generator<true, T, Radix, ForceSign, key_tag> int_type;
- typedef component<karma::domain, int_type, vector_type> type;
+ template <typename T, unsigned Radix, bool force_sign, typename A0
+ , typename Modifiers>
+ struct make_primitive<
+ terminal_ex<tag::int_tag<T, Radix, force_sign>, fusion::vector1<A0> >
+ , Modifiers>
+ : make_int_direct<T, Modifiers, Radix, force_sign> {};
 
- static type
- call(Elements const& elements)
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ template <typename T, typename Modifiers>
+ struct basic_int_literal
         {
- return type(elements);
- }
- };
+ 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 literal_int_generator<
+ T
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , 10, false, true
+ > result_type;
+
+ template <typename T_>
+ result_type operator()(T_ i, unused_type) const
+ {
+ return result_type(i);
+ }
+ };
+ }
 
-}}} // namespace boost::spirit::traits
+ template <typename Modifiers>
+ struct make_primitive<short, Modifiers>
+ : detail::basic_int_literal<int, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<int, Modifiers>
+ : detail::basic_int_literal<int, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<long, Modifiers>
+ : detail::basic_int_literal<long, Modifiers> {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename Modifiers>
+ struct make_primitive<boost::long_long_type, Modifiers>
+ : detail::basic_int_literal<boost::long_long_type, Modifiers> {};
+#endif
+
+}}}
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/numeric/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,452 +0,0 @@
-// Copyright (c) 2001-2009 Hartmut Kaiser
-// Copyright (c) 2001-2007 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_KARMA_META_GRAMMAR_FEB_23_2007_0505PM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_FEB_23_2007_0505PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/numeric/numeric_fwd.hpp>
-#include <boost/spirit/home/support/placeholders.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/identity.hpp>
-#include <boost/mpl/bool.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // numeric tags
- ///////////////////////////////////////////////////////////////////////////
- template <typename T, unsigned Radix, bool ForceSign>
- struct int_tag
- {};
-
- template <typename T, unsigned Radix, bool ForceSign>
- struct uint_tag
- {};
-
- template <typename T, typename RealPolicies>
- struct real_tag
- {
- RealPolicies policies;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // numeric specs
- ///////////////////////////////////////////////////////////////////////////
- template <typename T, unsigned Radix, bool ForceSign>
- struct int_spec
- : proto::terminal<int_tag<T, Radix, ForceSign> >::type
- {};
-
- template <typename T, unsigned Radix, bool ForceSign>
- struct uint_spec
- : proto::terminal<uint_tag<T, Radix, ForceSign> >::type
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename T, typename RealPolicies>
- struct real_spec
- : proto::terminal<real_tag<T, RealPolicies> >::type
- {
- private:
- typedef typename
- proto::terminal<real_tag<T, RealPolicies> >::type
- base_type;
-
- base_type make_tag(RealPolicies const& p) const
- {
- base_type xpr = {{p}};
- return xpr;
- }
-
- public:
- real_spec(RealPolicies const& p = RealPolicies())
- : base_type(make_tag(p))
- {}
- };
-
- ///////////////////////////////////////////////////////////////////////////
- namespace detail
- {
- template <typename RealPolicies>
- struct real_policy
- {
- template <typename Tag>
- static RealPolicies get(Tag) { return RealPolicies(); }
-
- template <typename T>
- static RealPolicies const& get(real_tag<T, RealPolicies> const& p)
- { return p.policies; }
- };
- }
-
-}}} // namespace boost::spirit::karma
-
-namespace boost { namespace spirit
-{
- ///////////////////////////////////////////////////////////////////////////
- // test if a tag is an int tag (the basic specializations are defined in
- // the file support/placeholders.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename T, unsigned Radix, bool ForceSign>
- struct is_int_tag<karma::int_tag<T, Radix, ForceSign>, karma::domain> :
- mpl::true_ {};
-
- template <typename T, unsigned Radix, bool ForceSign>
- struct is_int_tag<karma::uint_tag<T, Radix, ForceSign>, karma::domain> :
- mpl::true_ {};
-
- ///////////////////////////////////////////////////////////////////////////
- // test if a tag is a real tag (the basic specializations are defined in
- // the file support/placeholders.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename T, typename RealPolicies>
- struct is_real_tag<karma::real_tag<T, RealPolicies>, karma::domain> :
- mpl::true_ {};
-
-}} // namespace boost::spirit
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // get the director of an int tag
- ///////////////////////////////////////////////////////////////////////////
- template <typename T, bool IsLiteral>
- struct extract_int_director;
-
- template <bool IsLiteral>
- struct extract_int_director<tag::bin, IsLiteral>
- {
- typedef uint_generator<IsLiteral, unsigned, 2, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::oct, IsLiteral>
- {
- typedef uint_generator<IsLiteral, unsigned, 8, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::hex, IsLiteral>
- {
- typedef uint_generator<IsLiteral, unsigned, 16, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::ushort, IsLiteral>
- {
- typedef uint_generator<IsLiteral, unsigned short, 10, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::ulong, IsLiteral>
- {
- typedef uint_generator<IsLiteral, unsigned long, 10, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::uint, IsLiteral>
- {
- typedef uint_generator<IsLiteral, unsigned int, 10, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::short_, IsLiteral>
- {
- typedef int_generator<IsLiteral, short, 10, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::long_, IsLiteral>
- {
- typedef int_generator<IsLiteral, long, 10, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::int_, IsLiteral>
- {
- typedef int_generator<IsLiteral, int, 10, false> type;
- };
-
-#ifdef BOOST_HAS_LONG_LONG
- template <bool IsLiteral>
- struct extract_int_director<tag::ulong_long, IsLiteral>
- {
- typedef uint_generator<IsLiteral, boost::ulong_long_type, 10, false> type;
- };
-
- template <bool IsLiteral>
- struct extract_int_director<tag::long_long, IsLiteral>
- {
- typedef int_generator<IsLiteral, boost::long_long_type, 10, false> type;
- };
-#endif
-
- template <typename T, unsigned Radix, bool ForceSign, bool IsLiteral>
- struct extract_int_director<int_tag<T, Radix, ForceSign>, IsLiteral>
- {
- typedef int_generator<IsLiteral, T, Radix, ForceSign> type;
- };
-
- template <typename T, unsigned Radix, bool ForceSign, bool IsLiteral>
- struct extract_int_director<uint_tag<T, Radix, ForceSign>, IsLiteral>
- {
- typedef uint_generator<IsLiteral, T, Radix, ForceSign> type;
- };
-
- template <typename T, typename Unused>
- struct extract_int_director_lit
- : extract_int_director<T, true> {};
-
- template <typename T>
- struct extract_int_director_plain
- : extract_int_director<T, false> {};
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of a floating point literal type
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag>
- struct extract_literal_real_director;
-
- template <>
- struct extract_literal_real_director<float>
- {
- typedef
- real_generator<true, float, real_generator_policies<float> >
- type;
- };
-
- template <>
- struct extract_literal_real_director<double>
- {
- typedef
- real_generator<true, double, real_generator_policies<double> >
- type;
- };
-
- template <>
- struct extract_literal_real_director<long double>
- {
- typedef
- real_generator<
- true, long double, real_generator_policies<long double>
- >
- type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of a floating point tag
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag, bool IsLiteral>
- struct extract_real_director;
-
- template <bool IsLiteral>
- struct extract_real_director<tag::float_, IsLiteral>
- {
- typedef
- real_generator<IsLiteral, float, real_generator_policies<float> >
- type;
- };
-
- template <bool IsLiteral>
- struct extract_real_director<tag::double_, IsLiteral>
- {
- typedef
- real_generator<IsLiteral, double, real_generator_policies<double> >
- type;
- };
-
- template <bool IsLiteral>
- struct extract_real_director<tag::long_double, IsLiteral>
- {
- typedef
- real_generator<
- IsLiteral, long double, real_generator_policies<long double>
- >
- type;
- };
-
- template <typename T, typename RealPolicies, bool IsLiteral>
- struct extract_real_director<real_tag<T, RealPolicies>, IsLiteral>
- {
- typedef real_generator<IsLiteral, T, RealPolicies> type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag, typename Unused>
- struct extract_real_director_lit
- : extract_real_director<Tag, true> {};
-
- template <typename Tag>
- struct extract_real_director_plain
- : extract_real_director<Tag, false> {};
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of an integer literal type
- ///////////////////////////////////////////////////////////////////////////
- template <typename T>
- struct extract_literal_int_director;
-
- template <>
- struct extract_literal_int_director<short>
- {
- typedef int_generator<true, short, 10, false> type;
- };
-
- template <>
- struct extract_literal_int_director<unsigned short>
- {
- typedef uint_generator<true, unsigned short, 10, false> type;
- };
-
- template <>
- struct extract_literal_int_director<int>
- {
- typedef int_generator<true, int, 10, false> type;
- };
-
- template <>
- struct extract_literal_int_director<unsigned int>
- {
- typedef uint_generator<true, unsigned int, 10, false> type;
- };
-
- template <>
- struct extract_literal_int_director<long>
- {
- typedef int_generator<true, long, 10, false> type;
- };
-
- template <>
- struct extract_literal_int_director<unsigned long>
- {
- typedef uint_generator<true, unsigned long, 10, false> type;
- };
-
-#ifdef BOOST_HAS_LONG_LONG
- template <>
- struct extract_literal_int_director<boost::ulong_long_type>
- {
- typedef int_generator<true, boost::ulong_long_type, 10, false> type;
- };
-
- template <>
- struct extract_literal_int_director<boost::long_long_type>
- {
- typedef uint_generator<true, boost::long_long_type, 10, false> type;
- };
-#endif
-
- ///////////////////////////////////////////////////////////////////////////
- // numeric parser meta-grammar
- ///////////////////////////////////////////////////////////////////////////
-
- // literals: 10, 10L, 10LL
- struct int_literal_meta_grammar
- : meta_grammar::compose_empty<
- proto::if_<
- is_int_lit_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_literal_int_director<mpl::_> >
- >
- {};
-
- // all the different integer's as int_, uint, bin, oct, dec, hex, etc.
- // and the corresponding int_(10), uint(10), etc.
- struct int_meta_grammar
- : proto::or_<
- meta_grammar::compose_empty<
- proto::if_<
- is_int_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_int_director_plain<mpl::_> >
- >,
- meta_grammar::compose_function1_eval<
- proto::function<
- proto::if_<
- is_int_tag<proto::_child, karma::domain>()
- >,
- int_literal_meta_grammar
- >,
- karma::domain,
- mpl::identity<extract_int_director_lit<mpl::_, mpl::_> >
- >
- >
- {};
-
- // floating point literals: 1.0, 1.0f, 10.1e2 etc.
- struct real_literal_meta_grammar
- : meta_grammar::compose_empty<
- proto::if_<
- is_real_lit_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_literal_real_director<mpl::_> >
- >
- {};
-
- struct real_meta_grammar
- : proto::or_<
- meta_grammar::compose_single<
- proto::if_<
- is_real_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_real_director_plain<mpl::_> >
- >,
- meta_grammar::compose_function1_full<
- proto::function<
- proto::if_<
- is_real_tag<proto::_child, karma::domain>()
- >,
- real_literal_meta_grammar
- >,
- karma::domain,
- mpl::identity<extract_real_director_lit<mpl::_, mpl::_> >
- >
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- struct numeric_meta_grammar
- : proto::or_<
- int_meta_grammar,
- real_meta_grammar
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hooks into the RD meta-grammar.
- // (see qi/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<Expr
- , typename enable_if<proto::matches<Expr, numeric_meta_grammar> >::type>
- : mpl::true_
- {};
-
- template <typename Expr>
- struct expr_transform<Expr
- , typename enable_if<proto::matches<Expr, numeric_meta_grammar> >::type>
- : mpl::identity<numeric_meta_grammar>
- {};
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/karma/numeric/numeric_fwd.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/numeric_fwd.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,51 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_NUMERIC_FWD_FEB_27_2007_1338PM)
-#define BOOST_SPIRIT_KARMA_NUMERIC_FWD_FEB_27_2007_1338PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- template <bool IsLiteral, typename T, unsigned Radix, bool ForceSign,
- typename Tag = unused_type>
- struct int_generator;
-
- template <bool IsLiteral, typename T, unsigned Radix, bool ForceSign,
- typename Tag = unused_type>
- struct uint_generator;
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename T = int, unsigned Radix = 10, bool ForceSign = false>
- struct int_spec;
-
- template <typename T = unsigned int, unsigned Radix = 10,
- bool ForceSign = false>
- struct uint_spec;
-
- ///////////////////////////////////////////////////////////////////////////
- template <bool IsLiteral, typename T, typename RealPolicies,
- typename Tag = unused_type>
- struct real_generator;
-
- template <typename T>
- struct real_generator_policies;
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename T = double,
- typename RealPolicies = real_generator_policies<T> >
- struct real_spec;
-
-}}} // namespace boost::spirit::karma
-
-#endif
-
-

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,242 +6,403 @@
 #if !defined(BOOST_SPIRIT_KARMA_REAL_FEB_26_2007_0512PM)
 #define BOOST_SPIRIT_KARMA_REAL_FEB_26_2007_0512PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
+#include <boost/config/no_tr1/cmath.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/char_class.hpp>
-#include <boost/spirit/home/support/modifier.hpp>
+#include <boost/spirit/home/support/detail/get_encoding.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/char.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/karma/detail/get_casetag.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
 #include <boost/spirit/home/karma/numeric/real_policies.hpp>
-#include <boost/spirit/home/karma/char.hpp>
-#include <boost/spirit/home/karma/numeric/int.hpp>
-#include <boost/spirit/home/karma/numeric/detail/numeric_utils.hpp>
-#include <boost/config/no_tr1/cmath.hpp>
+#include <boost/spirit/home/karma/numeric/detail/real_utils.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/fusion/include/value_at.hpp>
+#include <boost/fusion/include/vector.hpp>
 
-namespace boost { namespace spirit { namespace karma
+namespace boost { namespace spirit
 {
- namespace detail
+ namespace tag
+ {
+ template <typename T, typename Policies>
+ struct real_tag
+ {
+ real_tag() {}
+ real_tag(Policies const& policies)
+ : policies_(policies) {}
+
+ Policies policies_;
+ };
+ }
+
+ namespace karma
     {
- template <typename RealPolicies>
- struct real_policy;
+ ///////////////////////////////////////////////////////////////////////
+ // This one is the class that the user can instantiate directly in
+ // order to create a customized real generator
+ template <typename T = double, typename Policies = real_policies<T> >
+ struct real_generator
+ : spirit::terminal<tag::real_tag<T, Policies> >
+ {
+ real_generator() {}
+ real_generator(Policies const& p)
+ : spirit::terminal<tag::real_tag<T, Policies> >(p) {}
+ };
     }
 
     ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, tag::float_> // enables float_
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::double_> // enables double_
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::long_double> // enables long_double
+ : mpl::true_ {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, float> // enables lit(1.of)
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, double> // enables lit(1.0)
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, long double> // enables lit(1.0l)
+ : mpl::true_ {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename A0>
+ struct use_terminal<karma::domain // enables float_(...)
+ , terminal_ex<tag::float_, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables double_(...)
+ , terminal_ex<tag::double_, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables long_double(...)
+ , terminal_ex<tag::long_double, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ // lazy float_(...), double_(...), long_double(...)
+ template <>
+ struct use_lazy_terminal<karma::domain, tag::float_, 1>
+ : mpl::true_ {};
+
+ template <>
+ struct use_lazy_terminal<karma::domain, tag::double_, 1>
+ : mpl::true_ {};
+
+ template <>
+ struct use_lazy_terminal<karma::domain, tag::long_double, 1>
+ : mpl::true_ {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ // enables custom real generator
+ template <typename T, typename Policy>
+ struct use_terminal<karma::domain, tag::real_tag<T, Policy> >
+ : mpl::true_ {};
+
+ template <typename T, typename Policy, typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::real_tag<T, Policy>, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ // enables *lazy* custom real generator
+ template <typename T, typename Policy>
+ struct use_lazy_terminal<
+ karma::domain
+ , tag::real_tag<T, Policy>
+ , 1 // arity
+ > : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace karma
+{
+ using spirit::float_;
+ using spirit::float__type;
+ using spirit::double_;
+ using spirit::double__type;
+ using spirit::long_double;
+ using spirit::long_double_type;
+
+ ///////////////////////////////////////////////////////////////////////////
     // This specialization is used for real generators not having a direct
     // initializer: float_, double_ etc. These generators must be used in
- // conjunction with a parameter.
+ // conjunction with an attribute.
     ///////////////////////////////////////////////////////////////////////////
- template <typename T, typename RealPolicies, typename Tag>
- struct real_generator<false, T, RealPolicies, Tag>
+ template <
+ typename T, typename Policies, typename CharEncoding, typename Tag>
+ struct any_real_generator
+ : primitive_generator<any_real_generator<T, Policies, CharEncoding, Tag> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef typename Policies::properties properties;
+
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef T type;
         };
 
- // double_/float_/etc. has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
- {
- RealPolicies const& p =
- detail::real_policy<RealPolicies>::get(spirit::subject(component));
-
- bool result = real_inserter<T, RealPolicies, Tag>::
- call(sink, param, p);
+ any_real_generator(Policies const& policies = Policies())
+ : p_(policies) {}
 
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ // double_/float_/etc. has an attached attribute
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
+ return inserter_type::call(sink, attr, p_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- // this double_/float_/etc. has no parameter attached, it needs to have
+ // this double_/float_/etc. has no attribute attached, it needs to have
         // been initialized from a direct literal
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
- static bool
- generate(Component const&, OutputIterator&, Context&, Delimiter const&,
- unused_type)
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ static bool generate(OutputIterator&, Context&, Delimiter const&
+ , unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false, real_not_usable_without_attribute,
- (Component, Context));
+ BOOST_SPIRIT_ASSERT_MSG(false, real_not_usable_without_attribute, ());
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& /*component*/, Context const& /*ctx*/)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
- return "real number";
+ return info("real");
         }
+
+ Policies p_;
     };
 
     ///////////////////////////////////////////////////////////////////////////
     // This specialization is used for real generators having a direct
     // initializer: float_(10.), double_(20.) etc.
     ///////////////////////////////////////////////////////////////////////////
- template <typename T, typename RealPolicies, typename Tag>
- struct real_generator<true, T, RealPolicies, Tag>
+ template <
+ typename T, typename Policies, typename CharEncoding, typename Tag
+ , bool no_attribute>
+ struct literal_real_generator
+ : primitive_generator<literal_real_generator<T, Policies, CharEncoding
+ , Tag, no_attribute> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef typename Policies::properties properties;
+
+ template <typename Context, typename Unused>
         struct attribute
- {
- typedef unused_type type;
- };
+ : mpl::if_c<no_attribute, unused_type, T>
+ {};
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
- {
- RealPolicies const& p = detail::real_policy<RealPolicies>::get(
- fusion::at_c<0>(component.elements));
- T n = fusion::at_c<1>(component.elements);
- bool result = real_inserter<T, RealPolicies, Tag>::call(sink, n, p);
+ literal_real_generator(typename add_const<T>::type n
+ , Policies const& policies = Policies())
+ : n_(n), p_(policies) {}
+
+ // A double_(1.0) which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ if (n_ != attr)
+ return false;
+
+ typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
+ return inserter_type::call(sink, n_, p_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
 
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ // A double_(1.0) without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
+ {
+ typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
+ return inserter_type::call(sink, n_, p_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& /*component*/, Context const& /*ctx*/)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
- return "real number";
+ return info("real");
         }
+
+ T n_;
+ Policies p_;
     };
 
-}}}
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ // extract policies if this is a real_tag
+ template <typename Policies>
+ struct get_policies
+ {
+ template <typename Tag>
+ static Policies call(Tag) { return Policies(); }
+
+ template <typename T>
+ static Policies const& call(tag::real_tag<T, Policies> const& p)
+ { return p.policies_; }
+ };
+ }
 
-namespace boost { namespace spirit { namespace traits
-{
     ///////////////////////////////////////////////////////////////////////////
- // lower_case real generator
+ // Generator generators: make_xxx function (objects)
     ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename T, typename RealPolicies, typename Tag>
- struct make_modified_component<
- Domain, karma::real_generator<false, T, RealPolicies, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::lower char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- real_policy_type;
- typedef fusion::vector<real_policy_type> vector_type;
-
- typedef karma::real_generator<false, T, RealPolicies, key_tag> real_type;
- typedef component<karma::domain, real_type, vector_type> type;
+ template <
+ typename T, typename Modifiers, typename Policies = real_policies<T> >
+ struct make_real
+ {
+ 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 any_real_generator<
+ T, Policies
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ > result_type;
 
- static type
- call(Elements const& elements)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return type(elements);
+ using karma::detail::get_policies;
+ return result_type(get_policies<Policies>::call(term));
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename T, typename RealPolicies, typename Tag>
- struct make_modified_component<
- Domain, karma::real_generator<true, T, RealPolicies, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::lower char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- real_policy_type;
- typedef typename
- fusion::result_of::value_at_c<Elements, 1>::type
- real_data_type;
- typedef fusion::vector<real_policy_type, real_data_type> vector_type;
-
- typedef karma::real_generator<true, T, RealPolicies, key_tag> real_type;
- typedef component<karma::domain, real_type, vector_type> type;
-
- static type
- call(Elements const& elements)
- {
- return type(elements);
- }
- };
+ template <typename Modifiers>
+ struct make_primitive<tag::float_, Modifiers>
+ : make_real<float, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::double_, Modifiers>
+ : make_real<double, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::long_double, Modifiers>
+ : make_real<long double, Modifiers> {};
 
     ///////////////////////////////////////////////////////////////////////////
- // lower_case real generator
- ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename T, typename RealPolicies, typename Tag>
- struct make_modified_component<
- Domain, karma::real_generator<false, T, RealPolicies, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::upper char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- real_policy_type;
- typedef fusion::vector<real_policy_type> vector_type;
+ template <typename T, typename Policy, typename Modifiers>
+ struct make_primitive<tag::real_tag<T, Policy>, Modifiers>
+ : make_real<T, Modifiers, Policy> {};
 
- typedef karma::real_generator<false, T, RealPolicies, key_tag> real_type;
- typedef component<karma::domain, real_type, vector_type> type;
+ ///////////////////////////////////////////////////////////////////////////
+ template <
+ typename T, typename Modifiers, typename Policies = real_policies<T> >
+ struct make_real_direct
+ {
+ 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 literal_real_generator<
+ T, Policies
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , false
+ > result_type;
 
- static type
- call(Elements const& elements)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return type(elements);
+ return result_type(fusion::at_c<0>(term.args)
+ , karma::detail::get_policies<Policies>::call(term.term));
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename T, typename RealPolicies, typename Tag>
- struct make_modified_component<
- Domain, karma::real_generator<true, T, RealPolicies, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::upper char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- real_policy_type;
- typedef typename
- fusion::result_of::value_at_c<Elements, 1>::type
- real_data_type;
- typedef fusion::vector<real_policy_type, real_data_type> vector_type;
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::float_, fusion::vector1<A0> >, Modifiers>
+ : make_real_direct<float, Modifiers> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::double_, fusion::vector1<A0> >, Modifiers>
+ : make_real_direct<double, Modifiers> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::long_double, fusion::vector1<A0> >, Modifiers>
+ : make_real_direct<long double, Modifiers> {};
 
- typedef karma::real_generator<true, T, RealPolicies, key_tag> real_type;
- typedef component<karma::domain, real_type, vector_type> type;
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T, typename Policy, typename A0, typename Modifiers>
+ struct make_primitive<
+ terminal_ex<tag::real_tag<T, Policy>, fusion::vector1<A0> >
+ , Modifiers>
+ : make_real_direct<T, Modifiers, Policy> {};
 
- static type
- call(Elements const& elements)
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ template <typename T, typename Modifiers>
+ struct basic_real_literal
         {
- return type(elements);
- }
- };
+ 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 literal_real_generator<
+ T, real_policies<T>
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , true
+ > result_type;
+
+ template <typename T_>
+ result_type operator()(T_ i, unused_type) const
+ {
+ return result_type(i);
+ }
+ };
+ }
+
+ template <typename Modifiers>
+ struct make_primitive<float, Modifiers>
+ : detail::basic_real_literal<float, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<double, Modifiers>
+ : detail::basic_real_literal<double, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<long double, Modifiers>
+ : detail::basic_real_literal<long double, Modifiers> {};
 
-}}} // namespace boost::spirit::traits
+}}}
 
 #endif // defined(BOOST_SPIRIT_KARMA_REAL_FEB_26_2007_0512PM)

Modified: branches/release/boost/spirit/home/karma/numeric/real_policies.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/numeric/real_policies.hpp (original)
+++ branches/release/boost/spirit/home/karma/numeric/real_policies.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,67 +6,123 @@
 #if !defined(BOOST_SPIRIT_KARMA_REAL_POLICIES_MAR_02_2007_0936AM)
 #define BOOST_SPIRIT_KARMA_REAL_POLICIES_MAR_02_2007_0936AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
+#include <boost/config/no_tr1/cmath.hpp>
+#include <boost/math/special_functions/fpclassify.hpp>
+
 #include <boost/spirit/home/support/char_class.hpp>
 #include <boost/spirit/home/karma/generate.hpp>
 #include <boost/spirit/home/karma/char.hpp>
 #include <boost/spirit/home/karma/numeric/int.hpp>
-#include <boost/config/no_tr1/cmath.hpp>
-#include <boost/spirit/home/support/detail/math/fpclassify.hpp>
+#include <boost/spirit/home/karma/numeric/detail/real_utils.hpp>
+
+#include <boost/mpl/bool.hpp>
 
 namespace boost { namespace spirit { namespace karma
 {
     ///////////////////////////////////////////////////////////////////////////
     //
- // real_generator_policies, if you need special handling of your floating
+ // real_policies, if you need special handling of your floating
     // point numbers, just overload this policy class and use it as a template
- // parameter to the karma::real_spec floating point specifier:
+ // parameter to the karma::real_generator floating point specifier:
     //
     // template <typename T>
- // struct scientific_policy : karma::real_generator_policies<T>
+ // struct scientific_policy : karma::real_policies<T>
     // {
     // // we want the numbers always to be in scientific format
- // static int floatfield(T n) { return scientific; }
+ // static int floatfield(T n) { return fmtflags::scientific; }
     // };
     //
     // typedef
- // karma::real_spec<double, scientific_policy<double> >
+ // karma::real_generator<double, scientific_policy<double> >
     // science_type;
     //
     // karma::generate(sink, science_type(), 1.0); // will output: 1.0e00
     //
     ///////////////////////////////////////////////////////////////////////////
     template <typename T>
- struct real_generator_policies
+ struct real_policies
     {
         ///////////////////////////////////////////////////////////////////////
+ // Expose the data type the generator is targeted to
+ ///////////////////////////////////////////////////////////////////////
+ typedef T value_type;
+
+ ///////////////////////////////////////////////////////////////////////
+ // By default the policy doesn't require any special iterator
+ // functionality. The floating point generator exposes its properties
+ // from here, so this needs to be updated in case other properties
+ // need to be implemented.
+ ///////////////////////////////////////////////////////////////////////
+ typedef mpl::int_<generator_properties::no_properties> properties;
+
+ ///////////////////////////////////////////////////////////////////////
         // Specifies, which representation type to use during output
         // generation.
         ///////////////////////////////////////////////////////////////////////
- enum fmtflags
+ struct fmtflags
         {
- scientific = 0, // Generate floating-point values in scientific
- // format (with an exponent field).
- fixed = 1 // Generate floating-point values in fixed-point
- // format (with no exponent field).
+ enum {
+ scientific = 0, // Generate floating-point values in scientific
+ // format (with an exponent field).
+ fixed = 1 // Generate floating-point values in fixed-point
+ // format (with no exponent field).
+ };
         };
-
+
+ ///////////////////////////////////////////////////////////////////////
+ // This is the main function used to generate the output for a
+ // floating point number. It is called by the real generator in order
+ // to perform the conversion. In theory all of the work can be
+ // implemented here, but it is the easiest to use existing
+ // functionality provided by the type specified by the template
+ // parameter `Inserter`.
+ //
+ // sink: the output iterator to use for generation
+ // n: the floating point number to convert
+ // p: the instance of the policy type used to instantiate this
+ // floating point generator.
+ ///////////////////////////////////////////////////////////////////////
+ template <typename Inserter, typename OutputIterator, typename Policies>
+ static bool
+ call (OutputIterator& sink, T n, Policies const& p)
+ {
+ return Inserter::call_n(sink, n, p);
+ }
+
         ///////////////////////////////////////////////////////////////////////
         // The default behavior is to not to require generating a sign. If
- // 'force_sign' is specified as true, then all generated numbers will
+ // 'force_sign()' returns true, then all generated numbers will
         // have a sign ('+' or '-', zeros will have a space instead of a sign)
+ //
+ // n The floating point number to output. This can be used to
+ // adjust the required behavior depending on the value of
+ // this number.
         ///////////////////////////////////////////////////////////////////////
- static bool const force_sign = false;
-
+ static bool const force_sign(T)
+ {
+ return false;
+ }
+
         ///////////////////////////////////////////////////////////////////////
- // The 'trailing_zeros' flag instructs the floating point generator to
- // emit trailing zeros up to the required precision digits.
+ // Return whether trailing zero digits have to be emitted in the
+ // fractional part of the output. If set, this flag instructs the
+ // floating point generator to emit trailing zeros up to the required
+ // precision digits (as returned by the precision() function).
+ //
+ // n The floating point number to output. This can be used to
+ // adjust the required behavior depending on the value of
+ // this number.
         ///////////////////////////////////////////////////////////////////////
- static bool const trailing_zeros = false;
-
+ static bool trailing_zeros(T)
+ {
+ // the default behavior is not to generate trailing zeros
+ return false;
+ }
+
         ///////////////////////////////////////////////////////////////////////
         // Decide, which representation type to use in the generated output.
         //
@@ -74,39 +130,25 @@
         // between 0.001 and 100000 will be generated using the fixed format,
         // all others will be generated using the scientific representation.
         //
- // The trailing_zeros flag can be used to force the output of trailing
- // zeros in the fractional part up to the number of digits returned by
- // the precision() member function. The default is not to generate
- // the trailing zeros.
+ // The function trailing_zeros() can be used to force the output of
+ // trailing zeros in the fractional part up to the number of digits
+ // returned by the precision() member function. The default is not to
+ // generate the trailing zeros.
         //
         // n The floating point number to output. This can be used to
         // adjust the formatting flags depending on the value of
         // this number.
         ///////////////////////////////////////////////////////////////////////
- static int
- floatfield(T n)
+ static int floatfield(T n)
         {
             if (detail::is_zero(n))
- return fixed;
+ return fmtflags::fixed;
 
             T abs_n = detail::absolute_value(n);
- return (abs_n >= 1e5 || abs_n < 1e-3) ? scientific : fixed;
+ return (abs_n >= 1e5 || abs_n < 1e-3)
+ ? fmtflags::scientific : fmtflags::fixed;
         }
-
- ///////////////////////////////////////////////////////////////////////
- // The 'fractional_precision' constant specifies the default number of
- // digits to generate for the fractional part of a floating point
- // number. This is used by this (default) policies implementation
- // only. If you need another fractional precision you'll have to
- // overload the precision function below.
- //
- // Note: The actual number of digits for a floating point number is
- // determined by the precision() function below. This allows to
- // have different precisions depending on the value of the
- // floating point number.
- ///////////////////////////////////////////////////////////////////////
- static unsigned int const fractional_precision = 3;
-
+
         ///////////////////////////////////////////////////////////////////////
         // Return the maximum number of decimal digits to generate in the
         // fractional part of the output.
@@ -122,30 +164,32 @@
         // function below. Moreover, this precision will be limited
         // to the value of std::numeric_limits<T>::digits10 + 1
         ///////////////////////////////////////////////////////////////////////
- static unsigned int
- precision(T)
+ static unsigned precision(T)
         {
- // generate max. 'fractional_precision' fractional digits
- return fractional_precision;
+ // by default, generate max. 3 fractional digits
+ return 3;
         }
 
         ///////////////////////////////////////////////////////////////////////
         // Generate the integer part of the number.
         //
- // sink The output iterator to use for generation
- // n The absolute value of the integer part of the floating
- // point number to convert (always non-negative).
- // sign The sign of the overall floating point number to convert.
+ // sink The output iterator to use for generation
+ // n The absolute value of the integer part of the floating
+ // point number to convert (always non-negative).
+ // sign The sign of the overall floating point number to
+ // convert.
+ // force_sign Whether a sign has to be generated even for
+ // non-negative numbers
         ///////////////////////////////////////////////////////////////////////
- template <bool ForceSign, typename OutputIterator>
- static bool
- integer_part (OutputIterator& sink, T n, bool sign)
+ template <typename OutputIterator>
+ static bool integer_part (OutputIterator& sink, T n, bool sign
+ , bool force_sign)
         {
- return sign_inserter<ForceSign>::call(
- sink, detail::is_zero(n), sign) &&
+ return sign_inserter::call(
+ sink, detail::is_zero(n), sign, force_sign) &&
                    int_inserter<10>::call(sink, n);
         }
-
+
         ///////////////////////////////////////////////////////////////////////
         // Generate the decimal point.
         //
@@ -156,6 +200,8 @@
         // to the value returned from the precision() function
         // earlier. I.e. a fractional part of 0.01234 is
         // represented as 1234 when the 'Precision' is 5.
+ // precision The number of digits to emit as returned by the
+ // function 'precision()' above
         //
         // This is given to allow to decide, whether a decimal point
         // has to be generated at all.
@@ -165,12 +211,11 @@
         // function below.
         ///////////////////////////////////////////////////////////////////////
         template <typename OutputIterator>
- static bool
- dot (OutputIterator& sink, T)
+ static bool dot (OutputIterator& sink, T /*n*/, unsigned /*precision*/)
         {
             return char_inserter<>::call(sink, '.'); // generate the dot by default
         }
-
+
         ///////////////////////////////////////////////////////////////////////
         // Generate the fractional part of the number.
         //
@@ -180,14 +225,17 @@
         // the number of units which correspond to the 'Precision'.
         // I.e. a fractional part of 0.01234 is represented as 1234
         // when the 'precision_' parameter is 5.
- //
- // Note: If the trailing_zeros flag is not returned from the
- // floatfield() function, the 'precision_' parameter will have
- // been corrected from the value the precision() function
- // returned earlier (defining the maximal number of fractional
- // digits) in the sense, that it takes into account trailing
- // zeros. I.e. a floating point number 0.0123 and a value of 5
- // returned from precision() will result in:
+ // precision_ The corrected number of digits to emit (see note
+ // below)
+ // precision The number of digits to emit as returned by the
+ // function 'precision()' above
+ //
+ // Note: If trailing_zeros() does not return true the 'precision_'
+ // parameter will have been corrected from the value the
+ // precision() function returned earlier (defining the maximal
+ // number of fractional digits) in the sense, that it takes into
+ // account trailing zeros. I.e. a floating point number 0.0123
+ // and a value of 5 returned from precision() will result in:
         //
         // trailing_zeros is not specified:
         // n 123
@@ -199,8 +247,8 @@
         //
         ///////////////////////////////////////////////////////////////////////
         template <typename OutputIterator>
- static bool
- fraction_part (OutputIterator& sink, T n, unsigned precision_)
+ static bool fraction_part (OutputIterator& sink, T n
+ , unsigned precision_, unsigned precision)
         {
             // allow for ADL to find the correct overload for floor and log10
             using namespace std;
@@ -208,12 +256,14 @@
             // The following is equivalent to:
             // generate(sink, right_align(precision, '0')[ulong], n);
             // but it's spelled out to avoid inter-modular dependencies.
-
+
             T digits = (detail::is_zero(n) ? 0 : floor(log10(n))) + 1;
             bool r = true;
             for (/**/; r && digits < precision_; digits = digits + 1)
                 r = char_inserter<>::call(sink, '0');
- return r && int_inserter<10>::call(sink, n);
+ if (precision && r)
+ r = int_inserter<10>::call(sink, n);
+ return r;
         }
 
         ///////////////////////////////////////////////////////////////////////
@@ -229,18 +279,17 @@
         // output possibly influenced by either the lower[...] or upper[...]
         // directives.
         ///////////////////////////////////////////////////////////////////////
- template <typename Tag, typename OutputIterator>
- static bool
- exponent (OutputIterator& sink, T n)
+ template <typename CharEncoding, typename Tag, typename OutputIterator>
+ static bool exponent (OutputIterator& sink, long n)
         {
- T abs_n = detail::absolute_value(n);
- bool r = char_inserter<Tag>::call(sink, 'e') &&
- sign_inserter<false>::call(
- sink, detail::is_zero(n), detail::is_negative(n));
+ long abs_n = detail::absolute_value(n);
+ bool r = char_inserter<CharEncoding, Tag>::call(sink, 'e') &&
+ sign_inserter::call(sink, detail::is_zero(n)
+ , detail::is_negative(n), false);
 
             // the C99 Standard requires at least two digits in the exponent
             if (r && abs_n < 10)
- r = char_inserter<Tag>::call(sink, '0');
+ r = char_inserter<CharEncoding, Tag>::call(sink, '0');
             return r && int_inserter<10>::call(sink, abs_n);
         }
 
@@ -248,9 +297,11 @@
         // Print the textual representations for non-normal floats (NaN and
         // Inf)
         //
- // sink The output iterator to use for generation
- // n The (signed) floating point number to convert.
- //
+ // sink The output iterator to use for generation
+ // n The (signed) floating point number to convert.
+ // force_sign Whether a sign has to be generated even for
+ // non-negative numbers
+ //
         // The Tag template parameter is either of the type unused_type or
         // describes the character class and conversion to be applied to any
         // output possibly influenced by either the lower[...] or upper[...]
@@ -259,25 +310,23 @@
         // Note: These functions get called only if fpclassify() returned
         // FP_INFINITY or FP_NAN.
         ///////////////////////////////////////////////////////////////////////
- template <bool ForceSign, typename Tag, typename OutputIterator>
- static bool
- nan (OutputIterator& sink, T n)
- {
- return sign_inserter<ForceSign>::call(
- sink, false, detail::is_negative(n)) &&
- string_inserter<Tag>::call(sink, "nan");
- }
-
- template <bool ForceSign, typename Tag, typename OutputIterator>
- static bool
- inf (OutputIterator& sink, T n)
- {
- return sign_inserter<ForceSign>::call(
- sink, false, detail::is_negative(n)) &&
- string_inserter<Tag>::call(sink, "inf");
+ template <typename CharEncoding, typename Tag, typename OutputIterator>
+ static bool nan (OutputIterator& sink, T n, bool force_sign)
+ {
+ return sign_inserter::call(
+ sink, false, detail::is_negative(n), force_sign) &&
+ string_inserter<CharEncoding, Tag>::call(sink, "nan");
+ }
+
+ template <typename CharEncoding, typename Tag, typename OutputIterator>
+ static bool inf (OutputIterator& sink, T n, bool force_sign)
+ {
+ return sign_inserter::call(
+ sink, false, detail::is_negative(n), force_sign) &&
+ string_inserter<CharEncoding, Tag>::call(sink, "inf");
         }
     };
-
+
 }}}
 
 #endif // defined(BOOST_SPIRIT_KARMA_REAL_POLICIES_MAR_02_2007_0936AM)

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,219 +6,494 @@
 #if !defined(BOOST_SPIRIT_KARMA_UINT_FEB_23_2007_0840PM)
 #define BOOST_SPIRIT_KARMA_UINT_FEB_23_2007_0840PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <limits>
 
-#include <boost/spirit/home/support/modifier.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/char_class.hpp>
+#include <boost/spirit/home/support/detail/get_encoding.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/karma/detail/get_casetag.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
-#include <boost/spirit/home/karma/numeric/numeric_fwd.hpp>
 #include <boost/spirit/home/karma/numeric/detail/numeric_utils.hpp>
 #include <boost/fusion/include/at.hpp>
 #include <boost/fusion/include/value_at.hpp>
-#include <boost/mpl/assert.hpp>
+#include <boost/fusion/include/vector.hpp>
 
+namespace boost { namespace spirit
+{
+ namespace tag
+ {
+ template <typename T, unsigned Radix>
+ struct uint_tag {};
+ }
+
+ namespace karma
+ {
+ ///////////////////////////////////////////////////////////////////////
+ // This one is the class that the user can instantiate directly in
+ // order to create a customized int generator
+ template <typename T = unsigned int, unsigned Radix = 10>
+ struct uint_generator
+ : spirit::terminal<tag::uint_tag<T, Radix> >
+ {};
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, tag::ushort_> // enables ushort_
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::uint_> // enables uint_
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::ulong_> // enables ulong_
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::bin> // enables bin
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::oct> // enables oct
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::hex> // enables hex
+ : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <>
+ struct use_terminal<karma::domain, tag::ulong_long> // enables ulong_long
+ : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <> // enables lit(unsigned short(0))
+ struct use_terminal<karma::domain, unsigned short>
+ : mpl::true_ {};
+
+ template <> // enables lit(0U)
+ struct use_terminal<karma::domain, unsigned int>
+ : mpl::true_ {};
+
+ template <> // enables lit(0UL)
+ struct use_terminal<karma::domain, unsigned long>
+ : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <> // enables lit(0ULL)
+ struct use_terminal<karma::domain, boost::ulong_long_type>
+ : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename A0>
+ struct use_terminal<karma::domain // enables ushort_(...)
+ , terminal_ex<tag::ushort_, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables uint_(...)
+ , terminal_ex<tag::uint_, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables ulong_(...)
+ , terminal_ex<tag::ulong_, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables bin(...)
+ , terminal_ex<tag::bin, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables oct(...)
+ , terminal_ex<tag::oct, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables hex(...)
+ , terminal_ex<tag::hex, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename A0>
+ struct use_terminal<karma::domain // enables ulong_long(...)
+ , terminal_ex<tag::ulong_long, fusion::vector1<A0> >
+ > : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <> // enables *lazy* ushort_(...)
+ struct use_lazy_terminal<karma::domain, tag::ushort_, 1>
+ : mpl::true_ {};
+
+ template <> // enables *lazy* uint_(...)
+ struct use_lazy_terminal<karma::domain, tag::uint_, 1>
+ : mpl::true_ {};
+
+ template <> // enables *lazy* ulong_(...)
+ struct use_lazy_terminal<karma::domain, tag::ulong_, 1>
+ : mpl::true_ {};
+
+ template <> // enables *lazy* bin(...)
+ struct use_lazy_terminal<karma::domain, tag::bin, 1>
+ : mpl::true_ {};
+
+ template <> // enables *lazy* oct(...)
+ struct use_lazy_terminal<karma::domain, tag::oct, 1>
+ : mpl::true_ {};
+
+ template <> // enables *lazy* hex(...)
+ struct use_lazy_terminal<karma::domain, tag::hex, 1>
+ : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <> // enables *lazy* ulong_long(...)
+ struct use_lazy_terminal<karma::domain, tag::ulong_long, 1>
+ : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ // enables any custom uint_generator
+ template <typename T, unsigned Radix>
+ struct use_terminal<karma::domain, tag::uint_tag<T, Radix> >
+ : mpl::true_ {};
+
+ // enables any custom uint_generator(...)
+ template <typename T, unsigned Radix, typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::uint_tag<T, Radix>, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ // enables *lazy* custom uint_generator
+ template <typename T, unsigned Radix>
+ struct use_lazy_terminal<
+ karma::domain
+ , tag::uint_tag<T, Radix>
+ , 1 // arity
+ > : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
- template <typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct uint_generator<false, T, Radix, ForceSign, Tag>
+ using spirit::ushort_;
+ using spirit::ushort__type;
+ using spirit::uint_;
+ using spirit::uint__type;
+ using spirit::ulong_;
+ using spirit::ulong__type;
+#ifdef BOOST_HAS_LONG_LONG
+ using spirit::ulong_long;
+ using spirit::ulong_long_type;
+#endif
+ using spirit::bin;
+ using spirit::bin_type;
+ using spirit::oct;
+ using spirit::oct_type;
+ using spirit::hex;
+ using spirit::hex_type;
+
+ using spirit::lit; // lit(1U) is equivalent to 1U
+
+ ///////////////////////////////////////////////////////////////////////////
+ // This specialization is used for unsigned int generators not having a
+ // direct initializer: uint_, ulong_ etc. These generators must be used in
+ // conjunction with an Attribute.
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T, typename CharEncoding, typename Tag, unsigned Radix>
+ struct any_uint_generator
+ : primitive_generator<any_uint_generator<T, CharEncoding, Tag, Radix> >
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef T type;
         };
 
- // check template parameter 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ // check template Attribute 'Radix' for validity
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
- BOOST_MPL_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
+ BOOST_SPIRIT_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
             signed_unsigned_mismatch, ());
 
- // uint has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
+ // int has a Attribute attached
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
         static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
+ generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr)
         {
- bool result = int_inserter<Radix, Tag>::call(sink, param);
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ return int_inserter<Radix, CharEncoding, Tag>::call(sink, attr) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- // this uint has no parameter attached, it needs to have been
+ // this int has no Attribute attached, it needs to have been
         // initialized from a direct literal
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
+ template <typename OutputIterator, typename Context, typename Delimiter>
         static bool
- generate(Component const&, OutputIterator&, Context&, Delimiter const&,
- unused_type)
+ generate(OutputIterator&, Context&, Delimiter const&, unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false, uint_not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, uint_not_usable_without_attribute, ());
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
- return "unsigned integer";
+ return info("unsigned-integer");
         }
     };
 
- template <typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct uint_generator<true, T, Radix, ForceSign, Tag>
+ ///////////////////////////////////////////////////////////////////////////
+ // This specialization is used for unsigned int generators having a direct
+ // initializer: uint_(10), ulong_(20) etc.
+ ///////////////////////////////////////////////////////////////////////////
+ template <
+ typename T, typename CharEncoding, typename Tag, unsigned Radix
+ , bool no_attribute>
+ struct literal_uint_generator
+ : primitive_generator<literal_uint_generator<T, CharEncoding, Tag, Radix
+ , no_attribute> >
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
- {
- typedef unused_type type;
- };
+ : mpl::if_c<no_attribute, unused_type, T>
+ {};
 
- // check template parameter 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ literal_uint_generator(typename add_const<T>::type n)
+ : n_(n) {}
+
+ // check template Attribute 'Radix' for validity
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
- BOOST_MPL_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
+ BOOST_SPIRIT_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
             signed_unsigned_mismatch, ());
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
+ // A uint(1U) which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
+ template <typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
         {
- T n = fusion::at_c<0>(component.elements);
- bool result = int_inserter<Radix, Tag>::call(sink, n);
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ if (n_ != attr)
+ return false;
+
+ return int_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ // A uint(1U) without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
         {
- return "unsigned integer";
+ return int_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
- };
 
-}}}
-
-namespace boost { namespace spirit { namespace traits
-{
- ///////////////////////////////////////////////////////////////////////////
- // lower_case int_ generator
- ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct make_modified_component<
- Domain, karma::uint_generator<false, T, Radix, ForceSign, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::lower char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef karma::uint_generator<false, T, Radix, ForceSign, key_tag> int_type;
- typedef component<karma::domain, int_type, fusion::nil> type;
-
- static type
- call(Elements const&)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
- return type(fusion::nil());
+ return info("unsigned-integer");
         }
- };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct make_modified_component<
- Domain, karma::uint_generator<true, T, Radix, ForceSign, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::lower char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- int_data_type;
- typedef fusion::vector<int_data_type> vector_type;
+ T n_;
+ };
 
- typedef karma::uint_generator<true, T, Radix, ForceSign, key_tag> int_type;
- typedef component<karma::domain, int_type, vector_type> type;
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T, typename Modifiers, unsigned Radix = 10>
+ struct make_uint
+ {
+ 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 any_uint_generator<
+ T
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , Radix
+ > result_type;
 
- static type
- call(Elements const& elements)
+ result_type operator()(unused_type, unused_type) const
         {
- return type(elements);
+ return result_type();
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////
- // upper_case int_ generator
- ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct make_modified_component<
- Domain, karma::uint_generator<false, T, Radix, ForceSign, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::upper char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
+ template <typename Modifiers>
+ struct make_primitive<tag::ushort_, Modifiers>
+ : make_uint<unsigned short, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::uint_, Modifiers>
+ : make_uint<unsigned int, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::ulong_, Modifiers>
+ : make_uint<unsigned long, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::bin, Modifiers>
+ : make_uint<unsigned, Modifiers, 2> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::oct, Modifiers>
+ : make_uint<unsigned, Modifiers, 8> {};
+
+ template <typename Modifiers>
+ struct make_primitive<tag::hex, Modifiers>
+ : make_uint<unsigned, Modifiers, 16> {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename Modifiers>
+ struct make_primitive<tag::ulong_long, Modifiers>
+ : make_uint<boost::ulong_long_type, Modifiers> {};
+#endif
 
- typedef karma::uint_generator<false, T, Radix, ForceSign, key_tag> int_type;
- typedef component<karma::domain, int_type, fusion::nil> type;
+ template <typename T, unsigned Radix, typename Modifiers>
+ struct make_primitive<tag::uint_tag<T, Radix>, Modifiers>
+ : make_uint<T, Modifiers, Radix> {};
 
- static type
- call(Elements const&)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T, typename Modifiers, unsigned Radix = 10>
+ struct make_uint_direct
+ {
+ 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 literal_uint_generator<
+ T
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , Radix, false
+ > result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return type(fusion::nil());
+ return result_type(fusion::at_c<0>(term.args));
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename T, unsigned Radix, bool ForceSign, typename Tag>
- struct make_modified_component<
- Domain, karma::uint_generator<true, T, Radix, ForceSign, Tag>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::upper char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef typename
- fusion::result_of::value_at_c<Elements, 0>::type
- int_data_type;
- typedef fusion::vector<int_data_type> vector_type;
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::ushort_, fusion::vector1<A0> >, Modifiers>
+ : make_uint_direct<unsigned short, Modifiers> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::uint_, fusion::vector1<A0> >, Modifiers>
+ : make_uint_direct<unsigned int, Modifiers> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::ulong_, fusion::vector1<A0> >, Modifiers>
+ : make_uint_direct<unsigned long, Modifiers> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::bin, fusion::vector1<A0> >, Modifiers>
+ : make_uint_direct<unsigned, Modifiers, 2> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::oct, fusion::vector1<A0> >, Modifiers>
+ : make_uint_direct<unsigned, Modifiers, 8> {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::hex, fusion::vector1<A0> >, Modifiers>
+ : make_uint_direct<unsigned, Modifiers, 16> {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::ulong_long, fusion::vector1<A0> >, Modifiers>
+ : make_uint_direct<boost::ulong_long_type, Modifiers> {};
+#endif
 
- typedef karma::uint_generator<true, T, Radix, ForceSign, key_tag> int_type;
- typedef component<karma::domain, int_type, vector_type> type;
+ template <typename T, unsigned Radix, typename A0, typename Modifiers>
+ struct make_primitive<
+ terminal_ex<tag::uint_tag<T, Radix>, fusion::vector1<A0> >
+ , Modifiers>
+ : make_uint_direct<T, Modifiers, Radix> {};
 
- static type
- call(Elements const& elements)
+ namespace detail
+ {
+ template <typename T, typename Modifiers>
+ struct basic_uint_literal
         {
- return type(elements);
- }
- };
+ 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 literal_uint_generator<
+ T
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , 10, true
+ > result_type;
+
+ template <typename T_>
+ result_type operator()(T_ i, unused_type) const
+ {
+ return result_type(i);
+ }
+ };
+ }
 
-}}} // namespace boost::spirit::traits
+ template <typename Modifiers>
+ struct make_primitive<unsigned short, Modifiers>
+ : detail::basic_uint_literal<unsigned short, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<unsigned int, Modifiers>
+ : detail::basic_uint_literal<unsigned int, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<unsigned long, Modifiers>
+ : detail::basic_uint_literal<unsigned long, Modifiers> {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename Modifiers>
+ struct make_primitive<boost::ulong_long_type, Modifiers>
+ : detail::basic_uint_literal<boost::ulong_long_type, Modifiers> {};
+#endif
+
+}}}
 
 #endif

Modified: branches/release/boost/spirit/home/karma/operator.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,16 +6,17 @@
 #if !defined(BOOST_SPIRIT_KARMA_OPERATOR_FEB_28_2007_0351PM)
 #define BOOST_SPIRIT_KARMA_OPERATOR_FEB_28_2007_0351PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/operator/sequence.hpp>
+#include <boost/spirit/home/karma/operator/and_predicate.hpp>
+#include <boost/spirit/home/karma/operator/not_predicate.hpp>
 #include <boost/spirit/home/karma/operator/alternative.hpp>
 #include <boost/spirit/home/karma/operator/kleene.hpp>
 #include <boost/spirit/home/karma/operator/plus.hpp>
 #include <boost/spirit/home/karma/operator/optional.hpp>
 #include <boost/spirit/home/karma/operator/list.hpp>
-#include <boost/spirit/home/karma/operator/meta_grammar.hpp>
 
 #endif

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,5 +1,5 @@
 // Copyright (c) 2001-2009 Hartmut Kaiser
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 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)
@@ -7,74 +7,134 @@
 #if !defined(SPIRIT_KARMA_ALTERNATIVE_MAR_01_2007_1117AM)
 #define SPIRIT_KARMA_ALTERNATIVE_MAR_01_2007_1117AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/karma/operator/detail/alternative.hpp>
-#include <boost/spirit/home/support/attribute_transform.hpp>
-#include <boost/spirit/home/support/as_variant.hpp>
-#include <boost/spirit/home/support/detail/what_function.hpp>
-#include <boost/spirit/home/support/algorithm/any.hpp>
+#include <boost/spirit/home/karma/detail/alternative_function.hpp>
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/unused.hpp>
-#include <boost/fusion/include/for_each.hpp>
+#include <boost/spirit/home/support/detail/what_function.hpp>
+#include <boost/fusion/include/any.hpp>
 #include <boost/fusion/include/mpl.hpp>
-#include <boost/fusion/include/transform.hpp>
-#include <boost/variant.hpp>
-#include <boost/mpl/vector.hpp>
-#include <boost/mpl/end.hpp>
-#include <boost/mpl/insert_range.hpp>
-#include <boost/mpl/transform_view.hpp>
+#include <boost/fusion/include/for_each.hpp>
+#include <boost/mpl/accumulate.hpp>
+#include <boost/mpl/bitor.hpp>
 
-namespace boost { namespace spirit { namespace karma
+namespace boost { namespace spirit
 {
- struct alternative
- {
- template <typename T>
- struct transform_child : mpl::identity<T> {};
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_operator<karma::domain, proto::tag::bitwise_or> // enables |
+ : mpl::true_ {};
+
+ template <>
+ struct flatten_tree<karma::domain, proto::tag::bitwise_or> // flattens |
+ : mpl::true_ {};
 
- template <typename All, typename Filtered>
- struct build_container
+}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace traits
+{
+ // specialization for sequences
+ template <typename Elements>
+ struct alternative_properties
+ {
+ struct element_properties
         {
- // Ok, now make a variant over the attribute_sequence. It's
- // a pity that make_variant_over does not support forward MPL
- // sequences. We use our own conversion metaprogram (as_variant).
- typedef typename
- as_variant<Filtered>::type
- type;
+ template <typename T>
+ struct result;
+
+ template <typename F, typename Element>
+ struct result<F(Element)>
+ {
+ typedef properties_of<Element> type;
+ };
+
+ // never called, but needed for decltype-based result_of (C++0x)
+ template <typename Element>
+ typename result<element_properties(Element)>::type
+ operator()(Element&) const;
         };
 
- template <typename Component, typename Context, typename Iterator>
- struct attribute :
- build_fusion_sequence<alternative, Component, Iterator, Context>
+ typedef typename mpl::accumulate<
+ typename fusion::result_of::transform<
+ Elements, element_properties>::type
+ , mpl::int_<karma::generator_properties::countingbuffer>
+ , mpl::bitor_<mpl::_2, mpl::_1>
+ >::type type;
+ };
+
+}}}
+
+namespace boost { namespace spirit { namespace karma
+{
+ template <typename Elements>
+ struct alternative : nary_generator<alternative<Elements> >
+ {
+ typedef typename traits::alternative_properties<Elements>::type
+ properties;
+
+ template <typename Context, typename Iterator = unused_type>
+ struct attribute
         {
+ // Put all the element attributes in a tuple
+ typedef typename traits::build_attribute_sequence<
+ Elements, Context, mpl::identity, Iterator
+ >::type all_attributes;
+
+ // Ok, now make a variant over the attribute sequence. Note that
+ // build_variant makes sure that 1) all attributes in the variant
+ // are unique 2) puts the unused attribute, if there is any, to
+ // the front and 3) collapses single element variants, variant<T>
+ // to T.
+ typedef typename traits::build_variant<all_attributes>::type type;
         };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ alternative(Elements const& elements)
+ : elements(elements) {}
+
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx
+ , Delimiter const& d, Attribute const& attr) const
         {
             typedef detail::alternative_generate_functor<
- OutputIterator, Context, Delimiter, Parameter
+ OutputIterator, Context, Delimiter, Attribute
> functor;
 
             // f return true if *any* of the parser succeeds
- functor f (sink, ctx, d, param);
- return fusion::any(component.elements, f);
+ functor f (sink, ctx, d, attr);
+ return fusion::any(elements, f);
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "alternatives[";
- fusion::for_each(component.elements,
- spirit::detail::what_function<Context>(result, ctx));
- result += "]";
+ info result("alternative");
+ fusion::for_each(elements,
+ spirit::detail::what_function<Context>(result, context));
             return result;
         }
+
+ Elements elements;
     };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Elements, typename Modifiers>
+ struct make_composite<proto::tag::bitwise_or, Elements, Modifiers>
+ : make_nary_composite<Elements, alternative>
+ {};
+
 }}}
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/operator/karma-alt.zip
==============================================================================
Binary file. No diff available.

Modified: branches/release/boost/spirit/home/karma/operator/kleene.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/kleene.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator/kleene.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 Joel de Guzman
 // Copyright (c) 2001-2009 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -7,86 +7,93 @@
 #if !defined(BOOST_SPIRIT_KARMA_KLEENE_MAR_03_2007_0337AM)
 #define BOOST_SPIRIT_KARMA_KLEENE_MAR_03_2007_0337AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/detail/container.hpp>
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/attribute_transform.hpp>
+#include <boost/spirit/home/support/container.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
 
-#include <vector>
+#include <boost/type_traits/add_const.hpp>
 
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_operator<karma::domain, proto::tag::dereference> // enables *g
+ : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
- struct kleene
+ template <typename Subject>
+ struct kleene : unary_generator<kleene<Subject> >
     {
- template <typename T>
- struct build_attribute_container
- {
- typedef std::vector<T> type;
- };
-
- template <typename Component, typename Context, typename Iterator>
- struct attribute :
- build_container<kleene, Component, Iterator, Context>
- {
- };
+ typedef Subject subject_type;
+ typedef typename subject_type::properties properties;
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ // Build a std::vector from the subject's attribute. Note
+ // that build_std_vector may return unused_type if the
+ // subject's attribute is an unused_type.
+ template <typename Context, typename Iterator>
+ struct attribute
+ : traits::build_std_vector<
+ typename traits::attribute_of<Subject, Context, Iterator>::type
+ >
+ {};
+
+ kleene(Subject const& subject)
+ : subject(subject) {}
+
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx
+ , Delimiter const& d, Attribute const& attr) const
         {
- typedef typename
- result_of::subject<Component>::type::director
- director;
- typedef typename
- container::result_of::iterator<Parameter const>::type
- iterator_type;
+ typedef typename traits::result_of::iterator<
+ typename add_const<Attribute>::type
+ >::type iterator_type;
 
- iterator_type it = container::begin(param);
- iterator_type end = container::end(param);
+ iterator_type it = traits::begin(attr);
+ iterator_type end = traits::end(attr);
 
- // kleene fails only if the embedded parser fails
+ // kleene fails only if the underlying output fails
             bool result = true;
- for (/**/; result && !container::compare(it, end);
- container::next(it))
+ for (/**/; result && !traits::compare(it, end); traits::next(it))
             {
- result = director::generate(subject(component), sink, ctx, d,
- container::deref(it));
+ result = subject.generate(sink, ctx, d, traits::deref(it));
             }
- return result;
+ return detail::sink_is_good(sink);
         }
 
- // this kleene has no parameter attached
-// template <typename Component, typename OutputIterator,
-// typename Context, typename Delimiter>
-// static bool
-// generate(Component const&, OutputIterator&, Context&, Delimiter const&,
-// unused_type)
-// {
-// BOOST_MPL_ASSERT_MSG(false, kleene_not_usable_without_attribute, ());
-// return false;
-// }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "kleene[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ return info("kleene", subject.what(context));
         }
+
+ Subject subject;
     };
 
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Elements, typename Modifiers>
+ struct make_composite<proto::tag::dereference, Elements, Modifiers>
+ : make_unary_composite<Elements, kleene>
+ {};
+
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/karma/operator/list.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/list.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator/list.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 Joel de Guzman
 // Copyright (c) 2001-2009 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -7,90 +7,101 @@
 #if !defined(SPIRIT_KARMA_LIST_MAY_01_2007_0229PM)
 #define SPIRIT_KARMA_LIST_MAY_01_2007_0229PM
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/detail/container.hpp>
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/attribute_transform.hpp>
+#include <boost/spirit/home/support/container.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
 
-#include <vector>
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_operator<karma::domain, proto::tag::modulus> // enables g % d
+ : mpl::true_ {};
+
+}}
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
- struct list
+ template <typename Left, typename Right>
+ struct list : binary_generator<list<Left, Right> >
     {
- template <typename T>
- struct build_attribute_container
- {
- typedef std::vector<T> type;
- };
+ typedef Left left_type;
+ typedef Right right_type;
 
- template <typename Component, typename Context, typename Iterator>
- struct attribute :
- build_container<list, Component, Iterator, Context>
+ typedef mpl::int_<
+ left_type::properties::value | right_type::properties::value
+ > properties;
+
+ // Build a std::vector from the LHS's attribute. Note
+ // that build_std_vector may return unused_type if the
+ // subject's attribute is an unused_type.
+ template <typename Context, typename Iterator>
+ struct attribute
+ : traits::build_std_vector<
+ typename traits::attribute_of<Left, Context, Iterator>::type
+ >
+ {};
+
+ list(Left const& left, Right const& right)
+ : left(left), right(right) {}
+
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx
+ , Delimiter const& d, Attribute const& attr) const
         {
- };
+ typedef typename traits::result_of::iterator<
+ typename add_const<Attribute>::type
+ >::type iterator_type;
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
- {
- typedef typename
- spirit::result_of::left<Component>::type::director
- ldirector;
-
- typedef typename
- spirit::result_of::right<Component>::type::director
- rdirector;
-
- typedef typename
- container::result_of::iterator<Parameter const>::type
- iterator_type;
-
- iterator_type it = container::begin(param);
- iterator_type end = container::end(param);
-
- bool result = !container::compare(it, end);
- if (result && ldirector::generate(
- spirit::left(component), sink, ctx, d, container::deref(it)))
+ iterator_type it = traits::begin(attr);
+ iterator_type end = traits::end(attr);
+
+ bool result = !traits::compare(it, end);
+ if (result && left.generate(sink, ctx, d, traits::deref(it)))
             {
- for (container::next(it); result && !container::compare(it, end);
- container::next(it))
+ for (traits::next(it); result && !traits::compare(it, end);
+ traits::next(it))
                 {
- result =
- rdirector::generate(
- spirit::right(component), sink, ctx, d, unused) &&
- ldirector::generate(
- spirit::left(component), sink, ctx, d, container::deref(it));
+ result = right.generate(sink, ctx, d, unused) &&
+ left.generate(sink, ctx, d, traits::deref(it));
                 }
                 return result;
             }
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "list[";
-
- typedef typename
- spirit::result_of::left<Component>::type::director
- ldirector;
-
- typedef typename
- spirit::result_of::right<Component>::type::director
- rdirector;
-
- result += ldirector::what(spirit::left(component), ctx);
- result += ", ";
- result += rdirector::what(spirit::right(component), ctx);
- result += "]";
- return result;
+ return info("list",
+ std::make_pair(left.what(context), right.what(context)));
         }
+
+ Left left;
+ Right right;
     };
 
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Elements, typename Modifiers>
+ struct make_composite<proto::tag::modulus, Elements, Modifiers>
+ : make_binary_composite<Elements, list>
+ {};
+
 }}}
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/operator/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,113 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_META_GRAMMAR_FEB_28_2007_0346PM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_FEB_28_2007_0346PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/utility/enable_if.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- struct sequence;
- struct alternative;
- struct kleene;
- struct plus;
- struct optional;
- struct list;
-
- struct main_meta_grammar;
-
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // operator meta-grammars
- ///////////////////////////////////////////////////////////////////////////
- struct sequence_meta_grammar
- : proto::or_<
- meta_grammar::binary_rule_flat<
- karma::domain, proto::tag::shift_left, sequence,
- main_meta_grammar
- >,
- meta_grammar::binary_rule_flat<
- karma::domain, proto::tag::plus, sequence,
- main_meta_grammar
- >
- >
- {
- };
-
- struct alternative_meta_grammar
- : meta_grammar::binary_rule_flat<
- karma::domain, proto::tag::bitwise_or, alternative,
- main_meta_grammar
- >
- {
- };
-
- struct repeat_meta_grammar
- : proto::or_<
- meta_grammar::unary_rule<
- karma::domain, proto::tag::dereference, kleene,
- main_meta_grammar
- >,
- meta_grammar::unary_rule<
- karma::domain, proto::tag::negate, optional,
- main_meta_grammar
- >,
- meta_grammar::unary_rule<
- karma::domain, proto::tag::unary_plus, plus,
- main_meta_grammar
- >,
- meta_grammar::binary_rule<
- karma::domain, proto::tag::modulus, list,
- main_meta_grammar, main_meta_grammar
- >
- >
- {
- };
-
- struct operator_meta_grammar
- : proto::or_<
- sequence_meta_grammar,
- alternative_meta_grammar,
- repeat_meta_grammar
- >
- {
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hooks into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<Expr
- , typename enable_if<proto::matches<Expr, operator_meta_grammar> >::type>
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<Expr
- , typename enable_if<proto::matches<Expr, operator_meta_grammar> >::type>
- : mpl::identity<operator_meta_grammar>
- {
- };
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/operator/optional.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/optional.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator/optional.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 Joel de Guzman
 // Copyright (c) 2001-2009 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -7,30 +7,47 @@
 #if !defined(SPIRIT_KARMA_OPTIONAL_MARCH_31_2007_0852AM)
 #define SPIRIT_KARMA_OPTIONAL_MARCH_31_2007_0852AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/attribute_of.hpp>
-#include <boost/spirit/home/support/attribute_transform.hpp>
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/optional.hpp>
+#include <boost/type_traits/is_convertible.hpp>
 
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_operator<karma::domain, proto::tag::negate> // enables -g
+ : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
     namespace detail
     {
- template <typename Parameter>
+ ///////////////////////////////////////////////////////////////////////
+ template <typename Attribute>
         inline bool
- optional_is_valid(boost::optional<Parameter> const& opt)
+ optional_is_valid(boost::optional<Attribute> const& opt)
         {
             return opt;
         }
 
- template <typename Parameter>
+ template <typename Attribute>
         inline bool
- optional_is_valid(Parameter const& opt)
+ optional_is_valid(Attribute const& opt)
         {
             return true;
         }
@@ -41,16 +58,17 @@
             return true;
         }
 
- template <typename Parameter>
- inline Parameter const&
- optional_get(boost::optional<Parameter> const& opt)
+ ///////////////////////////////////////////////////////////////////////
+ template <typename Attribute>
+ inline Attribute const&
+ optional_get(boost::optional<Attribute> const& opt)
         {
             return get(opt);
         }
 
- template <typename Parameter>
- inline Parameter const&
- optional_get(Parameter const& opt)
+ template <typename Attribute>
+ inline Attribute const&
+ optional_get(Attribute const& opt)
         {
             return opt;
         }
@@ -62,53 +80,53 @@
         }
     }
 
- struct optional
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Subject>
+ struct optional : unary_generator<optional<Subject> >
     {
- template <typename T>
- struct build_attribute_container
- {
- typedef boost::optional<T> type;
- };
+ typedef Subject subject_type;
+ typedef typename subject_type::properties properties;
 
- template <typename Component, typename Context, typename Iterator>
- struct attribute :
- build_container<optional, Component, Iterator, Context>
- {
- };
-
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
- {
- typedef typename
- result_of::subject<Component>::type::director
- director;
-
- if (detail::optional_is_valid(param))
- {
- director::generate(subject(component), sink, ctx, d,
- detail::optional_get(param));
- }
- return true;
- }
+ // Build a boost::optional from the subject's attribute. Note
+ // that boost::optional may return unused_type if the
+ // subject's attribute is an unused_type.
+ template <typename Context, typename Iterator = unused_type>
+ struct attribute
+ : traits::build_optional<
+ typename traits::attribute_of<Subject, Context, Iterator>::type
+ >
+ {};
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ optional(Subject const& subject)
+ : subject(subject) {}
+
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx
+ , Delimiter const& d, Attribute const& attr) const
         {
- std::string result = "optional[";
+ if (detail::optional_is_valid(attr))
+ subject.generate(sink, ctx, d, detail::optional_get(attr));
+ return sink_is_good(sink);
+ }
 
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ template <typename Context>
+ info what(Context& context) const
+ {
+ return info("optional", subject.what(context));
         }
+
+ Subject subject;
     };
 
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Elements, typename Modifiers>
+ struct make_composite<proto::tag::negate, Elements, Modifiers>
+ : make_unary_composite<Elements, optional> {};
+
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/karma/operator/plus.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/plus.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator/plus.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 Joel de Guzman
 // Copyright (c) 2001-2009 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -7,89 +7,98 @@
 #if !defined(BOOST_SPIRIT_KARMA_POSITIVE_MAR_03_2007_0945PM)
 #define BOOST_SPIRIT_KARMA_POSITIVE_MAR_03_2007_0945PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
-#include <boost/spirit/home/support/detail/container.hpp>
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/detail/output_iterator.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/attribute_transform.hpp>
-#include <boost/mpl/assert.hpp>
-#include <vector>
+#include <boost/spirit/home/support/container.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
 
+#include <boost/type_traits/add_const.hpp>
+
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_operator<karma::domain, proto::tag::unary_plus> // enables +g
+ : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
- struct plus
+ template <typename Subject>
+ struct plus : unary_generator<plus<Subject> >
     {
- template <typename T>
- struct build_attribute_container
- {
- typedef std::vector<T> type;
- };
-
- template <typename Component, typename Context, typename Iterator>
- struct attribute :
- build_container<plus, Component, Iterator, Context>
- {
- };
+ typedef Subject subject_type;
+ typedef typename subject_type::properties properties;
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ // Build a std::vector from the subjects attribute. Note
+ // that build_std_vector may return unused_type if the
+ // subject's attribute is an unused_type.
+ template <typename Context, typename Iterator>
+ struct attribute
+ : traits::build_std_vector<
+ typename traits::attribute_of<subject_type, Context, Iterator>::type
+ >
+ {};
+
+ plus(Subject const& subject)
+ : subject(subject) {}
+
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx
+ , Delimiter const& d, Attribute const& attr) const
         {
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
- typedef typename
- container::result_of::iterator<Parameter const>::type
- iterator_type;
+ typedef typename traits::result_of::iterator<
+ typename add_const<Attribute>::type
+ >::type iterator_type;
 
- iterator_type it = container::begin(param);
- iterator_type end = container::end(param);
+ iterator_type it = traits::begin(attr);
+ iterator_type end = traits::end(attr);
 
             // plus fails if the parameter is empty
- if (it == end)
+ if (traits::compare(it, end))
                 return false;
 
+ // from now on plus fails only if the underlying output fails
             bool result = true;
- for (/**/; result && !container::compare(it, end);
- container::next(it))
+ for (/**/; result && !traits::compare(it, end); traits::next(it))
             {
- result = director::generate(spirit::subject(component), sink,
- ctx, d, container::deref(it));
+ result = subject.generate(sink, ctx, d, traits::deref(it));
             }
- return result;
+ return detail::sink_is_good(sink);
         }
 
- // this kleene has no parameter attached
-// template <typename Component, typename OutputIterator,
-// typename Context, typename Delimiter>
-// static bool
-// generate(Component const&, OutputIterator&, Context&, Delimiter const&,
-// unused_type)
-// {
-// BOOST_MPL_ASSERT_MSG(false, plus_not_usable_without_attribute, ());
-// return false;
-// }
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "plus[";
-
- typedef typename
- spirit::result_of::subject<Component>::type::director
- director;
-
- result += director::what(spirit::subject(component), ctx);
- result += "]";
- return result;
+ return info("plus", subject.what(context));
         }
+
+ Subject subject;
     };
 
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Elements, typename Modifiers>
+ struct make_composite<proto::tag::unary_plus, Elements, Modifiers>
+ : make_unary_composite<Elements, plus>
+ {};
+
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/karma/operator/sequence.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/sequence.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator/sequence.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,5 +1,5 @@
 // Copyright (c) 2001-2009 Hartmut Kaiser
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 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)
@@ -7,83 +7,188 @@
 #if !defined(SPIRIT_KARMA_SEQUENCE_FEB_28_2007_0247PM)
 #define SPIRIT_KARMA_SEQUENCE_FEB_28_2007_0247PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/operator/detail/sequence.hpp>
-#include <boost/spirit/home/support/attribute_transform.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/detail/fail_function.hpp>
+#include <boost/spirit/home/karma/detail/pass_container.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/detail/what_function.hpp>
+#include <boost/spirit/home/support/attributes.hpp>
 #include <boost/spirit/home/support/algorithm/any_if.hpp>
 #include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/sequence_base_id.hpp>
 #include <boost/fusion/include/vector.hpp>
 #include <boost/fusion/include/as_vector.hpp>
-#include <boost/fusion/include/transform.hpp>
-#include <boost/fusion/include/filter_if.hpp>
 #include <boost/fusion/include/for_each.hpp>
 #include <boost/type_traits/is_same.hpp>
-#include <boost/mpl/not.hpp>
+#include <boost/mpl/bitor.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/fusion/include/transform.hpp>
+#include <boost/mpl/accumulate.hpp>
 
-namespace boost { namespace spirit { namespace karma
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
 {
- struct sequence
- {
- template <typename T>
- struct transform_child : mpl::identity<T> {};
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_operator<karma::domain, proto::tag::shift_left> // enables <<
+ : mpl::true_ {};
+
+ template <>
+ struct flatten_tree<karma::domain, proto::tag::shift_left> // flattens <<
+ : mpl::true_ {};
 
- template <typename All, typename Filtered>
- struct build_container
+}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace traits
+{
+ // specialization for sequences
+ template <typename Elements>
+ struct sequence_properties
+ {
+ struct element_properties
         {
- typedef
- typename fusion::result_of::as_vector<Filtered>::type
- type;
+ template <typename T>
+ struct result;
+
+ template <typename F, typename Element>
+ struct result<F(Element)>
+ {
+ typedef properties_of<Element> type;
+ };
+
+ // never called, but needed for decltype-based result_of (C++0x)
+ template <typename Element>
+ typename result<element_properties(Element)>::type
+ operator()(Element&) const;
         };
 
- template <typename Component, typename Context, typename Iterator>
- struct attribute :
- build_fusion_sequence<
- sequence, Component, Iterator, Context, mpl::true_
- >
+ typedef typename mpl::accumulate<
+ typename fusion::result_of::transform<
+ Elements, element_properties>::type
+ , mpl::int_<karma::generator_properties::no_properties>
+ , mpl::bitor_<mpl::_2, mpl::_1>
+ >::type type;
+ };
+
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace karma
+{
+ template <typename Elements>
+ struct sequence : nary_generator<sequence<Elements> >
+ {
+ typedef typename traits::sequence_properties<Elements>::type properties;
+
+ sequence(Elements const& elements)
+ : elements(elements) {}
+
+ typedef Elements elements_type;
+ struct sequence_base_id;
+
+ template <typename Context, typename Iterator = unused_type>
+ struct attribute
         {
+ // Put all the element attributes in a tuple
+ typedef typename traits::build_attribute_sequence<
+ Elements, Context, mpl::identity, Iterator>::type
+ all_attributes;
+
+ // Now, build a fusion vector over the attributes. Note
+ // that build_fusion_vector 1) removes all unused attributes
+ // and 2) may return unused_type if all elements have
+ // unused_type(s).
+ typedef typename
+ traits::build_fusion_vector<all_attributes>::type
+ type_;
+
+ // Finally, strip single element vectors into its
+ // naked form: vector1<T> --> T
+ typedef typename
+ traits::strip_single_element_vector<type_>::type
+ type;
         };
 
- template <typename Context>
- struct attribute_not_unused
+ // standard case. Attribute is a fusion tuple
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate_impl(OutputIterator& sink, Context& ctx
+ , Delimiter const& d, Attribute& attr_, mpl::false_) const
         {
- template <typename Component>
- struct apply
- : spirit::traits::is_not_unused<typename
- traits::attribute_of<karma::domain, Component, Context>::type>
- {};
- };
+ typedef detail::fail_function<
+ OutputIterator, Context, Delimiter> fail_function;
+ typedef traits::attribute_not_unused<Context> predicate;
+
+ // wrap the attribute in a tuple if it is not a tuple or if the
+ // attribute of this sequence is a single element tuple
+ typedef typename attribute<Context>::type_ attr_type_;
+ typename traits::wrap_if_not_tuple<Attribute
+ , typename traits::one_element_sequence<attr_type_>::type
+ >::type attr(attr_);
+
+ // return false if *any* of the generators fail
+ return !spirit::any_if(elements, attr, fail_function(sink, ctx, d)
+ , predicate());
+ }
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& param)
+ // Special case when Attribute is an stl container
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate_impl(OutputIterator& sink, Context& ctx
+ , Delimiter const& d, Attribute const& attr_, mpl::true_) const
         {
- detail::sequence_generate<OutputIterator, Context, Delimiter>
- f (sink, ctx, d);
+ // return false if *any* of the generators fail
+ typedef detail::fail_function<
+ OutputIterator, Context, Delimiter> fail_function;
 
- typedef attribute_not_unused<Context> predicate;
+ return !fusion::any(elements, detail::make_pass_container(
+ fail_function(sink, ctx, d), attr_));
+ }
 
- // f returns true if *any* of the generators fail
- return !spirit::any_if(component.elements, param, f, predicate());
+ // main generate function. Dispatches to generate_impl depending
+ // on the Attribute type.
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ return generate_impl(sink, ctx, d, attr
+ , traits::is_container<Attribute>());
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& context) const
         {
- std::string result = "sequence[";
- fusion::for_each(component.elements,
- spirit::detail::what_function<Context>(result, ctx));
- result += "]";
+ info result("sequence");
+ fusion::for_each(elements,
+ spirit::detail::what_function<Context>(result, context));
             return result;
         }
+
+ Elements elements;
     };
 
-}}} // namespace boost::spirit::karma
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Elements, typename Modifiers>
+ struct make_composite<proto::tag::shift_left, Elements, Modifiers>
+ : make_nary_composite<Elements, sequence>
+ {};
+
+}}}
 
 #endif

Modified: branches/release/boost/spirit/home/karma/stream.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/stream.hpp (original)
+++ branches/release/boost/spirit/home/karma/stream.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,12 +6,13 @@
 #if !defined(BOOST_SPIRIT_KARMA_STREAM_MAY_01_2007_1254AM)
 #define BOOST_SPIRIT_KARMA_STREAM_MAY_01_2007_1254AM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/stream/format_manip.hpp>
+#include <boost/spirit/home/karma/stream/format_manip_attr.hpp>
+#include <boost/spirit/home/karma/stream/ostream_iterator.hpp>
 #include <boost/spirit/home/karma/stream/stream.hpp>
-#include <boost/spirit/home/karma/stream/meta_grammar.hpp>
 
 #endif

Modified: branches/release/boost/spirit/home/karma/stream/detail/format_manip.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/stream/detail/format_manip.hpp (original)
+++ branches/release/boost/spirit/home/karma/stream/detail/format_manip.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,89 +6,111 @@
 #if !defined(BOOST_SPIRIT_KARMA_FORMAT_MANIP_MAY_03_2007_1424PM)
 #define BOOST_SPIRIT_KARMA_FORMAT_MANIP_MAY_03_2007_1424PM
 
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
 #include <iterator>
 #include <string>
-#include <boost/spirit/home/karma/detail/ostream_iterator.hpp>
+#include <boost/spirit/home/karma/generate.hpp>
+#include <boost/spirit/home/karma/stream/ostream_iterator.hpp>
+#include <boost/mpl/bool.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma { namespace detail
 {
     ///////////////////////////////////////////////////////////////////////////
- template <
- typename Expr,
- typename Parameter = unused_type,
- typename Delimiter = unused_type
- >
+ template <typename Expr, typename CopyAttribute = mpl::false_
+ , typename Delimiter = unused_type, typename Attribute = unused_type>
     struct format_manip
     {
- format_manip(Expr const& xpr, Parameter const& p, Delimiter const& d)
- : expr(xpr), param(p), delim(d)
- {}
+ format_manip(Expr const& xpr, Delimiter const& d, Attribute const& a)
+ : expr(xpr), delim(d), pre(delimit_flag::dont_predelimit), attr(a) {}
+
+ format_manip(Expr const& xpr, Delimiter const& d
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit, Attribute const& a)
+ : expr(xpr), delim(d), pre(pre_delimit), attr(a) {}
+
+ Expr const& expr;
+ Delimiter const& delim;
+ BOOST_SCOPED_ENUM(delimit_flag) const pre;
+ Attribute const& attr;
+ };
+
+ template <typename Expr, typename Delimiter, typename Attribute>
+ struct format_manip<Expr, mpl::true_, Delimiter, Attribute>
+ {
+ format_manip(Expr const& xpr, Delimiter const& d, Attribute const& a)
+ : expr(xpr), delim(d), pre(delimit_flag::dont_predelimit), attr(a) {}
+
+ format_manip(Expr const& xpr, Delimiter const& d
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit, Attribute const& a)
+ : expr(xpr), delim(d), pre(pre_delimit), attr(a) {}
 
         Expr const& expr;
- Parameter const& param;
         Delimiter const& delim;
+ BOOST_SCOPED_ENUM(delimit_flag) const pre;
+ Attribute attr;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- template<typename Char, typename Traits, typename Expr>
+ template<typename Char, typename Traits, typename Expr, typename Copy>
     inline std::basic_ostream<Char, Traits> &
- operator<< (std::basic_ostream<Char, Traits> &os,
- format_manip<Expr> const& fm)
+ operator<< (std::basic_ostream<Char, Traits> &os
+ , format_manip<Expr, Copy> const& fm)
     {
- ostream_iterator<Char, Char, Traits> sink(os);
+ karma::ostream_iterator<Char, Char, Traits> sink(os);
         if (!karma::generate (sink, fm.expr))
         {
             os.setstate(std::ios_base::failbit);
         }
         return os;
     }
-
+
     ///////////////////////////////////////////////////////////////////////////
- template<typename Char, typename Traits, typename Expr, typename Parameter>
+ template<typename Char, typename Traits, typename Expr, typename Copy
+ , typename Attribute>
     inline std::basic_ostream<Char, Traits> &
- operator<< (std::basic_ostream<Char, Traits> &os,
- format_manip<Expr, Parameter> const& fm)
+ operator<< (std::basic_ostream<Char, Traits> &os
+ , format_manip<Expr, Copy, unused_type, Attribute> const& fm)
     {
- ostream_iterator<Char, Char, Traits> sink(os);
- if (!karma::generate(sink, fm.expr, fm.param))
+ karma::ostream_iterator<Char, Char, Traits> sink(os);
+ if (!karma::generate(sink, fm.expr, fm.attr))
         {
             os.setstate(std::ios_base::failbit);
         }
         return os;
     }
-
- template<typename Char, typename Traits, typename Expr, typename Delimiter>
+
+ template<typename Char, typename Traits, typename Expr, typename Copy
+ , typename Delimiter>
     inline std::basic_ostream<Char, Traits> &
- operator<< (std::basic_ostream<Char, Traits> &os,
- format_manip<Expr, unused_type, Delimiter> const& fm)
+ operator<< (std::basic_ostream<Char, Traits> &os
+ , format_manip<Expr, Copy, Delimiter> const& fm)
     {
- ostream_iterator<Char, Char, Traits> sink(os);
- if (!karma::generate_delimited(sink, fm.expr, fm.delim))
+ karma::ostream_iterator<Char, Char, Traits> sink(os);
+ if (!karma::generate_delimited(sink, fm.expr, fm.delim, fm.pre))
         {
             os.setstate(std::ios_base::failbit);
         }
         return os;
     }
-
+
     ///////////////////////////////////////////////////////////////////////////
- template<
- typename Char, typename Traits,
- typename Expr, typename Parameter, typename Delimiter
- >
+ template<typename Char, typename Traits, typename Expr, typename Copy
+ , typename Delimiter, typename Attribute>
     inline std::basic_ostream<Char, Traits> &
- operator<< (
- std::basic_ostream<Char, Traits> &os,
- format_manip<Expr, Parameter, Delimiter> const& fm)
+ operator<< (std::basic_ostream<Char, Traits> &os
+ , format_manip<Expr, Copy, Delimiter, Attribute> const& fm)
     {
- ostream_iterator<Char, Char, Traits> sink(os);
- if (!karma::generate_delimited(sink, fm.expr, fm.param, fm.delim))
+ karma::ostream_iterator<Char, Char, Traits> sink(os);
+ if (!karma::generate_delimited(sink, fm.expr, fm.delim, fm.pre, fm.attr))
         {
             os.setstate(std::ios_base::failbit);
         }
         return os;
     }
-
+
 }}}}
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/stream/detail/iterator_ostream.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/stream/detail/iterator_ostream.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,42 +0,0 @@
-// Copyright (c) 2001-2009 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boist.org/LICENSE_1_0.txt)
-
-#if !defined(BOOST_SPIRIT_ITERATOR_OSTREAM_MAY_27_2007_0133PM)
-#define BOOST_SPIRIT_ITERATOR_OSTREAM_MAY_27_2007_0133PM
-
-#include <boost/iostreams/stream.hpp>
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace karma { namespace detail
-{
- ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Char>
- struct iterator_sink
- {
- typedef boost::iostreams::sink_tag category;
- typedef Char char_type;
-
- iterator_sink (OutputIterator& sink_)
- : sink(sink_)
- {}
-
- // Write up to n characters from the buffer s to the output sequence,
- // returning the number of characters written
- std::streamsize write (Char const* s, std::streamsize n)
- {
- std::streamsize bytes_written = 0;
- while (n--) {
- *sink = *s;
- ++sink; ++s; ++bytes_written;
- }
- return bytes_written;
- }
-
- OutputIterator& sink;
- };
-
-}}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/stream/format_manip.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/stream/format_manip.hpp (original)
+++ branches/release/boost/spirit/home/karma/stream/format_manip.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,13 +6,15 @@
 #if !defined(BOOST_SPIRIT_KARMA_FORMAT_MANIP_MAY_01_2007_1211PM)
 #define BOOST_SPIRIT_KARMA_FORMAT_MANIP_MAY_01_2007_1211PM
 
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
 #include <boost/spirit/home/karma/generate.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/karma/stream/detail/format_manip.hpp>
 
-#include <boost/mpl/assert.hpp>
-#include <boost/utility/enable_if.hpp>
-
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
@@ -21,92 +23,95 @@
     inline detail::format_manip<Expr>
     format(Expr const& xpr)
     {
- typedef spirit::traits::is_component<karma::domain, Expr> is_component;
-
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(is_component::value,
- xpr_is_not_convertible_to_a_generator, (Expr));
-
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
         return karma::detail::format_manip<Expr>(xpr, unused, unused);
     }
 
- template <typename Expr, typename Parameter>
- inline detail::format_manip<Expr, Parameter>
- format(Expr const& xpr, Parameter const& p)
+ template <typename Expr, typename Attribute>
+ inline detail::format_manip<Expr, mpl::false_, unused_type, Attribute>
+ format(Expr const& xpr, Attribute const& attr)
     {
- typedef spirit::traits::is_component<karma::domain, Expr> is_component;
+ using karma::detail::format_manip;
 
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(is_component::value,
- xpr_is_not_convertible_to_a_generator, (Expr, Parameter));
-
- return karma::detail::format_manip<Expr, Parameter>(xpr, p, unused);
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ return format_manip<Expr, mpl::false_, unused_type, Attribute>(
+ xpr, unused, attr);
     }
 
     ///////////////////////////////////////////////////////////////////////////
     template <typename Expr, typename Delimiter>
- inline detail::format_manip<Expr, unused_type, Delimiter>
- format_delimited(Expr const& xpr, Delimiter const& d)
+ inline detail::format_manip<Expr, mpl::false_, Delimiter>
+ format_delimited(Expr const& xpr, Delimiter const& d
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit = delimit_flag::dont_predelimit)
+ {
+ using karma::detail::format_manip;
+
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
+ return format_manip<Expr, mpl::false_, Delimiter>(
+ xpr, d, pre_delimit, unused);
+ }
+
+ template <typename Expr, typename Delimiter, typename Attribute>
+ inline detail::format_manip<Expr, mpl::false_, Delimiter, Attribute>
+ format_delimited(Expr const& xpr, Delimiter const& d
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit, Attribute const& attr)
+ {
+ using karma::detail::format_manip;
+
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
+ return format_manip<Expr, mpl::false_, Delimiter, Attribute>(
+ xpr, d, pre_delimit, attr);
+ }
+
+ template <typename Expr, typename Delimiter, typename Attribute>
+ inline detail::format_manip<Expr, mpl::false_, Delimiter, Attribute>
+ format_delimited(Expr const& xpr, Delimiter const& d, Attribute const& attr)
     {
- typedef
- spirit::traits::is_component<karma::domain, Expr>
- expr_is_component;
- typedef
- spirit::traits::is_component<karma::domain, Delimiter>
- delimiter_is_component;
-
- // report invalid expression errors as early as possible
- BOOST_MPL_ASSERT_MSG(expr_is_component::value,
- xpr_is_not_convertible_to_a_generator, (Expr, Delimiter));
-
- BOOST_MPL_ASSERT_MSG(delimiter_is_component::value,
- delimiter_is_not_convertible_to_a_generator, (Expr, Delimiter));
-
- return karma::detail::format_manip<Expr, unused_type, Delimiter>(
- xpr, unused, d);
- }
-
- template <typename Expr, typename Parameter, typename Delimiter>
- inline detail::format_manip<Expr, Parameter, Delimiter>
- format_delimited(Expr const& xpr, Parameter const& p, Delimiter const& d)
- {
- typedef
- spirit::traits::is_component<karma::domain, Expr>
- expr_is_component;
- typedef
- spirit::traits::is_component<karma::domain, Delimiter>
- delimiter_is_component;
-
- // report invalid expression errors as early as possible
- BOOST_MPL_ASSERT_MSG(expr_is_component::value,
- xpr_is_not_convertible_to_a_generator,
- (Expr, Parameter, Delimiter));
-
- BOOST_MPL_ASSERT_MSG(delimiter_is_component::value,
- delimiter_is_not_convertible_to_a_generator,
- (Expr, Parameter, Delimiter));
+ using karma::detail::format_manip;
 
- return karma::detail::format_manip<Expr, Parameter, Delimiter>(
- xpr, p, d);
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
+ return format_manip<Expr, mpl::false_, Delimiter, Attribute>(
+ xpr, d, delimit_flag::dont_predelimit, attr);
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template<typename Char, typename Traits, typename Expr>
- inline typename
- enable_if<
- spirit::traits::is_component<karma::domain, Expr>,
- std::basic_ostream<Char, Traits> &
- >::type
- operator<< (std::basic_ostream<Char, Traits> &os, Expr const& xpr)
+ template<typename Char, typename Traits, typename Derived>
+ inline std::basic_ostream<Char, Traits> &
+ operator<< (std::basic_ostream<Char, Traits> &os, generator<Derived> const& g)
     {
- karma::detail::ostream_iterator<Char, Char, Traits> sink(os);
- if (!karma::generate (sink, xpr))
+ typedef traits::properties_of<
+ typename result_of::compile<karma::domain, Derived>::type
+ > properties;
+ typedef karma::ostream_iterator<Char, Char, Traits> outiter_type;
+
+ outiter_type target_sink(os);
+ karma::detail::output_iterator<outiter_type, properties> sink(target_sink);
+
+ if (!g.derived().generate(sink, unused, unused, unused))
         {
             os.setstate(std::ios_base::failbit);
         }
         return os;
     }
-
+
 }}}
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/stream/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/stream/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,126 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_META_GRAMMAR_MAY_01_2007_0313PM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_MAY_01_2007_0313PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/utility/enable_if.hpp>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
- struct any_stream;
-
- template <typename Char>
- struct stream_director;
-
- struct main_meta_grammar;
-
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director for a stream
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag>
- struct extract_any_stream_director;
-
- template <>
- struct extract_any_stream_director<tag::stream>
- {
- typedef any_stream<char> type;
- };
-
- template <>
- struct extract_any_stream_director<tag::wstream>
- {
- typedef any_stream<wchar_t> type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag, typename T>
- struct extract_stream_director;
-
- template <typename T>
- struct extract_stream_director<tag::stream, T>
- {
- typedef stream_director<char> type;
- };
-
- template <typename T>
- struct extract_stream_director<tag::wstream, T>
- {
- typedef stream_director<wchar_t> type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // utility meta-grammar
- ///////////////////////////////////////////////////////////////////////////
- struct utility_meta_grammar
- : proto::or_<
- // stream, wstream
- meta_grammar::compose_empty<
- proto::if_<
- is_stream_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_any_stream_director<mpl::_> >
- >,
- // stream(T), wstream(T)
- meta_grammar::compose_function1_eval<
- proto::function<
- proto::if_<
- is_stream_tag<proto::_child, karma::domain>()
- >,
- proto::_
- >,
- karma::domain,
- mpl::identity<extract_stream_director<mpl::_, mpl::_> >
- >
- >
- {
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hook into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<
- Expr,
- typename enable_if<
- proto::matches<Expr, utility_meta_grammar>
- >::type
- >
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<
- Expr,
- typename enable_if<
- proto::matches<Expr, utility_meta_grammar>
- >::type
- >
- : mpl::identity<utility_meta_grammar>
- {
- };
-
-}}}
-
-#endif

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,185 +6,338 @@
 #if !defined(BOOST_SPIRIT_KARMA_STREAM_MAY_01_2007_0310PM)
 #define BOOST_SPIRIT_KARMA_STREAM_MAY_01_2007_0310PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/karma/stream/detail/format_manip.hpp>
-#include <boost/spirit/home/karma/stream/detail/iterator_ostream.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/detail/hold_any.hpp>
+#include <boost/spirit/home/support/detail/get_encoding.hpp>
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/karma/stream/detail/format_manip.hpp>
+#include <boost/spirit/home/karma/stream/detail/iterator_sink.hpp>
+#include <boost/spirit/home/karma/detail/get_casetag.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/fusion/include/vector.hpp>
+#include <boost/fusion/include/cons.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_same.hpp>
 
 #include <iosfwd>
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit
 {
- // overload the streaming operators for the unused_type
- template <typename Char, typename Traits>
- inline std::basic_ostream<Char, Traits>&
- operator<< (std::basic_ostream<Char, Traits>& os, unused_type)
+ namespace tag
+ {
+ template <typename Char = char>
+ struct stream_tag {};
+ }
+
+ namespace karma
     {
- return os;
+ ///////////////////////////////////////////////////////////////////////
+ // This one is the class that the user can instantiate directly in
+ // order to create a customized int generator
+ template <typename Char = char>
+ struct stream_generator
+ : spirit::terminal<tag::stream_tag<Char> >
+ {};
     }
 
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, tag::stream> // enables stream
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, tag::wstream> // enables wstream
+ : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables stream(...)
+ , terminal_ex<tag::stream, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename A0>
+ struct use_terminal<karma::domain // enables wstream(...)
+ , terminal_ex<tag::wstream, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <> // enables stream(f)
+ struct use_lazy_terminal<
+ karma::domain, tag::stream, 1 /*arity*/
+ > : mpl::true_ {};
+
+ template <> // enables wstream(f)
+ struct use_lazy_terminal<
+ karma::domain, tag::wstream, 1 /*arity*/
+ > : mpl::true_ {};
+
+ // enables stream_generator<char_type>
+ template <typename Char>
+ struct use_terminal<karma::domain, tag::stream_tag<Char> >
+ : mpl::true_ {};
+
+ template <typename Char, typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::stream_tag<Char>, fusion::vector1<A0> >
+ > : mpl::true_ {};
+
+ template <typename Char>
+ struct use_lazy_terminal<
+ karma::domain, tag::stream_tag<Char>, 1 /*arity*/
+ > : mpl::true_ {};
+
 }}
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
- template <typename Char>
- struct any_stream
+ using spirit::stream;
+ using spirit::wstream;
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char, typename CharEncoding, typename Tag>
+ struct any_stream_generator
+ : primitive_generator<any_stream_generator<Char, CharEncoding, Tag> >
     {
- template <typename Component, typename Context, typename Unused>
+ template <typename Context, typename Unused>
         struct attribute
         {
             typedef spirit::hold_any type;
         };
 
- // any_stream has a parameter attached
-
- // this overload will be used in the normal case (not called from
- // format_manip).
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
+ // any_stream_generator has an attached attribute
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute
+ >
+ static bool generate(OutputIterator& sink, Context&
+ , Delimiter const& d, Attribute const& attr)
         {
- typedef
- karma::detail::iterator_sink<OutputIterator, Char>
- sink_device;
-
- iostreams::stream<sink_device> ostr(sink);
- ostr << param << std::flush; // use existing operator<<()
-
- if (ostr.good()) {
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
+ typedef karma::detail::iterator_sink<
+ OutputIterator, Char, CharEncoding, Tag
+ > sink_device;
+
+ // use existing operator<<()
+ boost::iostreams::stream<sink_device> ostr(sink);
+ ostr << attr << std::flush;
+
+ if (ostr.good())
+ return karma::delimit_out(sink, d); // always do post-delimiting
             return false;
         }
 
         // this is a special overload to detect if the output iterator has been
         // generated by a format_manip object.
         template <
- typename Component, typename T, typename Traits,
- typename Context, typename Delimiter, typename Parameter
+ typename T, typename Traits, typename Properties, typename Context
+ , typename Delimiter, typename Attribute
>
- static bool
- generate(Component const& component,
+ static bool generate(
             karma::detail::output_iterator<
- karma::detail::ostream_iterator<T, Char, Traits>
- >& sink, Context&, Delimiter const& d, Parameter const& param)
+ karma::ostream_iterator<T, Char, Traits>, Properties
+ >& sink, Context&, Delimiter const& d, Attribute const& attr)
         {
             typedef karma::detail::output_iterator<
- karma::detail::ostream_iterator<T, Char, Traits>
+ karma::ostream_iterator<T, Char, Traits>, Properties
> output_iterator;
- typedef
- karma::detail::iterator_sink<output_iterator, Char>
- sink_device;
+ typedef karma::detail::iterator_sink<
+ output_iterator, Char, CharEncoding, Tag
+ > sink_device;
 
- iostreams::stream<sink_device> ostr(sink);
+ // use existing operator<<()
+ boost::iostreams::stream<sink_device> ostr(sink);
             ostr.imbue(sink.get_ostream().getloc());
- ostr << param << std::flush; // use existing operator<<()
+ ostr << attr << std::flush;
 
- if (ostr.good()) {
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
+ if (ostr.good())
+ return karma::delimit_out(sink, d); // always do post-delimiting
             return false;
         }
 
         // this any_stream has no parameter attached, it needs to have been
         // initialized from a value/variable
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
+ template <typename OutputIterator, typename Context
+ , typename Delimiter>
         static bool
- generate(Component const&, OutputIterator&, Context&, Delimiter const&,
- unused_type)
+ generate(OutputIterator&, Context&, Delimiter const&, unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false, stream__not_usable_without_attribute,
- (Component, OutputIterator, Delimiter));
+ BOOST_SPIRIT_ASSERT_MSG(false, stream_not_usable_without_attribute,
+ (OutputIterator, Delimiter));
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& /*context*/) const
         {
- return "any-stream";
+ return info("stream");
         }
     };
 
- ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
- struct stream_director
+
+ template <typename T, typename Char, typename CharEncoding, typename Tag>
+ struct lit_stream_generator
+ : primitive_generator<lit_stream_generator<T, Char, CharEncoding, Tag> >
     {
- template <typename Component, typename Context, typename Unused>
- struct attribute
+ template <typename Context, typename Unused>
+ struct attribute
         {
             typedef unused_type type;
         };
 
- // stream_director has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const&)
+ lit_stream_generator(typename add_reference<T>::type t)
+ : t_(t)
+ {}
+
+ // lit_stream_generator has an attached parameter
+
+ // this overload will be used in the normal case (not called from
+ // format_manip).
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const&)
         {
- typedef
- karma::detail::iterator_sink<OutputIterator, Char>
- sink_device;
+ typedef karma::detail::iterator_sink<
+ OutputIterator, Char, CharEncoding, Tag
+ > sink_device;
 
- // use existing operator<<()
- iostreams::stream<sink_device> ostr(sink);
- ostr << fusion::at_c<0>(component.elements) << std::flush;
+ boost::iostreams::stream<sink_device> ostr(sink);
+ ostr << t_ << std::flush; // use existing operator<<()
 
- if (ostr.good()) {
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
+ if (ostr.good())
+ return karma::delimit_out(sink, d); // always do post-delimiting
             return false;
         }
 
         // this is a special overload to detect if the output iterator has been
         // generated by a format_manip object.
         template <
- typename Component, typename T, typename Traits,
- typename Context, typename Delimiter, typename Parameter
- >
- static bool
- generate(Component const& component,
+ typename T1, typename Traits, typename Properties
+ , typename Context, typename Delimiter, typename Attribute>
+ bool generate(
             karma::detail::output_iterator<
- karma::detail::ostream_iterator<T, Char, Traits>
- >& sink, Context&, Delimiter const& d, Parameter const&)
+ karma::ostream_iterator<T1, Char, Traits>, Properties
+ >& sink, Context&, Delimiter const& d, Attribute const&)
         {
             typedef karma::detail::output_iterator<
- karma::detail::ostream_iterator<T, Char, Traits>
+ karma::ostream_iterator<T1, Char, Traits>, Properties
> output_iterator;
- typedef
- karma::detail::iterator_sink<output_iterator, Char>
- sink_device;
+ typedef karma::detail::iterator_sink<
+ output_iterator, Char, CharEncoding, Tag
+ > sink_device;
 
- // use existing operator<<()
- iostreams::stream<sink_device> ostr(sink);
+ boost::iostreams::stream<sink_device> ostr(sink);
             ostr.imbue(sink.get_ostream().getloc());
- ostr << fusion::at_c<0>(component.elements) << std::flush;
+ ostr << t_ << std::flush; // use existing operator<<()
 
- if (ostr.good()) {
- karma::delimit(sink, d); // always do post-delimiting
- return true;
- }
+ if (ostr.good())
+ return karma::delimit_out(sink, d); // always do post-delimiting
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context& /*context*/) const
         {
- return "stream";
+ return info("any-stream");
         }
+
+ T t_;
     };
 
+ ///////////////////////////////////////////////////////////////////////////
+ // Parser generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char, typename Modifiers>
+ struct make_stream
+ {
+ 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 any_stream_generator<
+ Char
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ > result_type;
+
+ result_type operator()(unused_type, unused_type) const
+ {
+ return result_type();
+ }
+ };
+
+ // stream
+ template <typename Modifiers>
+ struct make_primitive<tag::stream, Modifiers>
+ : make_stream<char, Modifiers> {};
+
+ // wstream
+ template <typename Modifiers>
+ struct make_primitive<tag::wstream, Modifiers>
+ : make_stream<wchar_t, Modifiers> {};
+
+ // any_stream_generator<char_type>
+ template <typename Char, typename Modifiers>
+ struct make_primitive<tag::stream_tag<Char>, Modifiers>
+ : make_stream<Char, Modifiers> {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char, typename A0, typename Modifiers>
+ struct make_any_stream
+ {
+ 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 typename add_const<A0>::type const_attribute;
+ typedef lit_stream_generator<
+ const_attribute, Char
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, 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));
+ }
+ };
+
+ // stream(...)
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::stream, fusion::vector1<A0> >, Modifiers>
+ : make_any_stream<char, A0, Modifiers> {};
+
+ // wstream(...)
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::wstream, fusion::vector1<A0> >, Modifiers>
+ : make_any_stream<wchar_t, A0, Modifiers> {};
+
+ // any_stream_generator<char_type>(...)
+ template <typename Char, typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::stream_tag<Char>, fusion::vector1<A0> >
+ , Modifiers>
+ : make_any_stream<Char, A0, Modifiers> {};
+
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/karma/string.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/string.hpp (original)
+++ branches/release/boost/spirit/home/karma/string.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,11 +6,10 @@
 #if !defined(BOOST_SPIRIT_KARMA_STRING_FEB_23_2007_0156PM)
 #define BOOST_SPIRIT_KARMA_STRING_FEB_23_2007_0156PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/karma/string/lit.hpp>
-#include <boost/spirit/home/karma/string/meta_grammar.hpp>
 
 #endif

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 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,305 +6,317 @@
 #if !defined(BOOST_SPIRIT_KARMA_LIT_FEB_22_2007_0534PM)
 #define BOOST_SPIRIT_KARMA_LIT_FEB_22_2007_0534PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/char_class.hpp>
+#include <boost/spirit/home/support/detail/get_encoding.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/karma/delimit.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/spirit/home/karma/detail/get_casetag.hpp>
 #include <boost/spirit/home/karma/detail/string_generate.hpp>
-#include <boost/spirit/home/support/char_class.hpp>
-#include <boost/spirit/home/support/modifier.hpp>
+#include <boost/spirit/home/karma/detail/string_compare.hpp>
 #include <boost/fusion/include/at.hpp>
-#include <boost/fusion/include/value_at.hpp>
 #include <boost/fusion/include/vector.hpp>
+#include <boost/fusion/include/cons.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/bool.hpp>
 #include <string>
 
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename CharEncoding>
+ struct use_terminal<karma::domain
+ , tag::char_code<tag::string, CharEncoding> > // enables string
+ : mpl::true_ {};
+
+ template <typename T>
+ struct use_terminal<karma::domain, T
+ , typename enable_if<traits::is_string<T> >::type> // enables string literals
+ : mpl::true_ {};
+
+ template <typename CharEncoding, typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<
+ tag::char_code<tag::string, CharEncoding> // enables string(str)
+ , fusion::vector1<A0> >
+ > : traits::is_string<A0> {};
+
+ template <typename CharEncoding> // enables string(f)
+ struct use_lazy_terminal<
+ karma::domain
+ , tag::char_code<tag::string, CharEncoding>
+ , 1 /*arity*/
+ > : mpl::true_ {};
+
+}}
+
+///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
 {
     ///////////////////////////////////////////////////////////////////////////
     // generate literal strings from a given parameter
     ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
+ template <typename CharEncoding, typename Tag>
     struct any_string
+ : primitive_generator<any_string<CharEncoding, Tag> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef typename CharEncoding::char_type char_type;
+ typedef CharEncoding char_encoding;
+
+ template <typename Context, typename Unused>
         struct attribute
         {
- typedef std::basic_string<Char> type;
+ typedef std::basic_string<char_type> type;
         };
 
- // lit has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
+ // lit has an attached attribute
+ template <
+ typename OutputIterator, typename Context,
+ typename Delimiter, typename Attribute
+ >
         static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
+ generate(OutputIterator& sink, Context& /*ctx*/, Delimiter const& d,
+ Attribute const& attr)
         {
- bool result = detail::string_generate(sink, param);
- if (result)
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ return
+ karma::detail::string_generate(sink, attr, char_encoding(), Tag()) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- // this lit has no parameter attached, it needs to have been
+ // this lit has no attribute attached, it needs to have been
         // initialized from a direct literal
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, unused_type)
- {
- BOOST_MPL_ASSERT_MSG(false, lit_not_usable_without_attribute, ());
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ static bool generate(OutputIterator&, Context&, Delimiter const&,
+ unused_type const&)
+ {
+ // It is not possible (doesn't make sense) to use string without
+ // providing any attribute, as the generator doesn't 'know' what
+ // character to output. The following assertion fires if this
+ // situation is detected in your code.
+ BOOST_SPIRIT_ASSERT_MSG(false, string_not_usable_without_attribute, ());
             return false;
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ static info what(Context const& ctx)
         {
- return "any-string";
+ return info("any-string");
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////
     // generate literal strings
     ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
+ template <typename String, typename CharEncoding, typename Tag, bool no_attribute>
     struct literal_string
+ : primitive_generator<literal_string<String, CharEncoding, Tag, no_attribute> >
     {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef unused_type type;
- };
+ typedef CharEncoding char_encoding;
+ typedef typename
+ remove_const<typename traits::char_type_of<String>::type>::type
+ char_type;
+ typedef std::basic_string<char_type> string_type;
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/)
- {
- bool result = detail::string_generate(sink,
- fusion::at_c<0>(component.elements));
+ template <typename Context, typename Unused>
+ struct attribute
+ : mpl::if_c<no_attribute, unused_type, string_type>
+ {};
 
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ literal_string(typename add_reference<String>::type str)
+ : str_(str)
+ {}
+
+ // A string("...") which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ // fail if attribute isn't matched my immediate literal
+ using spirit::traits::get_c_string;
+ if (!detail::string_compare(get_c_string(attr), get_c_string(str_)
+ , char_encoding(), Tag()))
+ {
+ return false;
+ }
+ return detail::string_generate(sink, str_, char_encoding(), Tag()) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ // A string("...") without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
         {
- return std::string("\"")
- + spirit::detail::to_narrow_string(
- fusion::at_c<0>(component.elements))
- + std::string("\"")
- ;
+ return detail::string_generate(sink, str_, char_encoding(), Tag()) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // lazy string generation
- ///////////////////////////////////////////////////////////////////////////
- struct lazy_string
- {
- template <typename Component, typename Context, typename Unused>
- struct attribute
- {
- typedef unused_type type;
- };
 
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& ctx, Delimiter const& d, Parameter const& /*param*/)
+ template <typename Context>
+ info what(Context const& ctx) const
         {
- bool result = detail::string_generate(sink,
- fusion::at_c<0>(component.elements)(unused, ctx));
-
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ return info("literal-string", str_);
         }
 
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
- {
- return "string";
- }
+ string_type str_;
     };
 
- ///////////////////////////////////////////////////////////////////////////
- // generate literal strings from a given parameter
- ///////////////////////////////////////////////////////////////////////////
- template <typename Char, typename Tag>
- struct case_any_string
+ template <typename String, typename Tag, bool no_attribute>
+ struct literal_string<String, unused_type, Tag, no_attribute>
+ : primitive_generator<literal_string<String, unused_type, Tag, no_attribute> >
     {
- template <typename Component, typename Context, typename Unused>
+ typedef typename
+ remove_const<typename traits::char_type_of<String>::type>::type
+ char_type;
+ typedef std::basic_string<char_type> string_type;
+
+ template <typename Context, typename Unused>
         struct attribute
         {
- typedef std::basic_string<Char> type;
+ typedef typename mpl::if_c<
+ no_attribute, unused_type, string_type>::type
+ type;
         };
 
- // case_any_string has a parameter attached
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter, typename Parameter>
- static bool
- generate(Component const& /*component*/, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, Parameter const& param)
+ literal_string(typename add_reference<String>::type str)
+ : str_(str) {}
+
+ // A string("...") which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
+ template <
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
         {
- bool result = detail::string_generate(sink, param, Tag());
- karma::delimit(sink, d); // always do post-delimiting
- return result;
+ // fail if attribute isn't matched my immediate literal
+ using spirit::traits::get_c_string;
+ if (!detail::string_compare(get_c_string(attr), get_c_string(str_)))
+ return false;
+
+ return detail::string_generate(sink, str_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
- // this case_any_string has no parameter attached, it needs to have been
- // initialized from a direct literal
- template <typename Component, typename OutputIterator,
- typename Context, typename Delimiter>
- static bool
- generate(Component const& component, OutputIterator& sink,
- Context& /*ctx*/, Delimiter const& d, unused_type)
+ // A string("...") without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
         {
- BOOST_MPL_ASSERT_MSG(false, lit_not_usable_without_attribute, ());
- return false;
+ return detail::string_generate(sink, str_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
         }
 
-
- template <typename Component, typename Context>
- static std::string what(Component const& component, Context const& ctx)
+ template <typename Context>
+ info what(Context const& ctx) const
         {
- typedef typename Tag::char_set char_set;
- typedef typename Tag::char_class char_class_;
- return std::string("any-") +
- spirit::char_class::what<char_set>::is(char_class_())
- + "case-string";
+ return info("literal-string", str_);
         }
- };
 
-}}}
+ string_type str_;
+ };
 
-namespace boost { namespace spirit { namespace traits
-{
     ///////////////////////////////////////////////////////////////////////////
- // lower_case and upper_case literal_string generator
+ // Generator generators: make_xxx function (objects)
     ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename Char>
- struct make_modified_component<
- Domain, karma::literal_string<Char>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
- {
- typedef std::basic_string<Char> string_type;
- typedef fusion::vector<string_type> vector_type;
 
- typedef
- component<karma::domain, karma::literal_string<Char>, vector_type>
- type;
-
- static type
- call(Elements const& elements)
- {
- typedef typename Modifier::char_set char_set;
-
- string_type val(fusion::at_c<0>(elements));
- typename string_type::iterator end = val.end();
- for (typename string_type::iterator it = val.begin();
- it != end; ++it)
- {
- *it = char_set::tolower(*it);
- }
+ // string
+ template <typename CharEncoding, typename Modifiers>
+ struct make_primitive<
+ tag::char_code<tag::string, CharEncoding>
+ , Modifiers>
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code<tag::lower, CharEncoding> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code<tag::upper, CharEncoding> >::value;
+
+ typedef any_string<
+ typename spirit::detail::get_encoding<
+ Modifiers, CharEncoding, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ > result_type;
 
- return type(vector_type(val));
+ result_type operator()(unused_type, unused_type) const
+ {
+ return result_type();
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename Char>
- struct make_modified_component<
- Domain, karma::literal_string<Char>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
+ // string literal
+ template <typename T, typename Modifiers>
+ struct make_primitive<T, Modifiers
+ , typename enable_if<traits::is_string<T> >::type>
     {
- typedef std::basic_string<Char> string_type;
- typedef fusion::vector<string_type> vector_type;
-
- typedef
- component<karma::domain, karma::literal_string<Char>, vector_type>
- type;
-
- static type
- call(Elements const& elements)
- {
- typedef typename Modifier::char_set char_set;
-
- string_type val(fusion::at_c<0>(elements));
- typename string_type::iterator end = val.end();
- for (typename string_type::iterator it = val.begin();
- it != end; ++it)
- {
- *it = char_set::toupper(*it);
- }
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
 
- return type(vector_type(val));
- }
- };
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
 
- ///////////////////////////////////////////////////////////////////////////
- // lower and upper case_any_string conversions
- ///////////////////////////////////////////////////////////////////////////
- template <typename Domain, typename Elements, typename Modifier,
- typename Char>
- struct make_modified_component<
- Domain, karma::any_string<Char>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::lower_case_base_tag>
- >::type
- >
- {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::lower char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef component<
- karma::domain, karma::case_any_string<Char, key_tag>, fusion::nil
- > type;
+ typedef typename add_const<T>::type const_string;
+ typedef literal_string<
+ const_string
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , true
+ > result_type;
 
- static type
- call(Elements const&)
+ result_type operator()(
+ typename add_reference<const_string>::type str, unused_type) const
         {
- return type(fusion::nil());
+ return result_type(str);
         }
     };
 
- template <typename Domain, typename Elements, typename Modifier,
- typename Char>
- struct make_modified_component<
- Domain, karma::any_string<Char>, Elements, Modifier,
- typename enable_if<
- is_member_of_modifier<Modifier, spirit::char_class::upper_case_base_tag>
- >::type
- >
+ template <typename CharEncoding, typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::string, CharEncoding>
+ , fusion::vector1<A0> >
+ , Modifiers>
     {
- typedef typename Modifier::char_set char_set;
- typedef spirit::char_class::tag::upper char_class_;
- typedef spirit::char_class::key<char_set, char_class_> key_tag;
-
- typedef component<
- karma::domain, karma::case_any_string<Char, key_tag>, fusion::nil
- > type;
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code<tag::lower, CharEncoding> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code<tag::upper, CharEncoding> >::value;
+
+ typedef typename add_const<A0>::type const_string;
+ typedef literal_string<
+ const_string
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , false
+ > result_type;
 
- static type
- call(Elements const&)
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
         {
- return type(fusion::nil());
+ return result_type(fusion::at_c<0>(term.args));
         }
     };
 
-}}}
+}}} // namespace boost::spirit::karma
 
 #endif

Deleted: branches/release/boost/spirit/home/karma/string/meta_grammar.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/string/meta_grammar.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,236 +0,0 @@
-// Copyright (c) 2001-2009 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_KARMA_META_GRAMMAR_FEB_22_2007_0532PM)
-#define BOOST_SPIRIT_KARMA_META_GRAMMAR_FEB_22_2007_0532PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/support/placeholders.hpp>
-#include <boost/spirit/home/support/meta_grammar.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/type_traits/remove_const.hpp>
-#include <boost/type_traits/is_convertible.hpp>
-#include <string>
-
-namespace boost { namespace spirit { namespace karma
-{
- ///////////////////////////////////////////////////////////////////////////
- // forwards
- ///////////////////////////////////////////////////////////////////////////
- template <typename Char>
- struct any_string;
-
- template <typename Char>
- struct literal_string;
-
- struct lazy_string;
-
- struct string_meta_grammar;
-
- template <typename Expr, typename Enable>
- struct is_valid_expr;
-
- template <typename Expr, typename Enable>
- struct expr_transform;
-
- ///////////////////////////////////////////////////////////////////////////
- //
- ///////////////////////////////////////////////////////////////////////////
- template <typename T>
- struct extract_char;
-
- template <typename Char, typename Traits, typename Alloc>
- struct extract_char<std::basic_string<Char, Traits, Alloc> >
- {
- typedef Char type;
- };
-
- template <typename Char, int N>
- struct extract_char<Char[N]>
- {
- typedef typename remove_const<Char>::type type;
- };
-
- template <typename Char, int N>
- struct extract_char<Char(&)[N]>
- {
- typedef typename remove_const<Char>::type type;
- };
-
- template <typename Char>
- struct extract_char<Char*>
- {
- typedef typename remove_const<Char>::type type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // get the director of a string literal type
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag, typename T>
- struct extract_lit_director_lit;
-
- template <typename T>
- struct extract_lit_director_lit<tag::lit, T>
- {
- typedef typename extract_char<T>::type char_type;
- typedef literal_string<char_type> type;
- };
-
- template <typename T>
- struct extract_lit_director_lit<tag::wlit, T>
- {
- typedef typename extract_char<T>::type char_type;
- typedef literal_string<char_type> type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Tag>
- struct extract_lit_director_plain;
-
- template <>
- struct extract_lit_director_plain<tag::lit>
- {
- typedef any_string<char> type;
- };
-
- template <>
- struct extract_lit_director_plain<tag::wlit>
- {
- typedef any_string<wchar_t> type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // string generator meta-grammar
- ///////////////////////////////////////////////////////////////////////////
-
- // literal strings: "hello"
- struct string_literal_meta_grammar
- : proto::or_<
- meta_grammar::terminal_rule<
- karma::domain, char const*, literal_string<char>
- >,
- meta_grammar::terminal_rule<
- karma::domain, wchar_t const*, literal_string<wchar_t>
- >,
- meta_grammar::terminal_rule<
- karma::domain, char*, literal_string<char>
- >,
- meta_grammar::terminal_rule<
- karma::domain, wchar_t*, literal_string<wchar_t>
- >
- >
- {
- };
-
- // literal strings: "hello"
- struct basic_string_literal_meta_grammar
- : proto::or_<
- proto::terminal<char const*>,
- proto::terminal<wchar_t const*>
- >
- {
- };
-
- // std::string(s)
- struct std_string_meta_grammar
- : proto::or_<
- meta_grammar::terminal_rule<
- karma::domain,
- std::basic_string<char, proto::_, proto::_>,
- literal_string<char>
- >,
- meta_grammar::terminal_rule<
- karma::domain,
- std::basic_string<wchar_t, proto::_, proto::_>,
- literal_string<wchar_t>
- >
- >
- {
- };
-
- // std::string(s)
- struct basic_std_string_meta_grammar
- : proto::or_<
- proto::terminal<std::basic_string<char, proto::_, proto::_> >,
- proto::terminal<std::basic_string<wchar_t, proto::_, proto::_> >
- >
- {
- };
-
- namespace detail
- {
- // we use this test to detect if the argument to lit is a callable
- // function or not. Only types convertible to int or function/
- // function objects are allowed. Therefore, if T is not convertible
- // to an int, then we have a function/function object.
- template <typename T>
- struct is_not_convertible_to_int
- : mpl::not_<is_convertible<T, int> >
- {
- };
- }
-
- // this is the string literal meta grammar
- // literal strings: lit, lit("hello")
- struct string_meta_grammar
- : proto::or_<
- string_literal_meta_grammar,
- std_string_meta_grammar,
- meta_grammar::compose_empty<
- proto::if_<
- is_lit_tag<proto::_child, karma::domain>()
- >,
- karma::domain,
- mpl::identity<extract_lit_director_plain<mpl::_> >
- >,
- meta_grammar::compose_function1_eval<
- proto::function<
- proto::if_<
- is_lit_tag<proto::_child, karma::domain>()
- >,
- proto::or_<
- basic_string_literal_meta_grammar,
- basic_std_string_meta_grammar
- >
- >,
- karma::domain,
- mpl::identity<extract_lit_director_lit<mpl::_, mpl::_> >
- >,
- meta_grammar::function1_rule<
- karma::domain, tag::lit, lazy_string,
- proto::if_<
- detail::is_not_convertible_to_int<proto::_child>()
- >
- >
- >
- {
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // These specializations non-intrusively hooks into the Karma meta-grammar.
- // (see karma/meta_grammar.hpp)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Expr>
- struct is_valid_expr<Expr,
- typename enable_if<proto::matches<Expr, string_meta_grammar> >::type>
- : mpl::true_
- {
- };
-
- template <typename Expr>
- struct expr_transform<Expr,
- typename enable_if<proto::matches<Expr, string_meta_grammar> >::type>
- : mpl::identity<string_meta_grammar>
- {
- };
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/karma/what.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/what.hpp (original)
+++ branches/release/boost/spirit/home/karma/what.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,30 +6,27 @@
 #if !defined(BOOST_SPIRIT_WHAT_MAY_04_2007_0116PM)
 #define BOOST_SPIRIT_WHAT_MAY_04_2007_0116PM
 
-#include <boost/spirit/home/karma/meta_grammar.hpp>
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
 #include <boost/mpl/assert.hpp>
-#include <string>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
 
 namespace boost { namespace spirit { namespace karma
 {
     template <typename Expr>
- inline std::string what(Expr const& xpr)
+ inline info what(Expr const& xpr)
     {
- typedef spirit::traits::is_component<karma::domain, Expr> is_component;
-
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(
- is_component::value,
- xpr_is_not_convertible_to_a_generator, ());
-
- typedef typename
- spirit::result_of::as_component<karma::domain, Expr>::type
- component;
- typedef typename component::director director;
-
- component c = spirit::as_component(karma::domain(), xpr);
- return director::what(c, unused);
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression
+ // error message here, then the expression (expr) is not a
+ // valid spirit karma expression.
+ BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
+ return compile<karma::domain>(xpr).what(unused);
     }
+
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/lex.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex.hpp (original)
+++ branches/release/boost/spirit/home/lex.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,13 +6,13 @@
 #if !defined(BOOST_SPIRIT_LEXER_MARCH_22_2007_0929PM)
 #define BOOST_SPIRIT_LEXER_MARCH_22_2007_0929PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
 #include <boost/spirit/home/lex/lexer.hpp>
-#include <boost/spirit/home/lex/domain.hpp>
-#include <boost/spirit/home/lex/meta_grammar.hpp>
+#include <boost/spirit/home/lex/qi.hpp>
 #include <boost/spirit/home/lex/tokenize_and_parse.hpp>
+#include <boost/spirit/home/lex/tokenize_and_parse_attr.hpp>
 
 #endif

Modified: branches/release/boost/spirit/home/lex/domain.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/domain.hpp (original)
+++ branches/release/boost/spirit/home/lex/domain.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2007 Joel de Guzman
+// Copyright (c) 2001-2009 Joel de Guzman
 // Copyright (c) 2001-2009 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -7,15 +7,25 @@
 #if !defined(BOOST_SPIRIT_LEX_DOMAIN_MAR_13_2007_0140PM)
 #define BOOST_SPIRIT_LEX_DOMAIN_MAR_13_2007_0140PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
+#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/meta_compiler.hpp>
+#include <boost/spirit/home/support/info.hpp>
+
 namespace boost { namespace spirit { namespace lex
 {
- struct domain
- {};
-
+ // lex's domain
+ struct domain {};
+
+ // bring in some of spirit parts into spirit::lex
+ using spirit::unused;
+ using spirit::unused_type;
+ using spirit::compile;
+ using spirit::info;
+
 }}}
 
 #endif

Modified: branches/release/boost/spirit/home/lex/lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,25 +6,16 @@
 #if !defined(BOOST_SPIRIT_LEXER_MAR_22_2007_1008PM)
 #define BOOST_SPIRIT_LEXER_MAR_22_2007_1008PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/lex/lexer/terminal_holder.hpp>
-#include <boost/spirit/home/lex/lexer/terminal_director.hpp>
+#include <boost/spirit/home/lex/lexer/terminals.hpp>
 #include <boost/spirit/home/lex/lexer/token_def.hpp>
-#include <boost/spirit/home/lex/lexer/token_set.hpp>
 #include <boost/spirit/home/lex/lexer/char_token_def.hpp>
 #include <boost/spirit/home/lex/lexer/string_token_def.hpp>
 #include <boost/spirit/home/lex/lexer/sequence.hpp>
 #include <boost/spirit/home/lex/lexer/action.hpp>
-#include <boost/spirit/home/lex/lexer/lexer_actions.hpp>
 #include <boost/spirit/home/lex/lexer/lexer.hpp>
-#include <boost/spirit/home/lex/lexer/meta_grammar.hpp>
-
-#include <boost/spirit/home/lex/qi/state/state_switcher.hpp>
-#include <boost/spirit/home/lex/qi/state/in_state.hpp>
-#include <boost/spirit/home/lex/qi/utility/plain_token.hpp>
-#include <boost/spirit/home/lex/qi/meta_grammar.hpp>
 
 #endif

Modified: branches/release/boost/spirit/home/lex/lexer/action.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/action.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/action.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,90 +6,87 @@
 #if !defined(SPIRIT_LEX_ACTION_NOV_18_2007_0743PM)
 #define SPIRIT_LEX_ACTION_NOV_18_2007_0743PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/lex/set_state.hpp>
+#include <boost/spirit/home/lex/meta_compiler.hpp>
+#include <boost/spirit/home/lex/lexer_type.hpp>
+#include <boost/spirit/home/lex/argument.hpp>
+#include <boost/spirit/home/lex/lexer/support_functions.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/is_same.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace lex
 {
     ///////////////////////////////////////////////////////////////////////////
- namespace detail
+ template <typename Subject, typename Action>
+ struct action : unary_lexer<action<Subject, Action> >
     {
- ///////////////////////////////////////////////////////////////////////
- template <typename Char>
- struct set_state_functor
- {
- set_state_functor (Char const* new_state_)
- : new_state(new_state_)
- {
- }
-
- template <typename Range, typename LexerContext>
- void operator()(Range const&, std::size_t, bool&,
- LexerContext& ctx) const
- {
- ctx.set_state_name(new_state);
- }
-
- Char const* new_state;
- };
-
- ///////////////////////////////////////////////////////////////////////
- template <typename Char>
- set_state_functor<Char>
- make_set_state(Char const* new_state)
- {
- return set_state_functor<Char>(new_state);
- }
+ action(Subject const& subject, Action f)
+ : subject(subject), f(f) {}
 
- template <typename Char, typename Traits, typename Alloc>
- set_state_functor<Char>
- make_set_state(std::basic_string<Char, Traits, Alloc> const& new_state)
+ template <typename LexerDef, typename String>
+ void collect(LexerDef& lexdef, String const& state) const
         {
- return set_state_functor<Char>(new_state.c_str());
+ // collect the token definition information for the token_def
+ // this action is attached to
+ subject.collect(lexdef, state);
         }
 
- ///////////////////////////////////////////////////////////////////////
- template <typename LexerDef, typename F>
- inline void add_action_helper(LexerDef& lexdef, std::size_t id, F act)
+ template <typename LexerDef>
+ void add_actions(LexerDef& lexdef) const
         {
- lexdef.add_action(id, act);
- }
-
- template <typename LexerDef, typename String>
- inline void add_action_helper(LexerDef& lexdef, std::size_t id,
- spirit::tag::set_state_tag<String> t)
- {
- lexdef.add_action(id, make_set_state(t.name));
+ // call to add all actions attached further down the hierarchy
+ subject.add_actions(lexdef);
+
+ // retrieve the id of the associated token_def and register the
+ // given semantic action with the lexer instance
+ lexdef.add_action(subject.unique_id(), subject.state(), f);
         }
- }
-
+
+ Subject subject;
+ Action f;
+ };
+
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
     ///////////////////////////////////////////////////////////////////////////
- struct action
+ // Karma action meta-compiler
+ template <>
+ struct make_component<lex::domain, tag::action>
     {
- template <typename Component, typename LexerDef, typename String>
- static void
- collect(Component const& component, LexerDef& lexdef,
- String const& state)
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Elements, typename Modifiers>
+ struct result<This(Elements, Modifiers)>
         {
             typedef typename
- result_of::left<Component>::type::director
- director;
-
- // first collect the token definition information for the token_def
- // this action is attached to
- director::collect(spirit::left(component), lexdef, state);
+ remove_const<typename Elements::car_type>::type
+ subject_type;
 
- // retrieve the id of the associated token_def and register the
- // given semantic action with the lexer instance
- std::size_t id = director::id(spirit::left(component));
- detail::add_action_helper(lexdef, id, spirit::right(component));
+ typedef typename
+ remove_const<typename Elements::cdr_type::car_type>::type
+ action_type;
+
+ typedef lex::action<subject_type, action_type> type;
+ };
+
+ template <typename Elements>
+ typename result<make_component(Elements, unused_type)>::type
+ operator()(Elements const& elements, unused_type) const
+ {
+ typename result<make_component(Elements, unused_type)>::type
+ result(elements.car, elements.cdr.car);
+ return result;
         }
     };
-
-}}} // namespace boost::spirit::lex
+}}
 
 #endif

Modified: branches/release/boost/spirit/home/lex/lexer/char_token_def.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/char_token_def.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/char_token_def.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,35 +6,161 @@
 #if !defined(BOOST_SPIRIT_LEX_CHAR_TOKEN_DEF_MAR_28_2007_0626PM)
 #define BOOST_SPIRIT_LEX_CHAR_TOKEN_DEF_MAR_28_2007_0626PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/component.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/lex/domain.hpp>
+#include <boost/spirit/home/lex/lexer_type.hpp>
+#include <boost/spirit/home/lex/meta_compiler.hpp>
+
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<lex::domain, char> // enables 'x'
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<lex::domain, char[2]> // enables "x"
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<lex::domain, wchar_t> // enables wchar_t
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<lex::domain, wchar_t[2]> // enables L"x"
+ : mpl::true_ {};
+
+ template <typename CharEncoding, typename A0>
+ struct use_terminal<lex::domain
+ , terminal_ex<
+ tag::char_code<tag::char_, CharEncoding> // enables char_('x'), char_("x")
+ , fusion::vector1<A0>
+ >
+ > : mpl::true_ {};
+
+}}
 
 namespace boost { namespace spirit { namespace lex
 {
+ using spirit::lit; // lit('x') is equivalent to 'x'
+
     ///////////////////////////////////////////////////////////////////////////
     //
     // char_token_def
     // represents a single character token definition
     //
     ///////////////////////////////////////////////////////////////////////////
+ template <typename CharEncoding>
     struct char_token_def
+ : primitive_lexer<char_token_def<CharEncoding> >
+ {
+ typedef typename CharEncoding::char_type char_type;
+
+ char_token_def(char_type ch)
+ : ch(ch), unique_id_(std::size_t(~0)) {}
+
+ template <typename LexerDef, typename String>
+ void collect(LexerDef& lexdef, String const& state) const
+ {
+ unique_id_ = lexdef.add_token (state.c_str(), ch
+ , static_cast<std::size_t>(ch));
+ }
+
+ template <typename LexerDef>
+ void add_actions(LexerDef& lexdef) const {}
+
+ std::size_t id() const { return static_cast<std::size_t>(ch); }
+ std::size_t unique_id() const { return unique_id_; }
+
+ char_type ch;
+ mutable std::size_t unique_id_;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Lexer generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
     {
- template <typename Component, typename LexerDef, typename String>
- static void
- collect(Component const& component, LexerDef& lexdef,
- String const& state)
+ template <typename CharEncoding>
+ struct basic_literal
         {
- typedef typename result_of::subject<Component>::type char_type;
-
- char_type c = subject(component);
- lexdef.add_token (state.c_str(), lex::detail::escape(c),
- static_cast<std::size_t>(c));
+ typedef char_token_def<CharEncoding> result_type;
+
+ template <typename Char>
+ result_type operator()(Char ch, unused_type) const
+ {
+ return result_type(ch);
+ }
+
+ template <typename Char>
+ result_type operator()(Char const* str, unused_type) const
+ {
+ return result_type(str[0]);
+ }
+ };
+ }
+
+ // literals: 'x', "x"
+ template <typename Modifiers>
+ struct make_primitive<char, Modifiers>
+ : detail::basic_literal<char_encoding::standard> {};
+
+ template <typename Modifiers>
+ struct make_primitive<char const(&)[2], Modifiers>
+ : detail::basic_literal<char_encoding::standard> {};
+
+ // literals: L'x', L"x"
+ template <typename Modifiers>
+ struct make_primitive<wchar_t, Modifiers>
+ : detail::basic_literal<char_encoding::standard_wide> {};
+
+ template <typename Modifiers>
+ struct make_primitive<wchar_t const(&)[2], Modifiers>
+ : detail::basic_literal<char_encoding::standard_wide> {};
+
+ // handle char_('x')
+ template <typename CharEncoding, typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::char_, CharEncoding>
+ , fusion::vector1<A0>
+ >
+ , Modifiers>
+ {
+ typedef char_token_def<CharEncoding> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
         }
     };
-
+
+ // handle char_("x")
+ template <typename CharEncoding, typename Modifiers, typename Char>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::char_, CharEncoding>
+ , fusion::vector1<Char(&)[2]> // single char strings
+ >
+ , Modifiers>
+ {
+ typedef char_token_def<CharEncoding> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args)[0]);
+ }
+ };
+
 }}} // namespace boost::spirit::lex
 
 #endif

Modified: branches/release/boost/spirit/home/lex/lexer/lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexer.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,79 +6,81 @@
 #if !defined(BOOST_SPIRIT_LEX_LEXER_MAR_13_2007_0145PM)
 #define BOOST_SPIRIT_LEX_LEXER_MAR_13_2007_0145PM
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
+#if defined(_MSC_VER)
+#pragma once
 #endif
 
-#include <boost/spirit/home/support/safe_bool.hpp>
-#include <boost/spirit/home/lex/lexer/lexer_fwd.hpp>
-#include <boost/spirit/home/lex/lexer/terminal_holder.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/qi/skip_over.hpp>
+#include <boost/spirit/home/qi/parser.hpp>
+#include <boost/spirit/home/qi/detail/assign_to.hpp>
+#include <boost/spirit/home/lex/reference.hpp>
+#include <boost/spirit/home/lex/meta_compiler.hpp>
+#include <boost/spirit/home/lex/lexer_type.hpp>
 #include <boost/spirit/home/lex/lexer/token_def.hpp>
+#include <boost/assert.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/detail/iterator.hpp>
 #include <boost/fusion/include/vector.hpp>
-#include <boost/assert.hpp>
 #include <boost/mpl/assert.hpp>
-#include <string>
 #include <boost/range/iterator_range.hpp>
+#include <string>
 
 namespace boost { namespace spirit { namespace lex
 {
+ ///////////////////////////////////////////////////////////////////////////
     namespace detail
     {
         ///////////////////////////////////////////////////////////////////////
         template <typename LexerDef>
         struct lexer_def_
- : public proto::extends<
- typename make_terminal_holder<
- lexer_def_<LexerDef> const*, lexer_def_<LexerDef>
- >::type,
- lexer_def_<LexerDef>
- >
+ : proto::extends<
+ typename proto::terminal<
+ lex::reference<lexer_def_<LexerDef> const>
+ >::type
+ , lexer_def_<LexerDef> >
+ , qi::parser<lexer_def_<LexerDef> >
+ , lex::lexer_type<lexer_def_<LexerDef> >
+// , noncopyable
         {
         private:
             // avoid warnings about using 'this' in constructor
- lexer_def_& this_() { return *this; }
-
- // initialize proto base class
- typedef
- terminal_holder<lexer_def_ const*, lexer_def_>
- terminal_holder_;
- typedef typename proto::terminal<terminal_holder_>::type tag;
- typedef proto::extends<tag, lexer_def_> base_type;
+ lexer_def_& this_() { return *this; }
 
+ typedef typename LexerDef::char_type char_type;
+ typedef typename LexerDef::string_type string_type;
             typedef typename LexerDef::id_type id_type;
-
- tag make_tag() const
+
+ typedef lex::reference<lexer_def_ const> reference_;
+ typedef typename proto::terminal<reference_>::type terminal_type;
+ typedef proto::extends<terminal_type, lexer_def_> proto_base_type;
+
+ reference_ alias() const
             {
- tag xpr = {{ this }};
- return xpr;
+ return reference_(*this);
             }
-
- typedef typename LexerDef::char_type char_type;
- typedef typename LexerDef::string_type string_type;
 
         public:
- // Qi interface: metafunction calculating parser return type
- template <typename Component, typename Context, typename Iterator>
+ // Qi interface: metafunction calculating parser attribute type
+ template <typename Context, typename Iterator>
             struct attribute
             {
                 // the return value of a token set contains the matched token
                 // id, and the corresponding pair of iterators
                 typedef typename Iterator::base_iterator_type iterator_type;
                 typedef
- fusion::vector<id_type, iterator_range<iterator_type> >
+ fusion::vector2<id_type, iterator_range<iterator_type> >
                 type;
             };
-
- private:
+
             // Qi interface: parse functionality
- template <typename Iterator, typename Context, typename Skipper,
- typename Attribute>
- bool parse(Iterator& first, Iterator const& last,
- Context& context, Skipper const& skipper, Attribute& attr) const
+ template <typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context& /*context*/, Skipper const& skipper
+ , Attribute& attr) const
             {
- qi::skip(first, last, skipper); // always do a pre-skip
+ qi::skip_over(first, last, skipper); // always do a pre-skip
 
                 if (first != last) {
                     typedef typename
@@ -86,7 +88,7 @@
                     token_type;
 
                     token_type &t = *first;
- if (token_is_valid(t)) {
+ if (token_is_valid(t) && t.state() == first.get_state()) {
                     // any of the token definitions matched
                         qi::detail::assign_to(t, attr);
                         ++first;
@@ -95,47 +97,58 @@
                 }
                 return false;
             }
- friend struct terminal_director;
 
- static std::string what()
+ // Qi interface: 'what' functionality
+ template <typename Context>
+ info what(Context& /*context*/) const
             {
- return "lexer";
+ return info("lexer");
             }
 
+ private:
             // allow to use the lexer.self.add("regex1", id1)("regex2", id2);
             // syntax
             struct adder
             {
                 adder(lexer_def_& def_)
- : def(def_)
- {}
+ : def(def_) {}
 
- adder const&
- operator()(char_type c, id_type token_id = 0) const
+ // Add a token definition based on a single character as given
+ // by the first parameter, the second parameter allows to
+ // specify the token id to use for the new token. If no token
+ // id is given the character code is used.
+ adder const& operator()(char_type c
+ , id_type token_id = id_type()) const
                 {
- if (0 == token_id)
+ if (id_type() == token_id)
                         token_id = static_cast<id_type>(c);
- def.def.add_token (def.state.c_str(), lex::detail::escape(c),
- token_id);
+ def.def.add_token (def.state.c_str(), c, token_id);
                     return *this;
                 }
- adder const&
- operator()(string_type const& s, id_type token_id = id_type()) const
+
+ // Add a token definition based on a character sequence as
+ // given by the first parameter, the second parameter allows to
+ // specify the token id to use for the new token. If no token
+ // id is given this function will generate a unique id to be
+ // used as the token's id.
+ adder const& operator()(string_type const& s
+ , id_type token_id = id_type()) const
                 {
- if (0 == token_id)
- token_id = next_id<id_type>::get();
+ if (id_type() == token_id)
+ token_id = def.def.get_next_id();
                     def.def.add_token (def.state.c_str(), s, token_id);
                     return *this;
                 }
+
                 template <typename Attribute>
- adder const&
- operator()(token_def<Attribute, char_type, id_type>& tokdef,
- id_type token_id = id_type()) const
+ adder const& operator()(
+ token_def<Attribute, char_type, id_type>& tokdef
+ , id_type token_id = id_type()) const
                 {
                     // make sure we have a token id
- if (0 == token_id) {
- if (0 == tokdef.id()) {
- token_id = next_id<id_type>::get();
+ if (id_type() == token_id) {
+ if (id_type() == tokdef.id()) {
+ token_id = def.def.get_next_id();
                             tokdef.id(token_id);
                         }
                         else {
@@ -143,37 +156,30 @@
                         }
                     }
                     else {
- // the following assertion makes sure, that the token_def
+ // the following assertion makes sure that the token_def
                     // instance has not been assigned a different id earlier
- BOOST_ASSERT(0 == tokdef.id() || token_id == tokdef.id());
+ BOOST_ASSERT(id_type() == tokdef.id()
+ || token_id == tokdef.id());
                         tokdef.id(token_id);
                     }
-
+
                     def.define(tokdef);
                     return *this;
                 }
- template <typename TokenSet>
- adder const&
- operator()(token_set<TokenSet>& tokset) const
- {
- def.define(tokset);
- return *this;
- }
 
                 lexer_def_& def;
             };
             friend struct adder;
-
+
             // allow to use lexer.self.add_pattern("pattern1", "regex1")(...);
             // syntax
             struct pattern_adder
             {
                 pattern_adder(lexer_def_& def_)
- : def(def_)
- {}
+ : def(def_) {}
 
- pattern_adder const&
- operator()(string_type const& p, string_type const& s) const
+ pattern_adder const& operator()(string_type const& p
+ , string_type const& s) const
                 {
                     def.def.add_pattern (def.state.c_str(), p, s);
                     return *this;
@@ -182,26 +188,29 @@
                 lexer_def_& def;
             };
             friend struct pattern_adder;
-
+
+ private:
+ // Helper function to invoke the necessary 2 step compilation
+ // process on token definition expressions
+ template <typename TokenExpr>
+ void compile2pass(TokenExpr const& expr)
+ {
+ expr.collect(def, state);
+ expr.add_actions(def);
+ }
+
         public:
             ///////////////////////////////////////////////////////////////////
             template <typename Expr>
- void define(Expr const& xpr)
+ void define(Expr const& expr)
             {
- typedef typename
- result_of::as_component<lex::domain, Expr>::type
- component;
- typedef typename component::director director;
-
- component c = spirit::as_component(lex::domain(), xpr);
- director::collect(c, def, state);
+ compile2pass(compile<lex::domain>(expr));
             }
 
             lexer_def_(LexerDef& def_, string_type const& state_)
- : base_type(make_tag()), add(this_()), add_pattern(this_()),
- def(def_), state(state_)
- {
- }
+ : proto_base_type(terminal_type::make(alias()))
+ , add(this_()), add_pattern(this_()), def(def_), state(state_)
+ {}
 
             // allow to switch states
             lexer_def_ operator()(char_type const* state) const
@@ -212,19 +221,16 @@
             {
                 return lexer_def_(def, state);
             }
-
+
             // allow to assign a token definition expression
             template <typename Expr>
             lexer_def_& operator= (Expr const& xpr)
             {
- typedef
- spirit::traits::is_component<lex::domain, Expr>
- is_component;
-
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(
- is_component::value,
- xpr_is_not_convertible_to_a_token_definition, ());
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit lex
+ // expression.
+ BOOST_SPIRIT_ASSERT_MATCH(lex::domain, Expr);
 
                 def.clear(state.c_str());
                 define(xpr);
@@ -233,42 +239,36 @@
 
             adder add;
             pattern_adder add_pattern;
-
+
         private:
             LexerDef& def;
             string_type state;
         };
-
+
         // allow to assign a token definition expression
         template <typename LexerDef, typename Expr>
         inline lexer_def_<LexerDef>&
         operator+= (lexer_def_<LexerDef>& lexdef, Expr& xpr)
         {
- typedef
- spirit::traits::is_component<lex::domain, Expr>
- is_component;
-
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(
- is_component::value,
- xpr_is_not_convertible_to_a_token_definition, ());
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit lex
+ // expression.
+ BOOST_SPIRIT_ASSERT_MATCH(lex::domain, Expr);
 
             lexdef.define(xpr);
             return lexdef;
         }
-
+
         template <typename LexerDef, typename Expr>
         inline lexer_def_<LexerDef>&
         operator+= (lexer_def_<LexerDef>& lexdef, Expr const& xpr)
         {
- typedef
- spirit::traits::is_component<lex::domain, Expr>
- is_component;
-
- // report invalid expression error as early as possible
- BOOST_MPL_ASSERT_MSG(
- is_component::value,
- xpr_is_not_convertible_to_a_token_definition, ());
+ // Report invalid expression error as early as possible.
+ // If you got an error_invalid_expression error message here,
+ // then the expression (expr) is not a valid spirit lex
+ // expression.
+ BOOST_SPIRIT_ASSERT_MATCH(lex::domain, Expr);
 
             lexdef.define(xpr);
             return lexdef;
@@ -276,96 +276,73 @@
     }
 
     ///////////////////////////////////////////////////////////////////////////
- // This represents a lexer definition (helper for token and token set
- // definitions
+ // The match_flags flags are used to influence different matching
+ // modes of the lexer
+ struct match_flags
+ {
+ enum enum_type
+ {
+ match_default = 0, // no flags
+ match_not_dot_newline = 1, // the regex '.' doesn't match newlines
+ match_icase = 2 // all matching operations are case insensitive
+ };
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // This represents a lexer object
     ///////////////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////////////
+ // This is the first token id automatically assigned by the library
+ // if needed
+ enum tokenids
+ {
+ min_token_id = 0x10000
+ };
+
     template <typename Lexer>
- class lexer_def : private noncopyable, public Lexer
+ class lexer : public Lexer
     {
     private:
- typedef lexer_def self_type;
-
         // avoid warnings about using 'this' in constructor
- lexer_def& this_() { return *this; }
+ lexer& this_() { return *this; }
+
+ typename Lexer::id_type next_token_id;
 
- public:
+ public:
         typedef Lexer lexer_type;
         typedef typename Lexer::id_type id_type;
- typedef detail::lexer_def_<self_type> token_set;
         typedef typename Lexer::char_type char_type;
- typedef std::basic_string<char_type> string_type;
-
- lexer_def()
- : self(this_(), Lexer::initial_state())
- {
- }
-
- token_set self; // allow for easy token definition
-
- // this is just a dummy implementation to allow to use lexer_def
- // directly, without having to derive a separate class
- void def(token_set& /*self*/) {}
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // This represents a lexer object
- ///////////////////////////////////////////////////////////////////////////
- template <typename Definition>
- class lexer : public safe_bool<lexer<Definition> >
- {
- public:
- // operator_bool() is needed for the safe_bool base class
- bool operator_bool() const { return token_def; }
+ typedef typename Lexer::iterator_type iterator_type;
+ typedef lexer base_type;
 
- typedef typename Definition::lexer_type lexer_type;
- typedef typename Definition::char_type char_type;
- typedef typename Definition::iterator_type iterator_type;
- typedef typename Definition::id_type id_type;
+ typedef detail::lexer_def_<lexer> lexer_def;
+ typedef std::basic_string<char_type> string_type;
 
- lexer(Definition& token_def_)
- : token_def(token_def_)
- {
- // call initialization routine supplied by the target lexer
- token_def.def(token_def.self);
- }
+ lexer(unsigned int flags = match_flags::match_default
+ , id_type first_id = min_token_id)
+ : lexer_type(flags)
+ , next_token_id(first_id)
+ , self(this_(), lexer_type::initial_state())
+ {}
 
         // access iterator interface
         template <typename Iterator>
- iterator_type begin(Iterator& first, Iterator const& last) const
- { return token_def.begin(first, last); }
- iterator_type end() const { return token_def.end(); }
-
+ iterator_type begin(Iterator& first, Iterator const& last
+ , char_type const* initial_state = 0) const
+ { return this->lexer_type::begin(first, last, initial_state); }
+ iterator_type end() const
+ { return this->lexer_type::end(); }
+
         std::size_t map_state(char_type const* state)
- { return token_def.add_state(state); }
-
- Definition& get_definition() { return token_def; }
- Definition const& get_definition() const { return token_def; }
-
- private:
- Definition& token_def;
- };
+ { return this->lexer_type::add_state(state); }
 
- ///////////////////////////////////////////////////////////////////////////
- // Metafunction returning the iterator type of the lexer given the token
- // definition type.
- ///////////////////////////////////////////////////////////////////////////
- template <typename Definition>
- struct lexer_iterator
- {
- typedef typename lexer<Definition>::iterator_type type;
+ // create a unique token id
+ id_type get_next_id() { return next_token_id++; }
+
+ lexer_def self; // allow for easy token definition
     };
 
- ///////////////////////////////////////////////////////////////////////////
- // Generator function helping to construct a proper lexer object
- // instance
- ///////////////////////////////////////////////////////////////////////////
- template <typename Definition>
- inline lexer<Definition>
- make_lexer(Definition& def)
- {
- return lexer<Definition>(def);
- }
-
 }}}
 
 #endif

Deleted: branches/release/boost/spirit/home/lex/lexer/lexer_actions.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexer_actions.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,47 +0,0 @@
-// Copyright (c) 2001-2009 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_LEX_LEXER_ACTIONS_FEB_13_2008_1232PM)
-#define BOOST_SPIRIT_LEX_LEXER_ACTIONS_FEB_13_2008_1232PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <iosfwd>
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace lex
-{
- ///////////////////////////////////////////////////////////////////////////
- template <typename Char, typename Traits>
- struct echo_input_functor
- {
- echo_input_functor (std::basic_ostream<Char, Traits>& os_)
- : os(os_)
- {
- }
-
- template <typename Range, typename LexerContext>
- void operator()(Range const& r, std::size_t, bool&, LexerContext&) const
- {
- os << r;
- }
-
- std::basic_ostream<Char, Traits>& os;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Char, typename Traits>
- inline echo_input_functor<Char, Traits>
- echo_input(std::basic_ostream<Char, Traits>& os)
- {
- return echo_input_functor<Char, Traits>(os);
- }
-
-///////////////////////////////////////////////////////////////////////////////
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/lex/lexer/lexer_fwd.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexer_fwd.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,45 +0,0 @@
-// Copyright (c) 2001-2009 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_LEX_LEXER_FWD_MAR_22_2007_1137PM)
-#define BOOST_SPIRIT_LEX_LEXER_FWD_MAR_22_2007_1137PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/unused.hpp>
-
-namespace boost { namespace spirit { namespace lex
-{
- ///////////////////////////////////////////////////////////////////////////
- // This component represents a token definition
- ///////////////////////////////////////////////////////////////////////////
- template<typename Attribute = unused_type, typename Char = char,
- typename Idtype = std::size_t>
- class token_def;
-
- ///////////////////////////////////////////////////////////////////////////
- // token_set
- ///////////////////////////////////////////////////////////////////////////
- template <typename TokenSet>
- class token_set;
-
- ///////////////////////////////////////////////////////////////////////////
- // This represents a lexer definition (helper for token and token set
- // definitions)
- ///////////////////////////////////////////////////////////////////////////
- template <typename Lexer>
- class lexer_def;
-
- ///////////////////////////////////////////////////////////////////////////
- // This represents a lexer object
- ///////////////////////////////////////////////////////////////////////////
- template <typename Definition>
- class lexer;
-
-}}}
-
-#endif

Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
@@ -6,6 +6,10 @@
 #if !defined(BOOST_SPIRIT_LEXERTL_ITERATOR_TOKENISER_MARCH_22_2007_0859AM)
 #define BOOST_SPIRIT_LEXERTL_ITERATOR_TOKENISER_MARCH_22_2007_0859AM
 
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
 #include <boost/detail/iterator.hpp>
 #include <boost/spirit/home/support/detail/lexer/state_machine.hpp>
 #include <boost/spirit/home/support/detail/lexer/consts.hpp>
@@ -13,105 +17,35 @@
 #include <boost/spirit/home/support/detail/lexer/char_traits.hpp>
 #include <vector>
 
-namespace boost { namespace spirit { namespace lex
+namespace boost { namespace spirit { namespace lex { namespace lexertl
 {
+ ///////////////////////////////////////////////////////////////////////////
     template<typename Iterator>
     class basic_iterator_tokeniser
     {
     public:
         typedef std::vector<std::size_t> size_t_vector;
- typedef
- typename boost::detail::iterator_traits<Iterator>::value_type
- char_type;
-
-// static std::size_t next (const std::size_t * const lookup_,
-// std::size_t const dfa_alphabet_, const std::size_t * const dfa_,
-// Iterator const& start_, Iterator &start_token_,
-// Iterator const& end_)
-// {
-// if (start_token_ == end_) return 0;
-//
-// const std::size_t *ptr_ = dfa_ + dfa_alphabet_;
-// Iterator curr_ = start_token_;
-// bool end_state_ = *ptr_ != 0;
-// std::size_t id_ = *(ptr_ + lexer::id_index);
-// Iterator end_token_ = start_token_;
-//
-// while (curr_ != end_)
-// {
-// std::size_t const BOL_state_ = ptr_[lexer::bol_index];
-// std::size_t const EOL_state_ = ptr_[lexer::eol_index];
-//
-// if (BOL_state_ && (start_token_ == start_ ||
-// *(start_token_ - 1) == '\n'))
-// {
-// ptr_ = &dfa_[BOL_state_ * dfa_alphabet_];
-// }
-// else if (EOL_state_ && *curr_ == '\n')
-// {
-// ptr_ = &dfa_[EOL_state_ * dfa_alphabet_];
-// }
-// else
-// {
-// std::size_t const state_ = ptr_[lookup_[*curr_++]];
-//
-// if (state_ == 0)
-// {
-// break;
-// }
-//
-// ptr_ = &dfa_[state_ * dfa_alphabet_];
-// }
-//
-// if (*ptr_)
-// {
-// end_state_ = true;
-// id_ = *(ptr_ + lexer::id_index);
-// end_token_ = curr_;
-// }
-// }
-//
-// const std::size_t EOL_state_ = ptr_[lexer::eol_index];
-//
-// if (EOL_state_ && curr_ == end_)
-// {
-// ptr_ = &dfa_[EOL_state_ * dfa_alphabet_];
-//
-// if (*ptr_)
-// {
-// end_state_ = true;
-// id_ = *(ptr_ + lexer::id_index);
-// end_token_ = curr_;
-// }
-// }
-//
-// if (end_state_) {
-// // return longest match
-// start_token_ = end_token_;
-// }
-// else {
-// id_ = lexer::npos;
-// }
-//
-// return id_;
-// }
+ typedef typename boost::detail::iterator_traits<Iterator>::value_type
+ char_type;
 
         static std::size_t next (
- boost::lexer::basic_state_machine<char_type> const& state_machine_,
- std::size_t &dfa_state_, Iterator const& start_,
- Iterator &start_token_, Iterator const& end_)
+ boost::lexer::basic_state_machine<char_type> const& state_machine_
+ , std::size_t &dfa_state_, Iterator const& start_
+ , Iterator &start_token_, Iterator const& end_
+ , std::size_t& unique_id_)
         {
             if (start_token_ == end_) return 0;
 
         again:
- std::size_t const* lookup_ = &state_machine_._lookup[dfa_state_]->
+ std::size_t const* lookup_ = &state_machine_.data()._lookup[dfa_state_]->
                 front ();
- std::size_t dfa_alphabet_ = state_machine_._dfa_alphabet[dfa_state_];
- std::size_t const* dfa_ = &state_machine_._dfa[dfa_state_]->front ();
+ std::size_t dfa_alphabet_ = state_machine_.data()._dfa_alphabet[dfa_state_];
+ std::size_t const* dfa_ = &state_machine_.data()._dfa[dfa_state_]->front ();
             std::size_t const* ptr_ = dfa_ + dfa_alphabet_;
             Iterator curr_ = start_token_;
             bool end_state_ = *ptr_ != 0;
             std::size_t id_ = *(ptr_ + boost::lexer::id_index);
+ std::size_t uid_ = *(ptr_ + boost::lexer::unique_id_index);
             Iterator end_token_ = start_token_;
 
             while (curr_ != end_)
@@ -136,7 +70,7 @@
                     typedef typename
                         boost::lexer::char_traits<value_type>::index_type
                     index_type;
-
+
                     index_type index =
                         boost::lexer::char_traits<value_type>::call(*curr_++);
                     std::size_t const state_ = ptr_[
@@ -154,6 +88,7 @@
                 {
                     end_state_ = true;
                     id_ = *(ptr_ + boost::lexer::id_index);
+ uid_ = *(ptr_ + boost::lexer::unique_id_index);
                     dfa_state_ = *(ptr_ + boost::lexer::state_index);
                     end_token_ = curr_;
                 }
@@ -169,6 +104,7 @@
                 {
                     end_state_ = true;
                     id_ = *(ptr_ + boost::lexer::id_index);
+ uid_ = *(ptr_ + boost::lexer::unique_id_index);
                     dfa_state_ = *(ptr_ + boost::lexer::state_index);
                     end_token_ = curr_;
                 }
@@ -183,26 +119,29 @@
             }
             else {
                 id_ = boost::lexer::npos;
+ uid_ = boost::lexer::npos;
             }
-
+
+ unique_id_ = uid_;
             return id_;
         }
 
         ///////////////////////////////////////////////////////////////////////
- static
- std::size_t next (
- boost::lexer::basic_state_machine<char_type> const& state_machine_,
- Iterator const& start_, Iterator &start_token_, Iterator const& end_)
+ static std::size_t next (
+ boost::lexer::basic_state_machine<char_type> const& state_machine_
+ , Iterator const& start_, Iterator &start_token_, Iterator const& end_
+ , std::size_t& unique_id_)
         {
             if (start_token_ == end_) return 0;
 
- std::size_t const* lookup_ = &state_machine_._lookup[0]->front();
- std::size_t dfa_alphabet_ = state_machine_._dfa_alphabet[0];
- std::size_t const* dfa_ = &state_machine_._dfa[0]->front ();
+ std::size_t const* lookup_ = &state_machine_.data()._lookup[0]->front();
+ std::size_t dfa_alphabet_ = state_machine_.data()._dfa_alphabet[0];
+ std::size_t const* dfa_ = &state_machine_.data()._dfa[0]->front ();
             std::size_t const* ptr_ = dfa_ + dfa_alphabet_;
             Iterator curr_ = start_token_;
             bool end_state_ = *ptr_ != 0;
             std::size_t id_ = *(ptr_ + boost::lexer::id_index);
+ std::size_t uid_ = *(ptr_ + boost::lexer::unique_id_index);
             Iterator end_token_ = start_token_;
 
             while (curr_ != end_)
@@ -245,6 +184,7 @@
                 {
                     end_state_ = true;
                     id_ = *(ptr_ + boost::lexer::id_index);
+ uid_ = *(ptr_ + boost::lexer::unique_id_index);
                     end_token_ = curr_;
                 }
             }
@@ -259,6 +199,7 @@
                 {
                     end_state_ = true;
                     id_ = *(ptr_ + boost::lexer::id_index);
+ uid_ = *(ptr_ + boost::lexer::unique_id_index);
                     end_token_ = curr_;
                 }
             }
@@ -269,8 +210,10 @@
             }
             else {
                 id_ = boost::lexer::npos;
+ uid_ = boost::lexer::npos;
             }
-
+
+ unique_id_ = uid_;
             return id_;
         }
     };
@@ -279,6 +222,6 @@
     typedef basic_iterator_tokeniser<char const *> tokeniser;
     typedef basic_iterator_tokeniser<wchar_t const *> wtokeniser;
 
-}}}
+}}}}
 
 #endif

Deleted: branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,394 +0,0 @@
-// Copyright (c) 2001-2009 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_LEX_LEXER_FUNCTOR_NOV_18_2007_1112PM)
-#define BOOST_SPIRIT_LEX_LEXER_FUNCTOR_NOV_18_2007_1112PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/mpl/bool.hpp>
-#include <boost/function.hpp>
-#include <boost/range/iterator_range.hpp>
-#include <boost/detail/iterator.hpp>
-#include <boost/detail/workaround.hpp>
-#include <map>
-#include <boost/spirit/home/support/detail/lexer/generator.hpp>
-#include <boost/spirit/home/support/detail/lexer/rules.hpp>
-#include <boost/spirit/home/support/detail/lexer/state_machine.hpp>
-#include <boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp>
-#include <boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp>
-
-#if 0 != __COMO_VERSION__ || !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
-#define BOOST_SPIRIT_STATIC_EOF 1
-#define BOOST_SPIRIT_EOF_PREFIX static
-#else
-#define BOOST_SPIRIT_EOF_PREFIX
-#endif
-
-namespace boost { namespace spirit { namespace lex
-{
- namespace detail
- {
- ///////////////////////////////////////////////////////////////////////
- template <typename Iterator, typename HasActors, typename HasState>
- struct Data; // no default specialization
-
- ///////////////////////////////////////////////////////////////////////
- // doesn't support no state and no actors
- template <typename Iterator>
- struct Data<Iterator, mpl::false_, mpl::false_>
- {
- typedef std::size_t state_type;
- typedef iterator_range<Iterator> iterpair_type;
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
- char_type;
-
- typedef unused_type semantic_actions_type;
-
- typedef
- detail::wrap_action<unused_type, iterpair_type, Data>
- wrap_action_type;
-
- // initialize the shared data
- template <typename IterData>
- Data (IterData const& data_, Iterator& first_, Iterator const& last_)
- : state_machine(data_.state_machine_),
- rules(data_.rules_),
- first(first_), last(last_)
- {}
-
- std::size_t next(Iterator& end)
- {
- typedef basic_iterator_tokeniser<Iterator> tokenizer;
- return tokenizer::next(state_machine, first, end, last);
- }
-
- // nothing to invoke, so this is empty
- bool invoke_actions(std::size_t, Iterator const&)
- {
- return true; // always accept
- }
-
- std::size_t get_state() const { return 0; }
- void set_state_name (char_type const* state) {}
-
- boost::lexer::basic_state_machine<char_type> const& state_machine;
- boost::lexer::basic_rules<char_type> const& rules;
- Iterator& first;
- Iterator last;
- };
-
- ///////////////////////////////////////////////////////////////////////
- // doesn't support actors
- template <typename Iterator>
- struct Data<Iterator, mpl::false_, mpl::true_>
- : Data<Iterator, mpl::false_, mpl::false_>
- {
- typedef Data<Iterator, mpl::false_, mpl::false_> base_type;
-
- typedef typename base_type::state_type state_type;
- typedef typename base_type::char_type char_type;
- typedef
- typename base_type::semantic_actions_type
- semantic_actions_type;
-
- // initialize the shared data
- template <typename IterData>
- Data (IterData const& data_, Iterator& first_, Iterator const& last_)
- : base_type(data_, first_, last_), state(0)
- {}
-
- std::size_t next(Iterator& end)
- {
- typedef basic_iterator_tokeniser<Iterator> tokenizer;
- return tokenizer::next(this->state_machine, state,
- this->first, end, this->last);
- }
-
- std::size_t& get_state() { return state; }
- void set_state_name (char_type const* new_state)
- {
- std::size_t state_id = this->rules.state(new_state);
-
- // if the following assertion fires you've probably been using
- // a lexer state name which was not defined in your token
- // definition
- BOOST_ASSERT(state_id != boost::lexer::npos);
-
- if (state_id != boost::lexer::npos)
- state = state_id;
- }
-
- std::size_t state;
- };
-
- ///////////////////////////////////////////////////////////////////////
- // does support actors, but may have no state
- template <typename Iterator, typename HasState>
- struct Data<Iterator, mpl::true_, HasState>
- : Data<Iterator, mpl::false_, HasState>
- {
- typedef Data<Iterator, mpl::false_, HasState> base_type;
-
- typedef iterator_range<Iterator> iterpair_type;
- typedef typename base_type::state_type state_type;
- typedef typename base_type::char_type char_type;
-
- typedef void functor_type(iterpair_type, std::size_t, bool&, Data&);
- typedef boost::function<functor_type> functor_wrapper_type;
- typedef std::multimap<std::size_t, functor_wrapper_type>
- semantic_actions_type;
-
- typedef
- detail::wrap_action<functor_wrapper_type, iterpair_type, Data>
- wrap_action_type;
-
- template <typename IterData>
- Data (IterData const& data_, Iterator& first_, Iterator const& last_)
- : base_type(data_, first_, last_),
- actions(data_.actions_)
- {}
-
- // invoke attached semantic actions, if defined
- bool invoke_actions(std::size_t id, Iterator const& end)
- {
- if (actions.empty())
- return true; // nothing to invoke, continue with 'match'
-
- iterpair_type itp(this->first, end);
- bool match = true;
-
- typedef typename
- semantic_actions_type::const_iterator
- iterator_type;
-
- std::pair<iterator_type, iterator_type> p = actions.equal_range(id);
- while (p.first != p.second)
- {
- ((*p.first).second)(itp, id, match, *this);
- if (!match)
- return false; // return a 'no-match'
- ++p.first;
- }
- return true; // normal execution
- }
-
- semantic_actions_type const& actions;
- };
- }
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // lexertl_functor is a template usable as the functor object for the
- // multi_pass iterator allowing to wrap a lexertl based dfa into a
- // iterator based interface.
- //
- // Iterator: the type of the underlying iterator
- // Token: the type of the tokens produced by this functor
- // this needs to expose a constructor with the following
- // prototype:
- //
- // Token(std::size_t id, std::size_t state,
- // Iterator start, Iterator end)
- //
- // where 'id' is the token id, state is the lexer state,
- // this token has been matched in, and 'first' and 'end'
- // mark the start and the end of the token with respect
- // to the underlying character stream.
- // SupportsActors:
- // this is expected to be a mpl::bool_, if mpl::true_ the
- // lexertl_functor invokes functors which (optionally) have
- // been attached to the token definitions.
- // SupportState:
- // this is expected to be a mpl::bool_, if mpl::true_ the
- // lexertl_functor supports different lexer states,
- // otherwise no lexer state is supported.
- //
- ///////////////////////////////////////////////////////////////////////////
- template <typename Token,
- typename Iterator = typename Token::iterator_type,
- typename SupportsActors = mpl::false_,
- typename SupportsState = typename Token::has_state>
- class lexertl_functor
- {
- public:
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
- char_type;
-
- private:
- // Needed by compilers not implementing the resolution to DR45. For
- // reference, see
- // http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45.
- template <typename Iterator_, typename HasActors, typename HasState>
- friend struct detail::Data;
-
- // Helper template allowing to assign a value on exit
- template <typename T>
- struct assign_on_exit
- {
- assign_on_exit(T& dst_, T const& src_)
- : dst(dst_), src(src_)
- {}
- ~assign_on_exit()
- {
- dst = src;
- }
-
- T& dst;
- T const& src;
- };
-
- public:
- lexertl_functor()
-#if defined(__PGI)
- : eof()
-#endif
- {}
-
-#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
- // somehow VC7.1 needs this (meaningless) assignment operator
- lexertl_functor& operator=(lexertl_functor const& rhs)
- {
- return *this;
- }
-#endif
-
- ///////////////////////////////////////////////////////////////////////
- // interface to the multi_pass_policies::split_functor_input policy
- typedef Token result_type;
- typedef lexertl_functor unique;
- typedef detail::Data<Iterator, SupportsActors, SupportsState> shared;
-
- BOOST_SPIRIT_EOF_PREFIX result_type const eof;
-
- ///////////////////////////////////////////////////////////////////////
- typedef Iterator iterator_type;
- typedef typename shared::semantic_actions_type semantic_actions_type;
-
- // this is needed to wrap the semantic actions in a proper way
- typedef typename shared::wrap_action_type wrap_action_type;
-
- ///////////////////////////////////////////////////////////////////////
- template <typename MultiPass>
- static result_type& get_next(MultiPass& mp, result_type& result)
- {
- shared& data = mp.shared->ftor;
- if (data.first == data.last)
-#if defined(BOOST_SPIRIT_STATIC_EOF)
- return result = eof;
-#else
- return result = mp.ftor.eof;
-#endif
-
- Iterator end = data.first;
- std::size_t id = data.next(end);
-
- if (boost::lexer::npos == id) { // no match
-#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
- std::string next;
- Iterator it = data.first;
- for (std::size_t i = 0; i < 10 && it != data.last; ++it, ++i)
- next += *it;
-
- std::cerr << "Not matched, in state: " << data.state
- << ", lookahead: >" << next << "<" << std::endl;
-#endif
- result = result_type(0);
- }
- else if (0 == id) { // EOF reached
-#if defined(BOOST_SPIRIT_STATIC_EOF)
- result = eof;
-#else
- result = mp.ftor.eof;
-#endif
- }
- else {
-#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
- {
- std::string next;
- Iterator it = data.first;
- for (std::size_t i = 0; i < 10 && it != data.last; ++it, ++i)
- next += *it;
-
- std::cerr << "Matched: " << id << ", in state: "
- << data.state << ", string: >"
- << std::basic_string<char_type>(data.first, end) << "<"
- << ", lookahead: >" << next << "<" << std::endl;
- }
-#endif
- // invoke_actions might change state
- std::size_t state = data.get_state();
-
- // invoke attached semantic actions, if defined
- if (!data.invoke_actions(id, end))
- {
- // one of the semantic actions signaled no-match
- result = result_type(0);
- }
- else
- {
- // return matched token, advancing 'data.first' past the
- // matched sequence
- assign_on_exit<Iterator> on_exit(data.first, end);
- result = result_type(id, state, data.first, end);
- }
- }
- return result;
- }
-
- // set_state are propagated up to the iterator interface, allowing to
- // manipulate the current lexer state through any of the exposed
- // iterators.
- template <typename MultiPass>
- static std::size_t set_state(MultiPass& mp, std::size_t state_)
- {
- std::size_t oldstate = mp.shared->ftor.state;
- mp.shared->ftor.state = state_;
-
-#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
- std::cerr << "Switching state from: " << oldstate
- << " to: " << state_
- << std::endl;
-#endif
- return oldstate;
- }
-
- template <typename MultiPass>
- static std::size_t
- map_state(MultiPass const& mp, char_type const* statename)
- {
- return mp.shared->ftor.rules.state(statename);
- }
-
- // we don't need this, but it must be there
- template <typename MultiPass>
- static void destroy(MultiPass const&)
- {}
- };
-
-#if defined(BOOST_SPIRIT_STATIC_EOF)
- ///////////////////////////////////////////////////////////////////////////
- // eof token
- ///////////////////////////////////////////////////////////////////////////
- template <typename Token, typename Iterator, typename SupportsActors,
- typename SupportsState>
- typename lexertl_functor<
- Token, Iterator, SupportsActors, SupportsState>::result_type const
- lexertl_functor<
- Token, Iterator, SupportsActors, SupportsState>::eof =
- typename lexertl_functor<
- Token, Iterator, SupportsActors, SupportsState>::result_type();
-#endif
-
-}}}
-
-#undef BOOST_SPIRIT_EOF_PREFIX
-#undef BOOST_SPIRIT_STATIC_EOF
-
-#endif

Deleted: branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_generate_static.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_generate_static.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,559 +0,0 @@
-// Copyright (c) 2008 Ben Hanson
-// Copyright (c) 2009 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_LEX_LEXERTL_GENERATE_CPP_FEB_10_2008_0855PM)
-#define BOOST_SPIRIT_LEX_LEXERTL_GENERATE_CPP_FEB_10_2008_0855PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>
-#include <boost/spirit/home/support/detail/lexer/consts.hpp>
-#include <boost/spirit/home/support/detail/lexer/size_t.hpp>
-#include <boost/spirit/home/support/detail/lexer/state_machine.hpp>
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace lex { namespace detail
-{
- ///////////////////////////////////////////////////////////////////////////
- // Generate a table of the names of the used lexer states, which is a bit
- // tricky, because the table stored with the rules is sorted based on the
- // names, but we need it sorted using the state ids.
- template <typename Char>
- inline bool
- generate_cpp_state_names (boost::lexer::basic_rules<Char> const& rules_,
- std::ostream &os_, char const* name_suffix = "")
- {
- // we need to re-sort the state names in ascending order if the state
- // ids, filling possible gaps in between later
- typedef typename
- boost::lexer::basic_rules<Char>::string_size_t_map::const_iterator
- state_iterator;
- typedef std::map<std::size_t, char const*> reverse_state_map_type;
-
- reverse_state_map_type reverse_state_map;
- state_iterator send = rules_.statemap().end();
- for (state_iterator sit = rules_.statemap().begin(); sit != send; ++sit)
- {
- typedef typename reverse_state_map_type::value_type value_type;
- reverse_state_map.insert(value_type((*sit).second, (*sit).first.c_str()));
- }
-
- os_ << "// this table defines the names of the lexer states\n";
- os_ << "char const* const lexer_state_names" << name_suffix
- << "[" << rules_.statemap().size() << "] = \n{\n";
-
- typedef typename reverse_state_map_type::iterator iterator;
- iterator rend = reverse_state_map.end();
- std::size_t last_id = 0;
- for (iterator rit = reverse_state_map.begin(); rit != rend; ++rit)
- {
- for (/**/; last_id < (*rit).first; ++last_id)
- {
- os_ << " 0, // \"<undefined state>\"\n";
- }
- os_ << " \"" << (*rit).second << "\",\n";
- }
- os_ << "};\n\n";
-
- return true;
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Generate a tokenizer for the given state machine.
- template <typename Char>
- inline bool
- generate_cpp (boost::lexer::basic_state_machine<Char> const& sm_,
- boost::lexer::basic_rules<Char> const& rules_,
- std::ostream &os_, char const* name_suffix = "",
- bool skip_on_nomatch = true, bool optimize_parameters = true)
- {
- if (sm_._lookup->empty())
- return false;
-
- std::size_t const dfas_ = sm_._dfa->size();
- std::size_t const lookups_ = sm_._lookup->front()->size();
-
- os_ << "// Copyright (c) 2008 Ben Hanson\n";
- os_ << "//\n";
- os_ << "// Distributed under the Boost Software License, "
- "Version 1.0. (See accompanying\n";
- os_ << "// file licence_1_0.txt or copy at "
- "http://www.boost.org/LICENSE_1_0.txt)\n\n";
- os_ << "// Auto-generated by boost::lexer\n";
-
- std::string guard(__DATE__ "_" __TIME__);
- std::string::size_type p = guard.find_first_of(": ");
- while (std::string::npos != p)
- {
- guard.replace(p, 1, "_");
- p = guard.find_first_of(": ", p);
- }
-
- os_ << "#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_" << guard << ")\n";
- os_ << "#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_" << guard << "\n\n";
-
- os_ << "#include <boost/detail/iterator.hpp>\n";
- os_ << "#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>\n\n";
-
- os_ << "// the generated table of state names and the tokenizer have to be\n"
- "// defined in the boost::spirit::lex::static namespace\n";
- os_ << "namespace boost { namespace spirit { namespace lex { "
- "namespace static_ {\n\n";
-
- // generate the table containing state names
- if (!generate_cpp_state_names(rules_, os_, name_suffix))
- return false;
-
- os_ << "template<typename Iterator>\n";
- os_ << "std::size_t next_token" << name_suffix << " (";
-
- if (dfas_ > 1 || !optimize_parameters)
- {
- os_ << "std::size_t &start_state_, ";
- }
-
- if (sm_._seen_BOL_assertion || !optimize_parameters)
- {
- os_ << "Iterator const& start_, ";
- }
-
- if (dfas_ > 1 || sm_._seen_BOL_assertion || !optimize_parameters)
- {
- os_ << "\n ";
- }
-
- os_ << "Iterator &start_token_, Iterator const& end_)\n";
- os_ << "{\n";
- os_ << " enum {end_state_index, id_index, state_index, bol_index, "
- "eol_index,\n";
- os_ << " dead_state_index, dfa_offset};\n";
- os_ << " static const std::size_t npos = static_cast"
- "<std::size_t>(~0);\n";
-
- if (dfas_ > 1)
- {
- for (std::size_t state_ = 0; state_ < dfas_; ++state_)
- {
- std::size_t i_ = 0;
- std::size_t j_ = 1;
- std::size_t count_ = lookups_ / 8;
- std::size_t const* lookup_ = &sm_._lookup[state_]->front ();
- std::size_t const* dfa_ = &sm_._dfa[state_]->front ();
-
- os_ << " static const std::size_t lookup" << state_
- << "_[" << lookups_ << "] = {";
-
- for (/**/; i_ < count_; ++i_)
- {
- const std::size_t index_ = i_ * 8;
-
- os_ << lookup_[index_];
-
- for (; j_ < 8; ++j_)
- {
- os_ << ", " << lookup_[index_ + j_];
- }
-
- if (i_ < count_ - 1)
- {
- os_ << "," << std::endl << " ";
- }
-
- j_ = 1;
- }
-
- os_ << "};\n";
- count_ = sm_._dfa[state_]->size ();
- os_ << " static const std::size_t dfa" << state_ << "_[" <<
- count_ << "] = {";
- count_ /= 8;
-
- for (i_ = 0; i_ < count_; ++i_)
- {
- const std::size_t index_ = i_ * 8;
-
- os_ << dfa_[index_];
-
- for (j_ = 1; j_ < 8; ++j_)
- {
- os_ << ", " << dfa_[index_ + j_];
- }
-
- if (i_ < count_ - 1)
- {
- os_ << "," << std::endl << " ";
- }
- }
-
- std::size_t const mod_ = sm_._dfa[state_]->size () % 8;
- if (mod_)
- {
- const std::size_t index_ = count_ * 8;
-
- if (count_)
- {
- os_ << ",\n ";
- }
-
- os_ << dfa_[index_];
-
- for (j_ = 1; j_ < mod_; ++j_)
- {
- os_ << ", " << dfa_[index_ + j_];
- }
- }
-
- os_ << "};\n";
- }
-
- std::size_t count_ = sm_._dfa_alphabet.size();
- std::size_t i_ = 1;
-
- os_ << " static const std::size_t *lookup_arr_[" << count_ <<
- "] = {";
-
- os_ << "lookup0_";
-
- for (i_ = 1; i_ < count_; ++i_)
- {
- os_ << ", " << "lookup" << i_ << "_";
- }
-
- os_ << "};\n";
- os_ << " static const std::size_t dfa_alphabet_arr_[" <<
- count_ << "] = {";
-
- os_ << sm_._dfa_alphabet.front ();
-
- for (i_ = 1; i_ < count_; ++i_)
- {
- os_ << ", " << sm_._dfa_alphabet[i_];
- }
-
- os_ << "};\n";
- os_ << " static const std::size_t *dfa_arr_[" << count_ <<
- "] = {";
- os_ << "dfa0_";
-
- for (i_ = 1; i_ < count_; ++i_)
- {
- os_ << ", " << "dfa" << i_ << "_";
- }
-
- os_ << "};\n";
- }
- else
- {
- std::size_t const* lookup_ = &sm_._lookup[0]->front();
- std::size_t const* dfa_ = &sm_._dfa[0]->front();
- std::size_t i_ = 0;
- std::size_t j_ = 1;
- std::size_t count_ = lookups_ / 8;
-
- os_ << " static const std::size_t lookup_[";
- os_ << sm_._lookup[0]->size() << "] = {";
-
- for (; i_ < count_; ++i_)
- {
- const std::size_t index_ = i_ * 8;
-
- os_ << lookup_[index_];
-
- for (; j_ < 8; ++j_)
- {
- os_ << ", " << lookup_[index_ + j_];
- }
-
- if (i_ < count_ - 1)
- {
- os_ << "," << std::endl << " ";
- }
-
- j_ = 1;
- }
-
- os_ << "};\n";
- os_ << " static const std::size_t dfa_alphabet_ = " <<
- sm_._dfa_alphabet.front () << ";\n";
- os_ << " static const std::size_t dfa_[" <<
- sm_._dfa[0]->size () << "] = {";
- count_ = sm_._dfa[0]->size () / 8;
-
- for (i_ = 0; i_ < count_; ++i_)
- {
- const std::size_t index_ = i_ * 8;
-
- os_ << dfa_[index_];
-
- for (j_ = 1; j_ < 8; ++j_)
- {
- os_ << ", " << dfa_[index_ + j_];
- }
-
- if (i_ < count_ - 1)
- {
- os_ << "," << std::endl << " ";
- }
- }
-
- const std::size_t mod_ = sm_._dfa[0]->size () % 8;
-
- if (mod_)
- {
- const std::size_t index_ = count_ * 8;
-
- if (count_)
- {
- os_ << ",\n ";
- }
-
- os_ << dfa_[index_];
-
- for (j_ = 1; j_ < mod_; ++j_)
- {
- os_ << ", " << dfa_[index_ + j_];
- }
- }
-
- os_ << "};\n";
- }
-
- os_ << "\n if (start_token_ == end_) return 0;\n\n";
-
- if (dfas_ > 1)
- {
- os_ << "again:\n";
- os_ << " const std::size_t * lookup_ = lookup_arr_[start_state_];\n";
- os_ << " std::size_t dfa_alphabet_ = dfa_alphabet_arr_[start_state_];\n";
- os_ << " const std::size_t *dfa_ = dfa_arr_[start_state_];\n";
- }
-
- os_ << " const std::size_t *ptr_ = dfa_ + dfa_alphabet_;\n";
- os_ << " Iterator curr_ = start_token_;\n";
- os_ << " bool end_state_ = *ptr_ != 0;\n";
- os_ << " std::size_t id_ = *(ptr_ + id_index);\n";
- os_ << " Iterator end_token_ = start_token_;\n";
- os_ << '\n';
- os_ << " while (curr_ != end_)\n";
- os_ << " {\n";
-
- if (sm_._seen_BOL_assertion)
- {
- os_ << " std::size_t const BOL_state_ = ptr_[bol_index];\n";
- }
-
- if (sm_._seen_EOL_assertion)
- {
- os_ << " std::size_t const EOL_state_ = ptr_[eol_index];\n";
- }
-
- if (sm_._seen_BOL_assertion || sm_._seen_EOL_assertion)
- {
- os_ << '\n';
- }
-
- if (sm_._seen_BOL_assertion && sm_._seen_EOL_assertion)
- {
- os_ << " if (BOL_state_ && (start_token_ == start_ ||\n";
- os_ << " *(start_token_ - 1) == '\\n'))\n";
- os_ << " {\n";
- os_ << " ptr_ = &dfa_[BOL_state_ * dfa_alphabet_];\n";
- os_ << " }\n";
- os_ << " else if (EOL_state_ && *curr_ == '\\n')\n";
- os_ << " {\n";
- os_ << " ptr_ = &dfa_[EOL_state_ * dfa_alphabet_];\n";
- os_ << " }\n";
- os_ << " else\n";
- os_ << " {\n";
- os_ << " std::size_t const state_ =\n";
-
- if (lookups_ == 256)
- {
- os_ << " ptr_[lookup_[<typename Traits::index_type>"
- "(*curr_++)]];\n";
- }
- else
- {
- os_ << " ptr_[lookup_[*curr_++]];\n";
- }
-
- os_ << '\n';
- os_ << " if (state_ == 0) break;\n";
- os_ << '\n';
- os_ << " ptr_ = &dfa_[state_ * dfa_alphabet_];\n";
- os_ << " }\n";
- }
- else if (sm_._seen_BOL_assertion)
- {
- os_ << " if (BOL_state_ && (start_token_ == start_ ||\n";
- os_ << " *(start_token_ - 1) == '\\n'))\n";
- os_ << " {\n";
- os_ << " ptr_ = &dfa_[BOL_state_ * dfa_alphabet_];\n";
- os_ << " }\n";
- os_ << " else\n";
- os_ << " {\n";
- os_ << " std::size_t const state_ =\n";
-
- if (lookups_ == 256)
- {
- os_ << " ptr_[lookup_[static_cast<unsigned char>\n";
- os_ << " (*curr_++)]];\n";
- }
- else
- {
- os_ << " ptr_[lookup_[*curr_++]];\n";
- }
-
- os_ << '\n';
- os_ << " if (state_ == 0) break;\n";
- os_ << '\n';
- os_ << " ptr_ = &dfa_[state_ * dfa_alphabet_];\n";
- os_ << " }\n";
- }
- else if (sm_._seen_EOL_assertion)
- {
- os_ << " if (EOL_state_ && *curr_ == '\\n')\n";
- os_ << " {\n";
- os_ << " ptr_ = &dfa_[EOL_state_ * dfa_alphabet_];\n";
- os_ << " }\n";
- os_ << " else\n";
- os_ << " {\n";
- os_ << " std::size_t const state_ =\n";
-
- if (lookups_ == 256)
- {
- os_ << " ptr_[lookup_[static_cast<unsigned char>\n";
- os_ << " (*curr_++)]];\n";
- }
- else
- {
- os_ << " ptr_[lookup_[*curr_++]];\n";
- }
-
- os_ << '\n';
- os_ << " if (state_ == 0) break;\n";
- os_ << '\n';
- os_ << " ptr_ = &dfa_[state_ * dfa_alphabet_];\n";
- os_ << " }\n";
- }
- else
- {
- os_ << " std::size_t const state_ =\n";
-
- if (lookups_ == 256)
- {
- os_ << " ptr_[lookup_[static_cast<unsigned char>\n";
- os_ << " (*curr_++)]];\n";
- }
- else
- {
- os_ << " ptr_[lookup_[*curr_++]];\n";
- }
-
- os_ << '\n';
- os_ << " if (state_ == 0) break;\n";
- os_ << '\n';
- os_ << " ptr_ = &dfa_[state_ * dfa_alphabet_];\n";
- }
-
- os_ << '\n';
- os_ << " if (*ptr_)\n";
- os_ << " {\n";
- os_ << " end_state_ = true;\n";
- os_ << " id_ = *(ptr_ + id_index);\n";
-
- if (dfas_ > 1)
- {
- os_ << " start_state_ = *(ptr_ + state_index);\n";
- }
-
- os_ << " end_token_ = curr_;\n";
- os_ << " }\n";
- os_ << " }\n";
- os_ << '\n';
-
- if (sm_._seen_EOL_assertion)
- {
- os_ << " const std::size_t EOL_state_ = ptr_[eol_index];\n";
- os_ << '\n';
- os_ << " if (EOL_state_ && curr_ == end_)\n";
- os_ << " {\n";
- os_ << " ptr_ = &dfa_[EOL_state_ * dfa_alphabet_];\n";
- os_ << '\n';
- os_ << " if (*ptr_)\n";
- os_ << " {\n";
- os_ << " end_state_ = true;\n";
- os_ << " id_ = *(ptr_ + id_index);\n";
-
- if (dfas_ > 1)
- {
- os_ << " start_state_ = *(ptr_ + state_index);\n";
- }
-
- os_ << " end_token_ = curr_;\n";
- os_ << " }\n";
- os_ << " }\n";
- os_ << '\n';
- }
-
- os_ << " if (end_state_)\n";
- os_ << " {\n";
- os_ << " // return longest match\n";
- os_ << " start_token_ = end_token_;\n";
-
- if (dfas_ > 1)
- {
- os_ << '\n';
- os_ << " if (id_ == 0) goto again;\n";
- }
-
- os_ << " }\n";
- os_ << " else\n";
- os_ << " {\n";
-
- if (skip_on_nomatch)
- {
- os_ << " // No match causes char to be skipped\n";
- os_ << " ++start_token_;\n";
- }
-
- os_ << " id_ = npos;\n";
- os_ << " }\n";
- os_ << '\n';
- os_ << " return id_;\n";
- os_ << "}\n\n";
-
- os_ << "}}}} // namespace boost::spirit::lex::static_\n\n";
-
- os_ << "#endif\n";
-
- return os_.good();
- }
-
-///////////////////////////////////////////////////////////////////////////////
-}}}} // namespace boost::spirit::lex::detail
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace lex
-{
- ///////////////////////////////////////////////////////////////////////////
- template <typename Lexer>
- inline bool
- generate_static(Lexer const& lexer, std::ostream& os,
- char const* name_suffix = "")
- {
- if (!lexer.get_definition().init_dfa())
- return false;
- return detail::generate_cpp(lexer.get_definition().state_machine,
- lexer.get_definition().rules, os, name_suffix, false, false);
- }
-
-///////////////////////////////////////////////////////////////////////////////
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_iterator.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_iterator.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,117 +0,0 @@
-// Copyright (c) 2001-2009 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_LEX_LEXER_ITERATOR_MAR_16_2007_0353PM)
-#define BOOST_SPIRIT_LEX_LEXER_ITERATOR_MAR_16_2007_0353PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
-#include <boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp>
-#else
-#include <boost/spirit/home/support/iterators/detail/no_check_policy.hpp>
-#endif
-#include <boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp>
-#include <boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp>
-#include <boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp>
-#include <boost/spirit/home/support/iterators/multi_pass.hpp>
-
-namespace boost { namespace spirit { namespace lex
-{
- ///////////////////////////////////////////////////////////////////////////
- // Divide the given functor type into its components (unique and shared)
- // and build a std::pair from these parts
- template <typename Functor>
- struct make_functor
- {
- typedef
- std::pair<typename Functor::unique, typename Functor::shared>
- type;
- };
-
- ///////////////////////////////////////////////////////////////////////////////
- // Divide the given functor type into its components (unique and shared)
- // and build a std::pair from these parts
- template <typename FunctorData>
- struct make_multi_pass
- {
- typedef
- std::pair<typename FunctorData::unique, typename FunctorData::shared>
- functor_data_type;
- typedef typename FunctorData::result_type result_type;
-
- typedef multi_pass_policies::split_functor_input input_policy;
- typedef multi_pass_policies::ref_counted ownership_policy;
-#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
- typedef multi_pass_policies::buf_id_check check_policy;
-#else
- typedef multi_pass_policies::no_check check_policy;
-#endif
- typedef multi_pass_policies::split_std_deque storage_policy;
-
- typedef multi_pass_policies::default_policy<
- ownership_policy, check_policy, input_policy, storage_policy>
- policy_type;
- typedef spirit::multi_pass<functor_data_type, policy_type> type;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // lexer_iterator exposes an iterator for a lexertl based dfa (lexer)
- // The template parameters have the same semantics as described for the
- // lexertl_functor above.
- ///////////////////////////////////////////////////////////////////////////
- template <typename Functor>
- class lexertl_iterator
- : public make_multi_pass<Functor>::type
- {
- public:
- typedef typename Functor::unique unique_functor_type;
- typedef typename Functor::shared shared_functor_type;
-
- typedef typename Functor::iterator_type base_iterator_type;
- typedef typename Functor::result_type token_type;
-
- private:
- typedef
- typename make_multi_pass<Functor>::functor_data_type
- functor_type;
- typedef typename make_multi_pass<Functor>::type base_type;
- typedef typename Functor::char_type char_type;
-
- public:
- // create a new iterator encapsulating the lexer object to be used
- // for tokenization
- template <typename IteratorData>
- lexertl_iterator(IteratorData const& iterdata_,
- base_iterator_type& first, base_iterator_type const& last)
- : base_type(functor_type(unique_functor_type(),
- shared_functor_type(iterdata_, first, last))
- )
- {
- }
-
- // create an end iterator usable for end of range checking
- lexertl_iterator()
- {}
-
- // set the new required state for the underlying lexer object
- std::size_t set_state(std::size_t state)
- {
- return unique_functor_type::set_state(*this, state);
- }
-
- // map the given state name to a corresponding state id as understood
- // by the underlying lexer object
- std::size_t map_state(char_type const* statename)
- {
- return unique_functor_type::map_state(*this, statename);
- }
- };
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_lexer.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,371 +0,0 @@
-// Copyright (c) 2001-2009 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_LEX_LEXERTL_LEXER_MAR_17_2007_0139PM)
-#define BOOST_SPIRIT_LEX_LEXERTL_LEXER_MAR_17_2007_0139PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <iosfwd>
-
-#include <boost/spirit/home/support/safe_bool.hpp>
-#include <boost/spirit/home/support/detail/lexer/generator.hpp>
-#include <boost/spirit/home/support/detail/lexer/rules.hpp>
-#include <boost/spirit/home/support/detail/lexer/consts.hpp>
-#include <boost/spirit/home/lex/lexer/lexer_fwd.hpp>
-#include <boost/spirit/home/lex/lexer/lexertl/lexertl_token.hpp>
-#include <boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp>
-#include <boost/spirit/home/lex/lexer/lexertl/lexertl_iterator.hpp>
-#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
-#include <boost/spirit/home/support/detail/lexer/debug.hpp>
-#endif
-
-namespace boost { namespace spirit { namespace lex
-{
- ///////////////////////////////////////////////////////////////////////////
- namespace detail
- {
- ///////////////////////////////////////////////////////////////////////
- // The must_escape function checks if the given character value needs
- // to be preceded by a backslash character to disable its special
- // meaning in the context of a regular expression
- ///////////////////////////////////////////////////////////////////////
- template <typename Char>
- inline bool must_escape(Char c)
- {
- // FIXME: more needed?
- switch (c) {
- case '+': case '/': case '*': case '?':
- case '|':
- case '(': case ')':
- case '[': case ']':
- case '{': case '}':
- case '.':
- case '^': case '$':
- case '\\':
- case '"':
- return true;
-
- default:
- break;
- }
- return false;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // The escape function returns the string representation of the given
- // character value, possibly escaped with a backslash character, to
- // allow it being safely used in a regular expression definition.
- ///////////////////////////////////////////////////////////////////////
- template <typename Char>
- inline std::basic_string<Char> escape(Char ch)
- {
- std::basic_string<Char> result(1, ch);
- if (detail::must_escape(ch))
- {
- typedef typename std::basic_string<Char>::size_type size_type;
- result.insert((size_type)0, 1, '\\');
- }
- return result;
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // lexertl_token_set
- ///////////////////////////////////////////////////////////////////////////
- template <typename Token, typename Iterator = typename Token::iterator_type>
- class lexertl_token_set
- {
- protected:
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
- char_type;
- typedef std::basic_string<char_type> string_type;
-
- public:
- typedef Token token_type;
- typedef typename Token::id_type id_type;
-
- // interface for token definition management
- void add_token (char_type const* state, string_type const& tokendef,
- std::size_t token_id)
- {
- rules.add(state, tokendef, token_id, state);
- }
-
- // interface for pattern definition management
- void add_pattern (char_type const* state, string_type const& name,
- string_type const& patterndef)
- {
- add_state(state);
- rules.add_macro(name.c_str(), patterndef);
- }
-
- boost::lexer::rules const& get_rules() const { return rules; }
-
- void clear() { rules.clear(); }
-
- std::size_t add_state(char_type const* state)
- {
- rules.add_state(state);
- return rules.state(state);
- }
- string_type initial_state() const
- {
- return string_type(rules.initial());
- }
-
- private:
- boost::lexer::basic_rules<char_type> rules;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Lexer>
- bool generate_static(Lexer const& lex, std::ostream& os, char const* name);
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // Every lexer type to be used as a lexer for Spirit has to conform to
- // the following public interface:
- //
- // typedefs:
- // iterator_type The type of the iterator exposed by this lexer.
- // token_type The type of the tokens returned from the exposed
- // iterators.
- // token_set The type of the token set representing a lexer
- // state.
- //
- // functions:
- // default constructor
- // Since lexers are instantiated as base classes
- // only it might be a good idea to make this
- // constructor protected.
- // begin, end Return a pair of iterators, when dereferenced
- // returning the sequence of tokens recognized in
- // the input stream given as the parameters to the
- // begin() function.
- // add_token Should add the definition of a token to be
- // recognized by this lexer.
- // clear Should delete all current token definitions
- // associated with the given state of this lexer
- // object.
- //
- // template parameters:
- // Iterator The type of the iterator used to access the
- // underlying character stream.
- // Token The type of the tokens to be returned from the
- // exposed token iterator.
- // Functor The type of the InputPolicy to use to instantiate
- // the multi_pass iterator type to be used as the
- // token iterator (returned from begin()/end()).
- // TokenSet The type of the token set to use in conjunction
- // with this lexer type. This is used for the
- // token_set typedef described above only.
- //
- ///////////////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // The lexertl_lexer class is a implementation of a Spirit.Lex lexer on
- // top of Ben Hanson's lexertl library as outlined above (For more
- // information about lexertl go here: http://www.benhanson.net/lexertl.html).
- //
- // This class is supposed to be used as the first and only template
- // parameter while instantiating instances of a lex::lexer_def class.
- //
- ///////////////////////////////////////////////////////////////////////////
- template <
- typename Token = lexertl_token<>,
- typename Iterator = typename Token::iterator_type,
- typename Functor = lexertl_functor<Token, Iterator, mpl::false_>,
- typename TokenSet = token_set<lexertl_token_set<Token, Iterator> >
- >
- class lexertl_lexer
- : public safe_bool<lexertl_lexer<Token, Iterator, Functor, TokenSet> >
- {
- public:
- // operator_bool() is needed for the safe_bool base class
- bool operator_bool() const { return initialized_dfa; }
-
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
- char_type;
- typedef std::basic_string<char_type> string_type;
-
- // Every lexer type to be used as a lexer for Spirit has to conform to
- // a public interface .
- typedef Token token_type;
- typedef typename Token::id_type id_type;
- typedef TokenSet token_set;
- typedef lexertl_iterator<Functor> iterator_type;
-
- private:
- // this type is purely used for the iterator_type construction below
- struct iterator_data_type {
- boost::lexer::basic_state_machine<char_type> const& state_machine_;
- boost::lexer::basic_rules<char_type> const& rules_;
- typename Functor::semantic_actions_type const& actions_;
- };
-
- public:
- // Return the start iterator usable for iterating over the generated
- // tokens.
- iterator_type begin(Iterator& first, Iterator const& last) const
- {
- if (!init_dfa())
- return iterator_type();
-
- iterator_data_type iterator_data = { state_machine, rules, actions };
- return iterator_type(iterator_data, first, last);
- }
-
- // Return the end iterator usable to stop iterating over the generated
- // tokens.
- iterator_type end() const
- {
- return iterator_type();
- }
-
- protected:
- // Lexer instances can be created by means of a derived class only.
- lexertl_lexer()
- : initialized_dfa(false)
- {
- }
-
- public:
- // interface for token definition management
- void add_token (char_type const* state, string_type const& tokendef,
- std::size_t token_id)
- {
- add_state(state);
- rules.add(state, tokendef, token_id, state);
- initialized_dfa = false;
- }
- void add_token(char_type const* state, token_set& tokset)
- {
- add_state(state);
- rules.add(state, tokset.get_rules());
- initialized_dfa = false;
- }
-
- // interface for pattern definition management
- void add_pattern (char_type const* state, string_type const& name,
- string_type const& patterndef)
- {
- add_state(state);
- rules.add_macro(name.c_str(), patterndef);
- initialized_dfa = false;
- }
-
- void clear(char_type const* state)
- {
- std::size_t s = rules.state(state);
- if (boost::lexer::npos != s)
- rules.clear(state);
- initialized_dfa = false;
- }
- std::size_t add_state(char_type const* state)
- {
- std::size_t stateid = rules.state(state);
- if (boost::lexer::npos == stateid) {
- rules.add_state(state);
- stateid = rules.state(state);
- initialized_dfa = false;
- }
- return stateid;
- }
- string_type initial_state() const
- {
- return string_type(rules.initial());
- }
-
- // Register a semantic action with the given id
- template <typename F>
- void add_action(std::size_t id, F act)
- {
- // If you get compilation errors below stating value_type not being
- // a member of boost::fusion::unused_type, then you are probably
- // using semantic actions in your token definition without
- // the lexertl_actor_lexer being specified as the base class
- // (instead of the lexertl_lexer class).
- typedef
- typename Functor::semantic_actions_type::value_type
- value_type;
-
- typedef typename Functor::wrap_action_type wrapper_type;
-
- actions.insert(value_type(id, wrapper_type::call(act)));
- }
-
- bool init_dfa() const
- {
- if (!initialized_dfa) {
- state_machine.clear();
- try {
- typedef boost::lexer::basic_generator<char_type> generator;
- generator::build (rules, state_machine);
- generator::minimise (state_machine);
-
-#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
- boost::lexer::debug::dump(state_machine, std::cerr);
-#endif
- }
- catch (std::runtime_error const&) {
- return false;
- }
- initialized_dfa = true;
- }
- return true;
- }
-
- private:
- mutable boost::lexer::basic_state_machine<char_type> state_machine;
- boost::lexer::basic_rules<char_type> rules;
- typename Functor::semantic_actions_type actions;
- mutable bool initialized_dfa;
-
- template <typename Lexer>
- friend bool generate_static(Lexer const&, std::ostream&, char const*);
- };
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // The lexertl_actor_lexer class is another implementation of a Spirit.Lex
- // lexer on top of Ben Hanson's lexertl library as outlined above (For
- // more information about lexertl go here:
- // http://www.benhanson.net/lexertl.html).
- //
- // The only difference to the lexertl_lexer class above is that token_def
- // definitions may have semantic (lexer) actions attached while being
- // defined:
- //
- // int w;
- // token_def word = "[^ \t\n]+";
- // self = word[++ref(w)]; // see example: word_count_lexer
- //
- // This class is supposed to be used as the first and only template
- // parameter while instantiating instances of a lex::lexer_def class.
- //
- ///////////////////////////////////////////////////////////////////////////
- template <
- typename Token = lexertl_token<>,
- typename Iterator = typename Token::iterator_type,
- typename Functor = lexertl_functor<Token, Iterator, mpl::true_>,
- typename TokenSet = token_set<lexertl_token_set<Token, Iterator> >
- >
- class lexertl_actor_lexer
- : public lexertl_lexer<Token, Iterator, Functor, TokenSet>
- {
- protected:
- // Lexer instances can be created by means of a derived class only.
- lexertl_actor_lexer() {}
- };
-
-}}}
-
-#endif

Deleted: branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp 2009-09-14 12:50:29 EDT (Mon, 14 Sep 2009)
+++ (empty file)
@@ -1,386 +0,0 @@
-// Copyright (c) 2001-2009 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_LEX_LEXER_STATIC_FUNCTOR_FEB_10_2008_0755PM)
-#define BOOST_SPIRIT_LEX_LEXER_STATIC_FUNCTOR_FEB_10_2008_0755PM
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once // MS compatible compilers support #pragma once
-#endif
-
-#include <boost/mpl/bool.hpp>
-#include <boost/function.hpp>
-#include <boost/range/iterator_range.hpp>
-#include <boost/detail/iterator.hpp>
-#include <boost/detail/workaround.hpp>
-#include <map>
-#include <boost/spirit/home/support/detail/lexer/generator.hpp>
-#include <boost/spirit/home/support/detail/lexer/rules.hpp>
-#include <boost/spirit/home/support/detail/lexer/state_machine.hpp>
-#include <boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp>
-#include <boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp>
-
-#if 0 != __COMO_VERSION__ || !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
-#define BOOST_SPIRIT_STATIC_EOF 1
-#define BOOST_SPIRIT_EOF_PREFIX static
-#else
-#define BOOST_SPIRIT_EOF_PREFIX
-#endif
-
-namespace boost { namespace spirit { namespace lex
-{
- namespace detail
- {
- ///////////////////////////////////////////////////////////////////////
- template <typename Iterator, typename HasActors, typename HasState>
- struct Data; // no default specialization
-
- ///////////////////////////////////////////////////////////////////////
- // doesn't support no state and no actors
- template <typename Iterator>
- struct Data<Iterator, mpl::false_, mpl::false_>
- {
- typedef std::size_t state_type;
- typedef iterator_range<Iterator> iterpair_type;
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
- char_type;
-
- typedef std::size_t (*next_token_functor)(std::size_t&,
- Iterator const&, Iterator&, Iterator const&);
-
- typedef unused_type semantic_actions_type;
-
- typedef
- detail::wrap_action<unused_type, iterpair_type, Data>
- wrap_action_type;
-
- // initialize the shared data
- template <typename IterData>
- Data (IterData const& data_, Iterator& first_, Iterator const& last_)
- : next_token(data_.next_), first(first_), last(last_)
- {}
-
- std::size_t next(Iterator& end)
- {
- typedef basic_iterator_tokeniser<Iterator> tokenizer;
- std::size_t state;
- return next_token(state, first, end, last);
- }
-
- // nothing to invoke, so this is empty
- bool invoke_actions(std::size_t, Iterator const&)
- {
- return true; // always accept
- }
-
- std::size_t get_state() const { return 0; }
- void set_state_name (char const*) {}
-
- next_token_functor next_token;
- Iterator& first;
- Iterator last;
- };
-
- ///////////////////////////////////////////////////////////////////////
- // doesn't support no actors
- template <typename Iterator>
- struct Data<Iterator, mpl::false_, mpl::true_>
- : Data<Iterator, mpl::false_, mpl::false_>
- {
- typedef Data<Iterator, mpl::false_, mpl::false_> base_type;
-
- typedef typename base_type::state_type state_type;
- typedef typename base_type::char_type char_type;
- typedef
- typename base_type::semantic_actions_type
- semantic_actions_type;
-
- // initialize the shared data
- template <typename IterData>
- Data (IterData const& data_, Iterator& first_, Iterator const& last_)
- : base_type(data_, first_, last_), state(0)
- {}
-
- std::size_t next(Iterator& end)
- {
- typedef basic_iterator_tokeniser<Iterator> tokenizer;
- return this->next_token(state, this->first, end, this->last);
- }
-
- std::size_t& get_state() { return state; }
- void set_state_name (char_type const* new_state)
- {
- std::size_t state_id = this->rules.state(new_state);
- BOOST_ASSERT(state_id != boost::lexer::npos);
- if (state_id != boost::lexer::npos)
- state = state_id;
- }
-
- std::size_t state;
- };
-
- ///////////////////////////////////////////////////////////////////////
- // does support actors, but may have no state
- template <typename Iterator, typename HasState>
- struct Data<Iterator, mpl::true_, HasState>
- : Data<Iterator, mpl::false_, HasState>
- {
- typedef Data<Iterator, mpl::false_, HasState> base_type;
-
- typedef iterator_range<Iterator> iterpair_type;
- typedef typename base_type::state_type state_type;
- typedef typename base_type::char_type char_type;
-
- typedef void functor_type(iterpair_type, std::size_t, bool&, Data&);
- typedef boost::function<functor_type> functor_wrapper_type;
- typedef std::multimap<std::size_t, functor_wrapper_type>
- semantic_actions_type;
-
- typedef
- detail::wrap_action<functor_wrapper_type, iterpair_type, Data>
- wrap_action_type;
-
- template <typename IterData>
- Data (IterData const& data_, Iterator& first_, Iterator const& last_)
- : base_type(data_, first_, last_),
- actions(data_.actions_)
- {}
-
- // invoke attached semantic actions, if defined
- bool invoke_actions(std::size_t id, Iterator const& end)
- {
- if (actions.empty())
- return true; // nothing to invoke, continue with 'match'
-
- iterpair_type itp(this->first, end);
- bool match = true;
-
- typedef typename
- semantic_actions_type::const_iterator
- iterator_type;
-
- std::pair<iterator_type, iterator_type> p = actions.equal_range(id);
- while (p.first != p.second)
- {
- ((*p.first).second)(itp, id, match, *this);
- if (!match)
- return false; // return a 'no-match'
- ++p.first;
- }
- return true; // normal execution
- }
-
- semantic_actions_type const& actions;
- };
- }
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // lexertl_static_functor is a template usable as the functor object for
- // the multi_pass iterator allowing to wrap a lexertl based dfa into a
- // iterator based interface.
- //
- // Iterator: the type of the underlying iterator
- // Token: the type of the tokens produced by this functor
- // this needs to expose a constructor with the following
- // prototype:
- //
- // Token(std::size_t id, std::size_t state,
- // Iterator start, Iterator end)
- //
- // where 'id' is the token id, state is the lexer state,
- // this token has been matched in, and 'first' and 'end'
- // mark the start and the end of the token with respect
- // to the underlying character stream.
- // SupportsActors:
- // this is expected to be a mpl::bool_, if mpl::true_ the
- // lexertl_static_functor invokes functors which
- // (optionally) have been attached to the token definitions.
- // SupportState:
- // this is expected to be a mpl::bool_, if mpl::true_ the
- // lexertl_functor supports different lexer states,
- // otherwise no lexer state is supported.
- //
- ///////////////////////////////////////////////////////////////////////////
- template <typename Token,
- typename Iterator = typename Token::iterator_type,
- typename SupportsActors = mpl::false_,
- typename SupportsState = typename Token::has_state>
- class lexertl_static_functor
- {
- public:
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
- char_type;
-
- private:
- // Needed by compilers not implementing the resolution to DR45. For
- // reference, see
- // http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45.
- template <typename Iterator_, typename HasActors, typename HasState>
- friend struct detail::Data;
-
- // Helper template allowing to assign a value on exit
- template <typename T>
- struct assign_on_exit
- {
- assign_on_exit(T& dst_, T const& src_)
- : dst(dst_), src(src_)
- {}
- ~assign_on_exit()
- {
- dst = src;
- }
-
- T& dst;
- T const& src;
- };
-
- public:
- lexertl_static_functor()
-#if defined(__PGI)
- : eof()
-#endif
- {}
-
-#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
- // somehow VC7.1 needs this (meaningless) assignment operator
- lexertl_functor& operator=(lexertl_functor const& rhs)
- {
- return *this;
- }
-#endif
-
- ///////////////////////////////////////////////////////////////////////
- // interface to the multi_pass_policies::split_functor_input policy
- typedef Token result_type;
- typedef lexertl_static_functor unique;
- typedef detail::Data<Iterator, SupportsActors, SupportsState> shared;
-
- BOOST_SPIRIT_EOF_PREFIX result_type const eof;
-
- ///////////////////////////////////////////////////////////////////////
- typedef Iterator iterator_type;
- typedef typename shared::semantic_actions_type semantic_actions_type;
- typedef typename shared::next_token_functor next_token_functor;
-
- // this is needed to wrap the semantic actions in a proper way
- typedef typename shared::wrap_action_type wrap_action_type;
-
- ///////////////////////////////////////////////////////////////////////
- template <typename MultiPass>
- static result_type& get_next(MultiPass& mp, result_type& result)
- {
- shared& data = mp.shared->ftor;
- if (data.first == data.last)
-#if defined(BOOST_SPIRIT_STATIC_EOF)
- return result = eof;
-#else
- return result = mp.ftor.eof;
-#endif