Changeset 44677


Ignore:
Timestamp:
Apr 21, 2008, 5:40:00 AM (10 years ago)
Author:
Eric Niebler
Message:

don't double-deref args to make_expr, nuke trailing spaces

Location:
branches/proto/v4
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • branches/proto/v4/boost/proto/expr.hpp

    r44563 r44677  
    107107        #undef BOOST_PROTO_CHILD
    108108        #undef BOOST_PROTO_VOID
     109
     110        /// \brief Lets you inherit the interface of an expression
     111        /// while hiding from Proto the fact that the type is a Proto
     112        /// expression.
     113        template<typename Expr>
     114        struct unexpr
     115          : Expr
     116        {
     117            BOOST_PROTO_UNEXPR()
     118
     119            explicit unexpr(Expr const &expr)
     120              : Expr(expr)
     121            {}
     122           
     123            using Expr::operator =;
     124        };
     125
    109126    }}
    110127
  • branches/proto/v4/boost/proto/make_expr.hpp

    r44649 r44677  
    377377            {
    378378                typedef
    379                     typename boost::unwrap_reference<T>::type
    380                 unref_type;
    381 
    382                 typedef
    383                     typename proto::result_of::as_child<unref_type, Domain>::type
     379                    typename proto::result_of::as_child<T, Domain>::type
    384380                type;
    385381
    386382                static type call(T &t)
    387383                {
    388                     return functional::as_child<Domain>()(static_cast<unref_type &>(t));
     384                    return functional::as_child<Domain>()(t);
    389385                }
    390386            };
  • branches/proto/v4/boost/proto/proto_fwd.hpp

    r44649 r44677  
    696696    struct is_transform;
    697697
     698    #define BOOST_PROTO_UNEXPR() typedef int proto_is_expr_;
    698699    #define BOOST_PROTO_CALLABLE() typedef void proto_is_callable_;
    699700    #define BOOST_PROTO_TRANSFORM() typedef void proto_is_transform_;
  • branches/proto/v4/boost/xpressive/detail/core/matcher/action_matcher.hpp

    r44402 r44677  
    352352                typename expr_type::proto_child0::matcher_type::value_type::second_type
    353353            attr_type;
    354            
     354
    355355            typedef
    356356                typename proto::terminal<opt<attr_type> >::type
  • branches/proto/v4/boost/xpressive/detail/static/transforms/as_action.hpp

    r44563 r44677  
    174174                >
    175175            result_type;
    176            
     176
    177177            result_type operator ()(
    178178                typename impl::expr_param expr
     
    203203                >
    204204            begin_type;
    205            
     205
    206206            typedef typename impl::expr expr_type;
    207            
     207
    208208            typedef
    209209                typename shift_right<
  • branches/proto/v4/boost/xpressive/detail/static/transforms/as_independent.hpp

    r44563 r44677  
    103103        {
    104104            typedef typename proto::result_of::child<Expr>::type arg_type;
    105            
     105
    106106            typedef
    107107                typename IndependentEndXpression::impl<arg_type, int, int>::result_type
     
    111111                typename Grammar::template impl<arg_type, end_xpr_type, Data>::result_type
    112112            xpr_type;
    113            
     113
    114114            typedef
    115115                detail::lookahead_matcher<xpr_type>
     
    142142        {
    143143            typedef typename proto::result_of::child<Expr>::type arg_type;
    144            
     144
    145145            typedef
    146146                typename IndependentEndXpression::impl<arg_type, int, int>::result_type
     
    150150                typename Grammar::template impl<arg_type, end_xpr_type, Data>::result_type
    151151            xpr_type;
    152            
     152
    153153            typedef
    154154                detail::lookbehind_matcher<xpr_type>
     
    180180        {
    181181            typedef typename proto::result_of::child<Expr>::type arg_type;
    182            
     182
    183183            typedef
    184184                typename IndependentEndXpression::impl<arg_type, int, int>::result_type
  • branches/proto/v4/boost/xpressive/detail/static/transforms/as_matcher.hpp

    r44402 r44677  
    3232                >::type
    3333            result_type;
    34            
     34
    3535            result_type operator ()(
    3636                typename impl::expr_param expr
  • branches/proto/v4/boost/xpressive/detail/static/transforms/as_modifier.hpp

    r44402 r44677  
    4848                >::type
    4949            modifier_type;
    50            
     50
    5151            typedef
    5252                typename modifier_type::template apply<typename impl::data>::type
     
    5656                typename proto::result_of::right<Expr>::type
    5757            expr_type;
    58            
     58
    5959            typedef
    6060                typename Grammar::template impl<expr_type, State, visitor_type &>::result_type
  • branches/proto/v4/boost/xpressive/detail/static/transforms/as_quantifier.hpp

    r44402 r44677  
    7373                typename proto::result_of::child<Expr>::type
    7474            arg_type;
    75            
     75
    7676            typedef
    7777                typename Grammar::template impl<arg_type, detail::true_xpression, Data>::result_type
    7878            xpr_type;
    79            
     79
    8080            typedef
    8181                detail::simple_repeat_matcher<xpr_type, Greedy>
    8282            matcher_type;
    83            
     83
    8484            typedef
    8585                typename proto::terminal<matcher_type>::type
     
    166166                typename proto::result_of::child<Expr>::type
    167167            xpr_type;
    168            
     168
    169169            typedef
    170170                typename InsertMark::impl<xpr_type, State, Data>::result_type
     
    225225                detail::alternate_end_xpression
    226226            end_xpr;
    227            
     227
    228228            typedef
    229229                detail::optional_matcher<
     
    257257                detail::alternate_end_xpression
    258258            end_xpr;
    259            
     259
    260260            typedef
    261261                detail::optional_mark_matcher<
  • branches/proto/v4/boost/xpressive/detail/static/width_of.hpp

    r44402 r44677  
    3838      : mpl::size_t<N + M>
    3939    {};
    40    
     40
    4141    template<std::size_t M>
    4242    struct add_widths<unknown_width::value, M>
    4343      : unknown_width
    4444    {};
    45    
     45
    4646    template<std::size_t N>
    4747    struct add_widths<N, unknown_width::value>
    4848      : unknown_width
    4949    {};
    50    
     50
    5151    template<>
    5252    struct add_widths<unknown_width::value, unknown_width::value>
  • branches/proto/v4/boost/xpressive/regex_primitives.hpp

    r44565 r44677  
    189189                >
    190190            skip_transform;
    191            
     191
    192192            typedef
    193193                typename proto::shift_right<
  • branches/proto/v4/libs/proto/test/examples.cpp

    r44402 r44677  
    8282        /*<< Apply `CalculatorArity` to find the arity of the child. >>*/
    8383        typedef typename boost::result_of<CalculatorArity(child_expr, State, Data)>::type result_type;
    84        
     84
    8585        /*<< The `unary_arity` transform doesn't have an interesting
    8686        runtime counterpart, so just return a default-constructed object
  • branches/proto/v4/libs/proto/test/make_expr.cpp

    r44402 r44677  
    264264    void const *addr2 = boost::addressof(proto::child_c<1>(proto::child_c<0>(Convert()(expr))));
    265265    BOOST_CHECK_EQUAL(addr1, addr2);
    266    
     266
    267267    BOOST_CHECK_EQUAL(1, proto::value(proto::child_c<1>(proto::child_c<0>(expr))));
    268268    BOOST_CHECK_EQUAL(1, proto::value(proto::child_c<1>(proto::child_c<0>(Convert()(expr)))));
  • branches/proto/v4/libs/proto/test/matches.cpp

    r44402 r44677  
    1212#include <boost/type_traits/is_same.hpp>
    1313#include <boost/proto/core.hpp>
    14 #include <boost/proto/transform.hpp>
     14#include <boost/proto/transform/arg.hpp>
    1515#include <boost/test/unit_test.hpp>
    1616
  • branches/proto/v4/libs/proto/test/toy_spirit.cpp

    r44402 r44677  
    440440                >::type
    441441            result_type;
    442            
     442
    443443            result_type operator ()(
    444444                typename impl::expr_param expr
  • branches/proto/v4/libs/xpressive/doc/acknowledgements.qbk

    r43799 r44677  
    99
    1010I am indebted to [@http://boost.org/people/joel_de_guzman.htm Joel de Guzman]
    11 and [@http://boost.org/people/hartmut_kaiser.htm Hartmut Kaiser] for their 
     11and [@http://boost.org/people/hartmut_kaiser.htm Hartmut Kaiser] for their
    1212expert advice during the early states of xpressive's development. Much of
    1313static xpressive's syntax is owes a large debt to _spirit_, including the
    14 syntax for xpressive's semantic actions. I am thankful for 
     14syntax for xpressive's semantic actions. I am thankful for
    1515[@http://boost.org/people/john_maddock.htm John Maddock]'s excellent work on
    1616his proposal to add regular expressions to the standard library, and for
    1717various ideas borrowed liberally from his regex implementation. I'd also like
    1818to thank [@http://moderncppdesign.com/ Andrei Alexandrescu] for his input
    19 regarding the behavior of nested regex objects, and 
     19regarding the behavior of nested regex objects, and
    2020[@http://boost.org/people/dave_abrahams.htm Dave Abrahams] for his suggestions
    2121regarding the regex domain-specific embedded language. Noel Belcourt helped
  • branches/proto/v4/libs/xpressive/doc/actions.qbk

    r43799 r44677  
    1111
    1212Imagine you want to parse an input string and build a `std::map<>` from it. For
    13 something like that, matching a regular expression isn't enough. You want to 
     13something like that, matching a regular expression isn't enough. You want to
    1414/do something/ when parts of your regular expression match. Xpressive lets
    1515you attach semantic actions to parts of your static regular expressions. This
     
    3232        std::map<std::string, int> result;
    3333        std::string str("aaa=>1 bbb=>23 ccc=>456");
    34        
     34
    3535        // Match a word and an integer, separated by =>,
    3636        // and then stuff the result into a std::map<>
    3737        sregex pair = ( (s1= +_w) >> "=>" >> (s2= +_d) )
    3838            [ ref(result)[s1] = as<int>(s2) ];
    39        
     39
    4040        // Match one or more word/integer pairs, separated
    4141        // by whitespace.
     
    4848            std::cout << result["ccc"] << '\n';
    4949        }
    50        
     50
    5151        return 0;
    5252    }
     
    6060]
    6161
    62 The regular expression `pair` has two parts: the pattern and the action. The 
     62The regular expression `pair` has two parts: the pattern and the action. The
    6363pattern says to match a word, capturing it in sub-match 1, and an integer,
    6464capturing it in sub-match 2, separated by `"=>"`. The action is the part in
     
    7474it later. The expression `ref(result)` creates a lazy reference to the `result`
    7575object. The larger expression `ref(result)[s1]` is a lazy map index operation.
    76 Later, when this action is getting executed, `s1` gets replaced with the 
     76Later, when this action is getting executed, `s1` gets replaced with the
    7777first _sub_match_. Likewise, when `as<int>(s2)` gets executed, `s2` is replaced
    78 with the second _sub_match_. The `as<>` action converts its argument to the 
     78with the second _sub_match_. The `as<>` action converts its argument to the
    7979requested type using Boost.Lexical_cast. The effect of the whole action is to
    8080insert a new word/integer pair into the map.
    8181
    8282[note There is an important difference between the function `boost::ref()` in
    83 `<boost/ref.hpp>` and `boost::xpressive::ref()` in 
    84 `<boost/xpressive/regex_actions.hpp>`. The first returns a plain 
     83`<boost/ref.hpp>` and `boost::xpressive::ref()` in
     84`<boost/xpressive/regex_actions.hpp>`. The first returns a plain
    8585`reference_wrapper<>` which behaves in many respects like an ordinary
    8686reference. By contrast, `boost::xpressive::ref()` returns a /lazy/ reference
     
    138138action? Xpressive provides a mechanism to do this.
    139139
    140 The first step is to define a function object type. Here, for instance, is a 
     140The first step is to define a function object type. Here, for instance, is a
    141141function object type that calls `push()` on its argument:
    142142
     
    159159    function<push_impl>::type const push = {{}};
    160160
    161 The initialization looks a bit odd, but this is because `push` is being 
     161The initialization looks a bit odd, but this is because `push` is being
    162162statically initialized. That means it doesn't need to be constructed
    163163at runtime. We can use `push` in semantic actions as follows:
     
    183183that returns the `first` member of a `std::pair<>` or _sub_match_:
    184184
    185     // Function object that returns the 
     185    // Function object that returns the
    186186    // first element of a pair.
    187187    struct first_impl
     
    205205
    206206    // OK, use as first(s1) to get the begin iterator
    207     // of the sub-match referred to by s1.   
     207    // of the sub-match referred to by s1.
    208208    function<first_impl>::type const first = {{}};
    209209
     
    239239
    240240In the above code, we use `xpressive::val()` to hold the shared pointer by
    241 value. That's not normally necessary because local variables appearing in 
     241value. That's not normally necessary because local variables appearing in
    242242actions are held by value by default, but in this case, it is necessary. Had
    243243we written the action as `++*pi`, it would have executed immediately. That's
     
    264264As you can see, when using `reference<>`, you need to first declare a local
    265265variable and then declare a `reference<>` to it. These two steps can be combined
    266 into one using `local<>`. 
     266into one using `local<>`.
    267267
    268268[table local<> vs. reference<>
     
    302302call one of the regex algorithms, we can bind the reference to an actual
    303303map object. The following code shows how.
    304    
     304
    305305    // Define a placeholder for a map object:
    306306    placeholder<std::map<std::string, int> > _map;
    307    
     307
    308308    // Match a word and an integer, separated by =>,
    309309    // and then stuff the result into a std::map<>
    310310    sregex pair = ( (s1= +_w) >> "=>" >> (s2= +_d) )
    311311        [ _map[s1] = as<int>(s2) ];
    312    
     312
    313313    // Match one or more word/integer pairs, separated
    314314    // by whitespace.
     
    320320    // Here is the actual map to fill in:
    321321    std::map<std::string, int> result;
    322    
     322
    323323    // Bind the _map placeholder to the actual map
    324324    smatch what;
     
    341341]
    342342
    343 We use `placeholder<>` here to define `_map`, which stands in for a 
     343We use `placeholder<>` here to define `_map`, which stands in for a
    344344`std::map<>` variable. We can use the placeholder in the semantic action as if
    345345it were a map. Then, we define a _match_results_ struct and bind an actual map
    346 to the placeholder with "`what.let( _map = result );`". The _regex_match_ call 
     346to the placeholder with "`what.let( _map = result );`". The _regex_match_ call
    347347behaves as if the placeholder in the semantic action had been replaced with a
    348348reference to `result`.
     
    361361    // Define a placeholder for a map object:
    362362    placeholder<std::map<std::string, int> > _map;
    363    
     363
    364364    // Match a word and an integer, separated by =>,
    365365    // and then stuff the result into a std::map<>
    366366    sregex pair = ( (s1= +_w) >> "=>" >> (s2= +_d) )
    367367        [ _map[s1] = as<int>(s2) ];
    368    
     368
    369369    // The string to parse
    370370    std::string str("aaa=>1 bbb=>23 ccc=>456");
    371    
     371
    372372    // Here is the actual map to fill in:
    373373    std::map<std::string, int> result;
    374    
     374
    375375    // Create a regex_iterator to find all the matches
    376376    sregex_iterator it(str.begin(), str.end(), pair, let(_map=result));
    377377    sregex_iterator end;
    378    
     378
    379379    // step through all the matches, and fill in
    380380    // the result map
    381381    while(it != end)
    382382        ++it;
    383    
     383
    384384    std::cout << result["aaa"] << '\n';
    385385    std::cout << result["bbb"] << '\n';
     
    398398You are probably already familiar with regular expression /assertions/. In
    399399Perl, some examples are the [^^] and [^$] assertions, which you can use to
    400 match the beginning and end of a string, respectively. Xpressive lets you 
     400match the beginning and end of a string, respectively. Xpressive lets you
    401401define your own assertions. A custom assertion is a contition which must be
    402402true at a point in the match in order for the match to succeed. You can check
     
    439439
    440440In the above, `length()` is a lazy function that calls the `length()` member
    441 function of its argument, and `_` is a placeholder that receives the 
     441function of its argument, and `_` is a placeholder that receives the
    442442`sub_match`.
    443443
     
    452452    mark_tag month(1), day(2);
    453453    // find a valid date of the form month/day/year.
    454     sregex date = 
     454    sregex date =
    455455        (
    456456            // Month must be between 1 and 12 inclusive
  • branches/proto/v4/libs/xpressive/doc/dynamic_regexes.qbk

    r43799 r44677  
    2121function or with the _regex_compiler_ class template. Use _regex_compile_
    2222if you want the default locale. Use _regex_compiler_ if you need to
    23 specify a different locale. In the section on 
     23specify a different locale. In the section on
    2424[link boost_xpressive.user_s_guide.grammars_and_nested_matches regex grammars],
    2525we'll see another use for _regex_compiler_.
  • branches/proto/v4/libs/xpressive/doc/history.qbk

    r43799 r44677  
    6767[h2 Version 0.0.1, November 16, 2003]
    6868
    69 Announcement of xpressive: 
     69Announcement of xpressive:
    7070[@http://lists.boost.org/Archives/boost/2003/11/56312.php]
    7171
  • branches/proto/v4/libs/xpressive/doc/installation.qbk

    r43799 r44677  
    1717[@http://www.boost-consulting.com/vault/index.php?directory=Strings%20-%20Text%20Processing
    1818Boost File Vault] in the ["Strings - Text Processing] directory. In addition to
    19 the source code and the Boost license, this archive contains a copy of this 
     19the source code and the Boost license, this archive contains a copy of this
    2020documentation in PDF format. This version will always be stable and at least as
    2121current as the version in the latest Boost release. It may be more recent. The
  • branches/proto/v4/libs/xpressive/doc/introduction.qbk

    r43799 r44677  
    1616Expression Templates]] that are parsed at compile-time (static regexes).
    1717Dynamic regexes have the advantage that they can be accepted from the user
    18 as input at runtime or read from an initialization file. Static regexes 
     18as input at runtime or read from an initialization file. Static regexes
    1919have several advantages. Since they are C++ expressions instead of
    2020strings, they can be syntax-checked at compile-time. Also, they can naturally
  • branches/proto/v4/libs/xpressive/doc/matching.qbk

    r43799 r44677  
    2424
    2525The input can be a bidirectional range such as `std::string`, a C-style null-terminated string or a pair of
    26 iterators. In all cases, the type of the iterator used to traverse the input sequence must match the iterator 
    27 type used to declare the regex object. (You can use the table in the 
     26iterators. In all cases, the type of the iterator used to traverse the input sequence must match the iterator
     27type used to declare the regex object. (You can use the table in the
    2828[link boost_xpressive.user_s_guide.quick_start.know_your_iterator_type Quick Start] to find the correct regex
    2929type for your iterator.)
     
    7979In all other regards, _regex_search_ behaves like _regex_match_ ['(see above)]. In particular, it can operate
    8080on a bidirectional range such as `std::string`, C-style null-terminated strings or iterator ranges. The same
    81 care must be taken to ensure that the iterator type of your regex matches the iterator type of your input 
    82 sequence. As with _regex_match_, you can optionally provide a _match_results_ struct to receive the results 
     81care must be taken to ensure that the iterator type of your regex matches the iterator type of your input
     82sequence. As with _regex_match_, you can optionally provide a _match_results_ struct to receive the results
    8383of the search, and a _match_flag_type_ bitmask to control how the match is evaluated.
    8484
  • branches/proto/v4/libs/xpressive/doc/nyi.qbk

    r43799 r44677  
    1111
    1212* `syntax_option_type::collate`
    13 * Collation sequences such as [^'''[.a.]'''] 
     13* Collation sequences such as [^'''[.a.]''']
    1414* Equivalence classes like [^'''[=a=]''']
    1515* Control of nested results generation with `syntax_option_type::nosubs`,
  • branches/proto/v4/libs/xpressive/doc/substitutions.qbk

    r43799 r44677  
    6868[h2 The ECMA-262 Format Sequences]
    6969
    70 When you haven't specified a substitution string dialect with one of the format flags above, 
     70When you haven't specified a substitution string dialect with one of the format flags above,
    7171you get the dialect defined by ECMA-262, the standard for ECMAScript. The table below shows
    7272the escape sequences recognized in ECMA-262 mode.
  • branches/proto/v4/libs/xpressive/doc/symbols.qbk

    r43799 r44677  
    1010[h2 Overview]
    1111
    12 Symbol tables can be built into xpressive regular expressions with just a 
     12Symbol tables can be built into xpressive regular expressions with just a
    1313`std::map<>`. The map keys are the strings to be matched and the map values are
    1414the data to be returned to your semantic action. Xpressive attributes, named
     
    8484along with some special number names like "dozen".
    8585
    86 Symbol table matches are case sensitive by default, but they can be made 
     86Symbol table matches are case sensitive by default, but they can be made
    8787case-insensitive by enclosing the expression in `icase()`.
    8888
Note: See TracChangeset for help on using the changeset viewer.