]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/example/qi/compiler_tutorial/mini_c/expression.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / example / qi / compiler_tutorial / mini_c / expression.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #if !defined(BOOST_SPIRIT_MINIC_EXPRESSION_HPP)
8 #define BOOST_SPIRIT_MINIC_EXPRESSION_HPP
9
10 ///////////////////////////////////////////////////////////////////////////////
11 // Spirit v2.5 allows you to suppress automatic generation
12 // of predefined terminals to speed up complation. With
13 // BOOST_SPIRIT_NO_PREDEFINED_TERMINALS defined, you are
14 // responsible in creating instances of the terminals that
15 // you need (e.g. see qi::uint_type uint_ below).
16 #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
17 ///////////////////////////////////////////////////////////////////////////////
18
19 ///////////////////////////////////////////////////////////////////////////////
20 // Uncomment this if you want to enable debugging
21 // #define BOOST_SPIRIT_QI_DEBUG
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include <boost/spirit/include/qi.hpp>
25 #include "ast.hpp"
26 #include "error_handler.hpp"
27 #include "skipper.hpp"
28 #include <vector>
29
30 namespace client { namespace parser
31 {
32 namespace qi = boost::spirit::qi;
33 namespace ascii = boost::spirit::ascii;
34
35 ///////////////////////////////////////////////////////////////////////////////
36 // The expression grammar
37 ///////////////////////////////////////////////////////////////////////////////
38 template <typename Iterator>
39 struct expression : qi::grammar<Iterator, ast::expression(), skipper<Iterator> >
40 {
41 expression(error_handler<Iterator>& error_handler);
42
43 qi::rule<Iterator, ast::expression(), skipper<Iterator> >
44 expr, equality_expr, relational_expr,
45 logical_or_expr, logical_and_expr,
46 additive_expr, multiplicative_expr
47 ;
48
49 qi::rule<Iterator, ast::operand(), skipper<Iterator> >
50 unary_expr, primary_expr
51 ;
52
53 qi::rule<Iterator, ast::function_call(), skipper<Iterator> >
54 function_call
55 ;
56
57 qi::rule<Iterator, std::list<ast::expression>(), skipper<Iterator> >
58 argument_list
59 ;
60
61 qi::rule<Iterator, std::string(), skipper<Iterator> >
62 identifier
63 ;
64
65 qi::symbols<char, ast::optoken>
66 logical_or_op, logical_and_op,
67 equality_op, relational_op,
68 additive_op, multiplicative_op, unary_op
69 ;
70
71 qi::symbols<char>
72 keywords
73 ;
74 };
75 }}
76
77 #endif
78
79