Changeset 63892


Ignore:
Timestamp:
Jul 11, 2010, 7:41:53 PM (8 years ago)
Author:
Hartmut Kaiser
Message:

Spirit: added karma::duplicate[] directive, tests and docs

Location:
trunk/libs/spirit
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/spirit/doc/karma/directive.qbk

    r63788 r63892  
    1414`no_delimit[]`, and `delimit[]`), controlling case sensitivity (`upper[]` and
    1515`lower[]`), field width (`maxwidth[]`), buffering (`buffer[]`), splitting into
    16 columns (`columns[]`) and attribute handling (`omit[]` and `skip[]`).
     16columns (`columns[]`) and attribute handling (`duplicate[]`, `omit[]`, and
     17`skip[]`).
    1718
    1819[heading Module Header]
     
    891892will still execute the embedded generator while discarding the generated output
    892893afterwards. The `skip[]` directive will not execute the embedded generator, but
    893 will use it onlz to extract the exposed attribute type.
     894will use it only to extract the exposed attribute type.
    894895
    895896[heading Header]
     
    10081009
    10091010[endsect] [/ omit]
     1011
     1012[/////////////////////////////////////////////////////////////////////////////]
     1013[section:duplicate Duplicate Attribute (`duplicate[]`)]
     1014
     1015[heading Description]
     1016
     1017The directive `duplicate[]` duplicates its attribute to all elements of the
     1018embedded generator if this is a sequence generator. Otherwise it does nothing.
     1019
     1020[heading Header]
     1021
     1022    // forwards to <boost/spirit/home/karma/directive/duplicate.hpp>
     1023    #include <boost/spirit/include/karma_duplicate.hpp>
     1024
     1025Also, see __include_structure__.
     1026
     1027[table
     1028    [[Name]]
     1029    [[`boost::spirit::duplicate // alias: boost::spirit::karma::duplicate` ]]
     1030]
     1031
     1032[heading Model of]
     1033
     1034[:__unary_generator_concept__]
     1035
     1036[variablelist Notation
     1037    [[`a`]     [A generator object]]
     1038    [[`A`]     [Attribute type of generator `a`]]]
     1039
     1040[heading Expression Semantics]
     1041
     1042Semantics of an expression is defined only where it differs from, or is not
     1043defined in __unary_generator_concept__.
     1044
     1045[table
     1046    [[Expression]       [Semantics]]
     1047    [[`duplicate[a]`]   [The `duplicate` directive duplicates the supplied
     1048                         attribute for all elements of a embedded sequence
     1049                         generator. For all other types of embedded generators
     1050                         it has no effect. It succeeds as long as its embedded
     1051                         generator does not fail.]]
     1052]
     1053
     1054[heading Attributes]
     1055
     1056See __karma_comp_attr_notation__.
     1057
     1058[table
     1059    [[Expression]       [Attribute]]
     1060    [[`duplicate[a]`]
     1061[``a: A --> duplicate[a]: A
     1062a: tuple<A, A, ...> --> duplicate[a]: A
     1063a: Unused --> duplicate[a]: Unused``]]
     1064]
     1065
     1066If the embedded generator of the `duplicate[]` directive is a sequence it is
     1067expected that all elements of this sequence expose either the same attribute
     1068type, an compatible attribute type, or `unused`. In this case, the
     1069`duplicate[]` directive exposes the attribute type of its first element. The
     1070behavior of the `duplicate[]` directive is undefined if the elements of an
     1071embedded sequence do not expose the same attributes. Most likely, the
     1072corresponding expression will not compile.
     1073
     1074[heading Complexity]
     1075
     1076[:The overall complexity of the `duplicate[]` directive depends on the complexity
     1077  of the embedded generator.]
     1078
     1079[heading Example]
     1080
     1081[note The test harness for the example(s) below is presented in the
     1082      __karma_basics_examples__ section.]
     1083
     1084Some includes:
     1085
     1086[reference_karma_includes]
     1087
     1088Some using declarations:
     1089
     1090[reference_karma_using_declarations_duplicate]
     1091
     1092Basic usage of the `duplicate` generators:
     1093
     1094[reference_karma_duplicate]
     1095
     1096[endsect] [/ duplicate]
    10101097
    10111098[/////////////////////////////////////////////////////////////////////////////]
  • trunk/libs/spirit/doc/karma/quick_reference.qbk

    r61783 r63892  
    444444                                                 The embedded generator will never be executed.]]
    445445
     446    [[__karma_duplicate__`[a]`]  [`A`]          [The supplied attribute will be duplicated and passed unchanged to
     447                                                 all embedded elements of a sequence.]]
     448
    446449    [[__karma_buffer__`[a]`][`A`]               [Temporarily intercept the output generated by `a`,
    447450                                                 flushing it only after `a` succeeded]]
  • trunk/libs/spirit/doc/spirit2.qbk

    r61445 r63892  
    182182[def __karma_omit__                 [link spirit.karma.reference.directive.omit `omit`]]
    183183[def __karma_skip__                 [link spirit.karma.reference.directive.omit `skip`]]
     184[def __karma_duplicate__            [link spirit.karma.reference.directive.duplicate `duplicate`]]
    184185[def __karma_buffer__               [link spirit.karma.reference.directive.buffer `buffer`]]
    185186[template karma_repeat[str]         [link spirit.karma.reference.directive.repeat [str]]]
  • trunk/libs/spirit/doc/what_s_new.qbk

    r63788 r63892  
    3939  relaxed mode. Added __karma__ compile time directives `strict[]` and
    4040  `relaxed[]` allowing to switch between the two.
     41* Added __karma__ __karma_duplicate__ directive which duplicates the supplied
     42  attribute to all elements of an embedded generator sequence.
    4143
    4244[heading Bug Fixes]
  • trunk/libs/spirit/example/karma/reference.cpp

    r61284 r63892  
    467467
    468468    {
     469        //[reference_karma_using_declarations_duplicate
     470        using boost::spirit::karma::double_;
     471        using boost::spirit::karma::duplicate;
     472        using boost::spirit::karma::space;
     473        //]
     474
     475        //[reference_karma_duplicate
     476        test_generator_attr("2.02.0", duplicate[double_ << double_], 2.0);
     477        test_generator_attr_delim("2.0 2.0 ", duplicate[double_ << double_], space, 2.0);
     478        //]
     479    }
     480
     481    {
    469482        //[reference_karma_using_declarations_columns
    470483        using boost::spirit::karma::double_;
  • trunk/libs/spirit/test/Jamfile

    r62184 r63892  
    9090    [ run karma/debug.cpp                   : : : : karma_debug ]
    9191    [ run karma/delimiter.cpp               : : : : ]
     92    [ run karma/duplicate.cpp               : : : : ]
    9293    [ run karma/encoding.cpp                : : : : karma_encoding ]
    9394    [ run karma/eol.cpp                     : : : : karma_eol ]
Note: See TracChangeset for help on using the changeset viewer.