• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CALC7_EXPRESSION_HPP)
8 #define BOOST_SPIRIT_CALC7_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 <vector>
28 
29 namespace client { namespace parser
30 {
31     namespace qi = boost::spirit::qi;
32     namespace ascii = boost::spirit::ascii;
33 
34     ///////////////////////////////////////////////////////////////////////////////
35     //  The expression grammar
36     ///////////////////////////////////////////////////////////////////////////////
37     template <typename Iterator>
38     struct expression : qi::grammar<Iterator, ast::expression(), ascii::space_type>
39     {
40         expression(error_handler<Iterator>& error_handler);
41 
42         qi::rule<Iterator, ast::expression(), ascii::space_type> expr;
43         qi::rule<Iterator, ast::expression(), ascii::space_type> additive_expr;
44         qi::rule<Iterator, ast::expression(), ascii::space_type> multiplicative_expr;
45         qi::rule<Iterator, ast::operand(), ascii::space_type> unary_expr;
46         qi::rule<Iterator, ast::operand(), ascii::space_type> primary_expr;
47         qi::rule<Iterator, std::string(), ascii::space_type> identifier;
48     };
49 }}
50 
51 #endif
52 
53 
54