123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837 |
- <?xml version="1.0" encoding="utf-8"?>
- <!--
- Copyright 2012 Eric Niebler
- 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)
- -->
- <header name="boost/proto/matches.hpp">
- <para>
- Contains definition of the
- <computeroutput>
- <classname alt="boost::proto::matches">proto::matches<></classname>
- </computeroutput>
- metafunction for determining if a given expression matches a given pattern.
- </para>
- <namespace name="boost">
- <namespace name="proto">
- <struct name="_">
- <inherit><type><classname>proto::transform</classname><_></type></inherit>
- <purpose>A wildcard grammar element that matches any expression, and a transform that returns
- the current expression unchanged.</purpose>
- <description>
- <para>
- The wildcard type, <computeroutput>proto::_</computeroutput>, is a grammar element such
- that <computeroutput><classname>proto::matches</classname><E, proto::_>::value</computeroutput>
- is <computeroutput>true</computeroutput> for any expression type <computeroutput>E</computeroutput>.
- </para>
- <para>
- The wildcard can also be used as a stand-in for a template argument when matching terminals.
- For instance, the following is a grammar that will match any
- <computeroutput>std::complex<></computeroutput> terminal:<programlisting>BOOST_MPL_ASSERT((
- <classname>proto::matches</classname><
- <classname>proto::terminal</classname><std::complex<double> >::type,
- <emphasis role="bold"><classname>proto::terminal</classname><std::complex< proto::_ > ></emphasis>
- >
- ));</programlisting>
- </para>
- <para>
- When used as a transform, <computeroutput>proto::_</computeroutput> returns the current expression
- unchanged. For instance, in the following, <computeroutput>proto::_</computeroutput> is used with
- the <computeroutput><classname alt="proto::fold">proto::fold<></classname></computeroutput>
- transform to fold the children of a node:<programlisting>struct CountChildren :
- <classname>proto::or_</classname><
- // Terminals have no children
- <classname>proto::when</classname><<classname>proto::terminal</classname><proto::_>, mpl::int_<0>()>,
- // Use proto::fold<> to count the children of non-terminals
- <classname>proto::otherwise</classname><
- <classname>proto::fold</classname><
- proto::_, // <-- fold the current expression
- mpl::int_<0>(),
- mpl::plus<<classname>proto::_state</classname>, mpl::int_<1> >()
- >
- >
- >
- {};</programlisting>
- </para>
- </description>
- <struct name="impl">
- <template>
- <template-type-parameter name="Expr"/>
- <template-type-parameter name="State"/>
- <template-type-parameter name="Data"/>
- </template>
- <inherit><type><classname>proto::transform_impl</classname><Expr, State, Data></type></inherit>
- <typedef name="result_type">
- <type>Expr</type>
- </typedef>
- <method-group name="public member functions">
- <method name="operator()" cv="const">
- <type>Expr</type>
- <parameter name="expr">
- <paramtype>typename impl::expr_param</paramtype>
- <description>
- <para>An expression </para>
- </description>
- </parameter>
- <parameter name="">
- <paramtype>typename impl::state_param</paramtype>
- </parameter>
- <parameter name="">
- <paramtype>typename impl::data_param</paramtype>
- </parameter>
- <returns>
- <para>
- <computeroutput>expr</computeroutput>
- </para>
- </returns>
- </method>
- </method-group>
- </struct>
- <typedef name="proto_grammar">
- <type>_</type>
- </typedef>
- </struct>
- <!-- proto::not_ -->
- <struct name="not_">
- <template>
- <template-type-parameter name="Grammar"/>
- </template>
- <inherit><type><classname>proto::transform</classname><not_<Grammar> ></type></inherit>
- <purpose>Inverts the set of expressions matched by a grammar. When used as a transform,
- <computeroutput>proto::not_<></computeroutput> returns the current expression unchanged.
- </purpose>
- <description>
- <para>
- If an expression type <computeroutput>E</computeroutput> does not match a grammar
- <computeroutput>G</computeroutput>, then <computeroutput>E</computeroutput> <emphasis>does</emphasis>
- match <computeroutput>proto::not_<G></computeroutput>. For example,
- <computeroutput><classname>proto::not_</classname><<classname>proto::terminal</classname><<classname>proto::_</classname>> ></computeroutput>
- will match any non-terminal.
- </para>
- </description>
- <struct name="impl">
- <template>
- <template-type-parameter name="Expr"/>
- <template-type-parameter name="State"/>
- <template-type-parameter name="Data"/>
- </template>
- <inherit><type><classname>proto::transform_impl</classname><Expr, State, Data></type></inherit>
- <typedef name="result_type">
- <type>Expr</type>
- </typedef>
- <method-group name="public member functions">
- <method name="operator()" cv="const">
- <type>Expr</type>
- <parameter name="expr">
- <paramtype>typename impl::expr_param</paramtype>
- <description>
- <para>An expression </para>
- </description>
- </parameter>
- <parameter name="">
- <paramtype>typename impl::state_param</paramtype>
- </parameter>
- <parameter name="">
- <paramtype>typename impl::data_param</paramtype>
- </parameter>
- <requires>
- <para>
- <computeroutput><classname>proto::matches</classname><Expr, proto::not_>::value</computeroutput>
- is <computeroutput>true</computeroutput>.
- </para>
- </requires>
- <returns>
- <para>
- <computeroutput>expr</computeroutput>
- </para>
- </returns>
- </method>
- </method-group>
- </struct>
- <typedef name="proto_grammar">
- <type>not_</type>
- </typedef>
- </struct>
- <!-- proto::if_ -->
- <struct name="if_">
- <template>
- <template-type-parameter name="If"/>
- <template-type-parameter name="Then">
- <default><type><classname>proto::_</classname></type></default>
- </template-type-parameter>
- <template-type-parameter name="Else">
- <default><type><classname>proto::not_</classname><<classname>proto::_</classname>></type></default>
- </template-type-parameter>
- </template>
- <inherit><classname>proto::transform</classname><if_<If, Then, Else> ></inherit>
- <purpose>Used to select one grammar or another based on the result of a compile-time Boolean.
- When used as a transform, <computeroutput>proto::if_<></computeroutput> selects between two
- transforms based on a compile-time Boolean.</purpose>
- <description>
- <para>
- When <computeroutput>proto::if_<If, Then, Else></computeroutput> is used as a grammar,
- <computeroutput>If</computeroutput> must be a Proto transform and
- <computeroutput>Then</computeroutput> and <computeroutput>Else</computeroutput> must be grammars.
- An expression type <computeroutput>E</computeroutput> matches
- <computeroutput>proto::if_<If, Then, Else></computeroutput> if
- <computeroutput>boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>, If>(E)>::type::value</computeroutput>
- is <computeroutput>true</computeroutput> and
- <computeroutput>E</computeroutput> matches <computeroutput>Then</computeroutput>; or, if
- <computeroutput>boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>, If>(E)>::type::value</computeroutput>
- is <computeroutput>false</computeroutput> and <computeroutput>E</computeroutput> matches <computeroutput>Else</computeroutput>.
- </para>
- <para>
- The template parameter <computeroutput>Then</computeroutput> defaults to <computeroutput><classname>proto::_</classname></computeroutput>
- and <computeroutput>Else</computeroutput> defaults to
- <computeroutput><classname>proto::not_</classname><<classname>proto::_</classname>></computeroutput>,
- so an expression type <computeroutput>E</computeroutput> will match
- <computeroutput>proto::if_<If></computeroutput> if and only if
- <computeroutput>boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>, If>(E)>::type::value</computeroutput>
- is <computeroutput>true</computeroutput>.
- </para>
- <para>
- <programlisting>// A grammar that only matches integral terminals,
- // using is_integral<> from Boost.Type_traits.
- struct IsIntegral :
- <classname>proto::and_</classname><
- <classname>proto::terminal</classname><<classname>proto::_</classname>>,
- <classname>proto::if_</classname>< boost::is_integral<<classname>proto::_value</classname>>()>
- >
- {};</programlisting>
- </para>
- <para>
- When <computeroutput>proto::if_<If, Then, Else></computeroutput> is used as a transform,
- <computeroutput>If</computeroutput>, <computeroutput>Then</computeroutput> and
- <computeroutput>Else</computeroutput> must be Proto transforms. When applying the transform to
- an expression <computeroutput>E</computeroutput>, state <computeroutput>S</computeroutput> and
- data <computeroutput>V</computeroutput>, if
- <computeroutput>boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>, If>(E,S,V)>::type::value</computeroutput>
- is <computeroutput>true</computeroutput> then the <computeroutput>Then</computeroutput> transform
- is applied; otherwise the <computeroutput>Else</computeroutput> transform is applied.
- <programlisting>// Match a terminal. If the terminal is integral, return
- // mpl::true_; otherwise, return mpl::false_.
- struct IsIntegral2 :
- <classname>proto::when</classname><
- <classname>proto::terminal</classname><_>,
- proto::if_<
- boost::is_integral<<classname>proto::_value</classname>>(),
- mpl::true_(),
- mpl::false_()
- >
- >
- {};</programlisting>
- </para>
- </description>
- <struct name="impl">
- <template>
- <template-type-parameter name="Expr"/>
- <template-type-parameter name="State"/>
- <template-type-parameter name="Data"/>
- </template>
- <inherit><type><classname>proto::transform_impl</classname>< Expr, State, Data ></type></inherit>
- <typedef name="result_type">
- <type>typename mpl::if_<
- typename boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>, If>(Expr, State, Data)>::type,
- typename boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>, Then>(Expr, State, Data)>::type,
- typename boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>, Else>(Expr, State, Data)>::type
- >::type</type>
- </typedef>
- <method-group name="public member functions">
- <method name="operator()" cv="const">
- <type>result_type</type>
- <parameter name="expr">
- <paramtype>typename impl::expr_param</paramtype>
- <description>
- <para>An expression </para>
- </description>
- </parameter>
- <parameter name="state">
- <paramtype>typename impl::state_param</paramtype>
- <description>
- <para>The current state </para>
- </description>
- </parameter>
- <parameter name="data">
- <paramtype>typename impl::data_param</paramtype>
- <description>
- <para>A data of arbitrary type </para>
- </description>
- </parameter>
- <returns>
- <para>
- <computeroutput><classname>proto::when</classname><<classname>proto::_</classname>, <replaceable>Then-or-Else</replaceable>>()(expr, state, data)</computeroutput>
- </para>
- </returns>
- </method>
- </method-group>
- </struct>
- <typedef name="proto_grammar">
- <type>if_</type>
- </typedef>
- </struct>
- <!-- proto::or_ -->
- <struct name="or_">
- <template>
- <template-type-parameter name="G" pack="1"/>
- </template>
- <inherit><type><classname>proto::transform</classname><or_<G...> ></type></inherit>
- <purpose>For matching one of a set of alternate grammars. Alternates are tried in order to avoid ambiguity.
- When used as a transform, <computeroutput>proto::or_<></computeroutput> applies the transform
- associated with the first grammar that matches the expression.</purpose>
- <description>
- <para>
- An expression type <computeroutput>E</computeroutput> matches
- <computeroutput>proto::or_<G<subscript>0</subscript>,G<subscript>1</subscript>,...G<subscript>n</subscript>></computeroutput>
- if <computeroutput>E</computeroutput> matches any <computeroutput>G<subscript>x</subscript></computeroutput> for
- <computeroutput>x</computeroutput> in <computeroutput>[0,n]</computeroutput>.
- </para>
- <para>
- When applying
- <computeroutput>proto::or_<G<subscript>0</subscript>,G<subscript>1</subscript>,...G<subscript>n</subscript>></computeroutput>
- as a transform with an expression <computeroutput>e</computeroutput> of type <computeroutput>E</computeroutput>,
- state <computeroutput>s</computeroutput> and data <computeroutput>d</computeroutput>, it is equivalent to
- <computeroutput>G<subscript>x</subscript>()(e, s, d)</computeroutput>, where
- <computeroutput>x</computeroutput> is the lowest number such that
- <computeroutput><classname>proto::matches</classname><E, G<subscript>x</subscript>>::value</computeroutput>
- is <computeroutput>true</computeroutput>.
- </para>
- <para>
- The maximun number of template arguments <computeroutput>proto::or_<></computeroutput> accepts
- is controlled by the <computeroutput><macroname>BOOST_PROTO_MAX_LOGICAL_ARITY</macroname></computeroutput>
- macro.
- </para>
- </description>
- <struct name="impl">
- <template>
- <template-type-parameter name="Expr"/>
- <template-type-parameter name="State"/>
- <template-type-parameter name="Data"/>
- </template>
- <inherit><type><classname>proto::transform_impl</classname>< Expr, State, Data ></type></inherit>
- <typedef name="result_type">
- <type><replaceable>unspecified</replaceable></type>
- </typedef>
- <method-group name="public member functions">
- <method name="operator()" cv="const">
- <type>result_type</type>
- <parameter name="expr">
- <paramtype>typename impl::expr_param</paramtype>
- <description>
- <para>An expression </para>
- </description>
- </parameter>
- <parameter name="state">
- <paramtype>typename impl::state_param</paramtype>
- <description>
- <para>The current state </para>
- </description>
- </parameter>
- <parameter name="data">
- <paramtype>typename impl::data_param</paramtype>
- <description>
- <para>A data of arbitrary type </para>
- </description>
- </parameter>
- <returns>
- <para>
- <computeroutput>
- G<subscript>x</subscript>()(expr, state, data)
- </computeroutput>, where
- <computeroutput>x</computeroutput> is the lowest number such that
- <computeroutput>
- <classname>proto::matches</classname><Expr, G<subscript>x</subscript>>::value
- </computeroutput>
- is <computeroutput>true</computeroutput>.
- </para>
- </returns>
- </method>
- </method-group>
- </struct>
- <typedef name="proto_grammar">
- <type>or_</type>
- </typedef>
- </struct>
- <!-- proto::and_ -->
- <struct name="and_">
- <template>
- <template-type-parameter name="G" pack="1"/>
- </template>
- <inherit><type><classname>proto::transform</classname><and_<G...> ></type></inherit>
- <purpose>For matching all of a set of grammars. When used as a transform,
- <computeroutput>proto::and_<></computeroutput> applies the transform associated
- with each grammar in the set and returns the result of the last.</purpose>
- <description>
- <para>
- An expression type <computeroutput>E</computeroutput> matches
- <computeroutput>proto::and_<G<subscript>0</subscript>,G<subscript>1</subscript>,...G<subscript>n</subscript>></computeroutput>
- if <computeroutput>E</computeroutput> matches all <computeroutput>G<subscript>x</subscript></computeroutput>
- for <computeroutput>x</computeroutput> in <computeroutput>[0,n]</computeroutput>.
- </para>
- <para>
- When applying
- <computeroutput>proto::and_<G<subscript>0</subscript>,G<subscript>1</subscript>,...G<subscript>n</subscript>></computeroutput>
- as a transform with an expression <computeroutput>e</computeroutput>, state
- <computeroutput>s</computeroutput> and data <computeroutput>d</computeroutput>, it is equivalent
- to <computeroutput>(G<subscript>0</subscript>()(e, s, d),G<subscript>1</subscript>()(e, s, d),...G<subscript>n</subscript>()(e, s, d))</computeroutput>.
- </para>
- <para>
- The maximun number of template arguments <computeroutput>proto::and_<></computeroutput> accepts
- is controlled by the <computeroutput><macroname>BOOST_PROTO_MAX_LOGICAL_ARITY</macroname></computeroutput>
- macro.
- </para>
- </description>
- <struct name="impl">
- <template>
- <template-type-parameter name="Expr"/>
- <template-type-parameter name="State"/>
- <template-type-parameter name="Data"/>
- </template>
- <inherit><type><classname>proto::transform_impl</classname>< Expr, State, Data ></type></inherit>
- <typedef name="result_type">
- <type>typename boost::result_of<G<subscript>n</subscript>(Expr, State, Data)>::type</type>
- </typedef>
- <method-group name="public member functions">
- <method name="operator()" cv="const">
- <type>result_type</type>
- <parameter name="expr">
- <paramtype>typename impl::expr_param</paramtype>
- <description>
- <para>An expression </para>
- </description>
- </parameter>
- <parameter name="state">
- <paramtype>typename impl::state_param</paramtype>
- <description>
- <para>The current state </para>
- </description>
- </parameter>
- <parameter name="data">
- <paramtype>typename impl::data_param</paramtype>
- <description>
- <para>A data of arbitrary type </para>
- </description>
- </parameter>
- <returns>
- <para>
- <computeroutput>(G<subscript>0</subscript>()(expr, state, data),G<subscript>1</subscript>()(expr, state, data),...G<subscript>n</subscript>()(expr, state, data))</computeroutput>
- </para>
- </returns>
- </method>
- </method-group>
- </struct>
- <typedef name="proto_grammar">
- <type>and_</type>
- </typedef>
- </struct>
- <!-- proto::switch_ -->
- <struct name="switch_">
- <template>
- <template-type-parameter name="Cases"/>
- <template-type-parameter name="Transform"/>
- </template>
- <inherit><classname>proto::transform</classname><switch_<Cases, Transform> ></inherit>
- <purpose>For matching one of a set of alternate grammars, which are looked up based on
- the result type of the transform passed in second template parameter.
- If no transform is passed, the default one is <computeroutput><classname>proto::tag_of</classname><<classname>proto::_</classname>>()</computeroutput>
- so the default matching is based on the expression's tag type. When used as a transform,
- <computeroutput>proto::switch_<></computeroutput> applies the transform associated
- with the sub-grammar that matches the expression.</purpose>
- <description>
- <para>
- An expression type <computeroutput>E</computeroutput> matches
- <computeroutput>proto::switch_<C,T></computeroutput> if
- <computeroutput>E</computeroutput> matches
- <computeroutput>C::case_<boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>,T>(E)>::type></computeroutput>.
- </para>
- <para>
- When applying <computeroutput>proto::switch_<C,T></computeroutput> as a
- transform with an expression <computeroutput>e</computeroutput> of type
- <computeroutput>E</computeroutput>, state <computeroutput>s</computeroutput> of
- type <computeroutput>S</computeroutput> and data <computeroutput>d</computeroutput>
- of type <computeroutput>D</computeroutput>, it is equivalent to
- <computeroutput>C::case_<boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>,T>(E,S,D)>::type>()(e, s, d)</computeroutput>.
- </para>
- </description>
- <struct name="impl">
- <template>
- <template-type-parameter name="Expr"/>
- <template-type-parameter name="State"/>
- <template-type-parameter name="Data"/>
- </template>
- <inherit><type>
- Cases::template case_<
- typename <classname>when</classname><_, Transform>::template impl<Expr, State, Data>::result_type
- >::template impl<Expr, State, Data></type>
- </inherit>
- </struct>
- <typedef name="proto_grammar">
- <type>switch_</type>
- </typedef>
- </struct>
- <!-- proto::exact -->
- <struct name="exact">
- <template>
- <template-type-parameter name="T"/>
- </template>
- <purpose>For forcing exact matches of terminal types.</purpose>
- <description>
- <para>By default, matching terminals ignores references and cv-qualifiers. For instance,
- a terminal expression of type
- <computeroutput><classname>proto::terminal</classname><int const &>::type</computeroutput>
- will match the grammar <computeroutput><classname>proto::terminal</classname><int></computeroutput>.
- If that is not desired, you can force an exact match with
- <computeroutput><classname>proto::terminal</classname><proto::exact<int> ></computeroutput>.
- This will only match integer terminals where the terminal is held by value.</para>
- </description>
- </struct>
- <!-- proto::convertible_to -->
- <struct name="convertible_to">
- <template>
- <template-type-parameter name="T"/>
- </template>
- <purpose>For matching terminals that are convertible to a type.</purpose>
- <description>
- <para>
- Use <computeroutput>proto::convertible_to<></computeroutput> to match a terminal that is
- convertible to some type. For example, the grammar
- <computeroutput><classname>proto::terminal</classname><proto::convertible_to<int> ></computeroutput>
- will match any terminal whose argument is convertible to an integer.
- </para>
- </description>
- </struct>
-
- <!-- proto::vararg -->
- <struct name="vararg">
- <template>
- <template-type-parameter name="Grammar"/>
- </template>
- <purpose>For matching a Grammar to a variable number of sub-expressions.</purpose>
- <description>
- <para>
- An expression type <computeroutput><classname>proto::basic_expr</classname><AT,
- <classname alt="proto::listN">proto::list<replaceable>N</replaceable></classname><A<subscript>0</subscript>,...A<subscript>n</subscript>,U<subscript>0</subscript>,...U<subscript>m</subscript>> ></computeroutput>
- matches a grammar <computeroutput><classname>proto::basic_expr</classname><BT,
- <classname alt="proto::listN">proto::list<replaceable>M</replaceable></classname><B<subscript>0</subscript>,...B<subscript>n</subscript>,proto::vararg<V> > ></computeroutput>
- if <computeroutput>BT</computeroutput> is <computeroutput><classname>proto::_</classname></computeroutput>
- or <computeroutput>AT</computeroutput>, and if
- <computeroutput>A<subscript>x</subscript></computeroutput> matches
- <computeroutput>B<subscript>x</subscript></computeroutput>
- for each <computeroutput>x</computeroutput> in <computeroutput>[0,n]</computeroutput>
- and if <computeroutput>U<subscript>x</subscript></computeroutput> matches
- <computeroutput>V</computeroutput> for each <computeroutput>x</computeroutput> in <computeroutput>[0,m]</computeroutput>.
- </para>
- <para>For example:</para>
- <para>
- <programlisting>// Match any function call expression, regardless
- // of the number of function arguments:
- struct Function :
- <classname>proto::function</classname>< proto::vararg<proto::_> >
- {};</programlisting>
- </para>
- <para>
- When used as a transform, <computeroutput>proto::vararg<G></computeroutput>
- applies <computeroutput>G</computeroutput>'s transform.
- </para>
- </description>
- </struct>
- <!-- proto::matches -->
- <struct name="matches">
- <template>
- <template-type-parameter name="Expr"/>
- <template-type-parameter name="Grammar"/>
- </template>
- <purpose>A Boolean metafunction that evaluates whether a given expression type matches a grammar.</purpose>
- <description>
- <para>
- <computeroutput>proto::matches<Expr, Grammar></computeroutput> inherits from
- <computeroutput>mpl::true_</computeroutput> if
- <computeroutput>Expr::proto_grammar</computeroutput> matches
- <computeroutput>Grammar::proto_grammar</computeroutput>, and from
- <computeroutput>mpl::false_</computeroutput> otherwise.
- </para>
- <para>
- Non-terminal expressions are matched against a grammar according to the following rules:
- <itemizedlist>
- <listitem>
- <para>
- The wildcard pattern, <computeroutput>
- <classname>proto::_</classname>
- </computeroutput>, matches any expression.
- </para>
- </listitem>
- <listitem>
- <para>
- An expression
- <computeroutput>
- <classname>proto::basic_expr</classname><AT,
- <classname alt="proto::listN">
- proto::list<replaceable>N</replaceable>
- </classname><A<subscript>0</subscript>,...A<subscript>n</subscript>>
- >
- </computeroutput>
- matches a grammar
- <computeroutput>
- <classname>proto::basic_expr</classname><BT,
- <classname alt="proto::listN">
- proto::list<replaceable>N</replaceable>
- </classname><B<subscript>0</subscript>,...B<subscript>n</subscript>>
- >
- </computeroutput> if
- <computeroutput>BT</computeroutput> is <computeroutput>
- <classname>proto::_</classname>
- </computeroutput> or
- <computeroutput>AT</computeroutput>, and if <computeroutput>
- A<subscript>x</subscript>
- </computeroutput> matches
- <computeroutput>
- B<subscript>x</subscript>
- </computeroutput> for each <computeroutput>x</computeroutput> in <computeroutput>[0,n]</computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- An expression
- <computeroutput>
- <classname>proto::basic_expr</classname><AT,
- <classname alt="proto::listN">
- proto::list<replaceable>N</replaceable>
- </classname><A<subscript>0</subscript>,...A<subscript>n</subscript>,U<subscript>0</subscript>,...U<subscript>m</subscript>>
- >
- </computeroutput> matches a grammar
- <computeroutput>
- <classname>proto::basic_expr</classname><BT,
- <classname alt="proto::listN">
- proto::list<replaceable>M</replaceable>
- </classname><B<subscript>0</subscript>,...B<subscript>n</subscript>,<classname>proto::vararg</classname><V>
- > >
- </computeroutput> if
- <computeroutput>BT</computeroutput> is <computeroutput>
- <classname>proto::_</classname>
- </computeroutput> or
- <computeroutput>AT</computeroutput>, and if
- <computeroutput>
- A<subscript>x</subscript>
- </computeroutput> matches
- <computeroutput>
- B<subscript>x</subscript>
- </computeroutput> for each
- <computeroutput>x</computeroutput> in <computeroutput>[0,n]</computeroutput> and if
- <computeroutput>
- U<subscript>x</subscript>
- </computeroutput> matches
- <computeroutput>V</computeroutput> for each <computeroutput>x</computeroutput> in
- <computeroutput>[0,m]</computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- An expression <computeroutput>E</computeroutput> matches
- <computeroutput>
- <classname>proto::or_</classname><B<subscript>0</subscript>,...B<subscript>n</subscript>>
- </computeroutput> if
- <computeroutput>E</computeroutput> matches some
- <computeroutput>
- B<subscript>x</subscript>
- </computeroutput> for
- <computeroutput>x</computeroutput> in <computeroutput>[0,n]</computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- An expression <computeroutput>E</computeroutput> matches
- <computeroutput>
- <classname>proto::and_</classname><B<subscript>0</subscript>,...B<subscript>n</subscript>>
- </computeroutput> if
- <computeroutput>E</computeroutput> matches all
- <computeroutput>
- B<subscript>x</subscript>
- </computeroutput> for
- <computeroutput>x</computeroutput> in <computeroutput>[0,n]</computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- An expression <computeroutput>E</computeroutput> matches
- <computeroutput>
- <classname>proto::if_</classname><T,U,V>
- </computeroutput> if:
- <itemizedlist>
- <listitem>
- <computeroutput>
- boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>,T>(E)>::type::value
- </computeroutput>
- is <computeroutput>true</computeroutput> and
- <computeroutput>E</computeroutput> matches
- <computeroutput>U</computeroutput>, <emphasis>or</emphasis>
- </listitem>
- <listitem>
- <computeroutput>
- boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>,T>(E)>::type::value
- </computeroutput>
- is <computeroutput>false</computeroutput> and <computeroutput>E</computeroutput> matches
- <computeroutput>V</computeroutput>.
- </listitem>
- </itemizedlist>
- Note: <computeroutput>U</computeroutput> defaults to <computeroutput>
- <classname>proto::_</classname>
- </computeroutput>
- and <computeroutput>V</computeroutput> defaults to
- <computeroutput>
- <classname>proto::not_</classname><<classname>proto::_</classname>>
- </computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- An expression <computeroutput>E</computeroutput> matches
- <computeroutput>
- <classname>proto::not_</classname><T>
- </computeroutput> if
- <computeroutput>E</computeroutput> does <emphasis>not</emphasis> match <computeroutput>T</computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- An expression <computeroutput>E</computeroutput> matches
- <computeroutput>
- <classname>proto::switch_</classname><C, T>
- </computeroutput> if
- <computeroutput>E</computeroutput> matches <computeroutput>C::case_<boost::result_of<<classname>proto::when</classname><<classname>proto::_</classname>,T>(E)>::type></computeroutput>.
- Note: <computeroutput>T</computeroutput> defaults to <computeroutput><classname>proto::tag_of</classname><<classname>proto::_</classname>>()</computeroutput>
- </para>
- </listitem>
- </itemizedlist>
- </para>
- <para>
- A terminal expression can trivially match the grammar <classname>proto::_</classname>. In addition,
- a terminal expression
- <computeroutput>
- <classname>proto::basic_expr</classname><AT,
- <classname>proto::term</classname><A> >
- </computeroutput> matches a grammar
- <computeroutput>
- <classname>proto::basic_expr</classname><BT, <classname>proto::term</classname><B> >
- </computeroutput>
- if <computeroutput>BT</computeroutput> is <computeroutput><classname>proto::_</classname></computeroutput>
- or <computeroutput>AT</computeroutput> and one of the following is true:
- <itemizedlist>
- <listitem>
- <para>
- <computeroutput>B</computeroutput> is the wildcard pattern,
- <computeroutput>
- <classname>proto::_</classname>
- </computeroutput>
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>A</computeroutput> is <computeroutput>B</computeroutput>
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>A</computeroutput> is <computeroutput>B &</computeroutput>
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>A</computeroutput> is <computeroutput>B const &</computeroutput>
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>B</computeroutput> is <computeroutput>
- <classname>proto::exact</classname><A>
- </computeroutput>
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>B</computeroutput> is
- <computeroutput>
- <classname>proto::convertible_to</classname><X>
- </computeroutput>
- and <computeroutput>boost::is_convertible<A,X>::value</computeroutput> is
- <computeroutput>true</computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>A</computeroutput> is <computeroutput>X[M]</computeroutput> or
- <computeroutput>X(&)[M]</computeroutput> and
- <computeroutput>B</computeroutput> is <computeroutput>
- X[<globalname>proto::N</globalname>]
- </computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>A</computeroutput> is <computeroutput>X(&)[M]</computeroutput>
- and <computeroutput>B</computeroutput> is <computeroutput>
- X(&)[<globalname>proto::N</globalname>]
- </computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>A</computeroutput> is <computeroutput>X[M]</computeroutput> or
- <computeroutput>X(&)[M]</computeroutput> and <computeroutput>B</computeroutput> is
- <computeroutput>X*</computeroutput>.
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>B</computeroutput> <replaceable>lambda-matches</replaceable>
- <computeroutput>A</computeroutput> (see below).
- </para>
- </listitem>
- </itemizedlist>
- </para>
- <para>
- A type <computeroutput>B</computeroutput> <replaceable>lambda-matches</replaceable>
- <computeroutput>A</computeroutput> if one of the following is true:
- <itemizedlist>
- <listitem>
- <para>
- <computeroutput>B</computeroutput> is <computeroutput>A</computeroutput>
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>B</computeroutput> is the wildcard pattern, <computeroutput>
- <classname>proto::_</classname>
- </computeroutput>
- </para>
- </listitem>
- <listitem>
- <para>
- <computeroutput>B</computeroutput> is <computeroutput>
- T<B<subscript>0</subscript>,...B<subscript>n</subscript>>
- </computeroutput> and <computeroutput>A</computeroutput> is <computeroutput>
- T<A<subscript>0</subscript>,...A<subscript>n</subscript>>
- </computeroutput> and for each <computeroutput>x</computeroutput> in <computeroutput>[0,n]</computeroutput>,
- <computeroutput>A<subscript>x</subscript></computeroutput> and
- <computeroutput>B<subscript>x</subscript></computeroutput> are types such that
- <computeroutput>A<subscript>x</subscript></computeroutput> <replaceable>lambda-matches</replaceable>
- <computeroutput>B<subscript>x</subscript></computeroutput>
- </para>
- </listitem>
- </itemizedlist>
- </para>
- </description>
- <inherit>
- <type>mpl::bool_<<replaceable>true-or-false</replaceable>></type></inherit>
- </struct>
- </namespace>
- </namespace>
- </header>
|