• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2003 Martin Wille
3     http://spirit.sourceforge.net/
4 
5     Use, modification and distribution is subject to the Boost Software
6     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7     http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #include <boost/spirit/include/classic_core.hpp>
10 #include <boost/spirit/include/classic_if.hpp>
11 
12 extern bool fun();
13 
14 struct ftor
15 {
16     bool operator()() const;
17 };
18 
19 int
main()20 main()
21 {
22     //////////////////////////////////
23     // compile time check wether as_parser<> works for if_p
24 
25     ::BOOST_SPIRIT_CLASSIC_NS::rule<> r;
26 
27     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p('-')['-'];
28     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p("-")["-"];
29     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p('-')['-'].else_p['-'];
30     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p("-")["-"].else_p["-"];
31 
32     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p(&fun)["foo"];
33     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p(ftor())["foo"];
34     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p(&fun)["foo"].else_p["bar"];
35     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p(ftor())["foo"].else_p["bar"];
36 
37     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p(r)[r];
38     r = ::BOOST_SPIRIT_CLASSIC_NS::if_p(r)[r].else_p[r];
39 }
40