1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2001-2011 Hartmut Kaiser
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #if !defined(BOOST_SPIRIT_CONJURE_EXPRESSION_HPP)
9 #define BOOST_SPIRIT_CONJURE_EXPRESSION_HPP
11 ///////////////////////////////////////////////////////////////////////////////
12 // Spirit v2.5 allows you to suppress automatic generation
13 // of predefined terminals to speed up complation. With
14 // BOOST_SPIRIT_NO_PREDEFINED_TERMINALS defined, you are
15 // responsible in creating instances of the terminals that
16 // you need (e.g. see qi::uint_type uint_ below).
17 #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
18 ///////////////////////////////////////////////////////////////////////////////
20 ///////////////////////////////////////////////////////////////////////////////
21 // Uncomment this if you want to enable debugging
22 // #define BOOST_SPIRIT_QI_DEBUG
23 ///////////////////////////////////////////////////////////////////////////////
25 #include <boost/spirit/include/qi.hpp>
27 #include "error_handler.hpp"
30 namespace client { namespace parser
32 namespace qi = boost::spirit::qi;
33 namespace ascii = boost::spirit::ascii;
35 ///////////////////////////////////////////////////////////////////////////////
36 // The expression grammar
37 ///////////////////////////////////////////////////////////////////////////////
38 template <typename Iterator, typename Lexer>
39 struct expression : qi::grammar<Iterator, ast::expression()>
41 typedef error_handler<typename Lexer::base_iterator_type, Iterator>
44 expression(error_handler_type& error_handler, Lexer const& l);
48 qi::rule<Iterator, ast::expression()> expr;
49 qi::rule<Iterator, ast::operand()> unary_expr, postfix_expr;
50 qi::rule<Iterator, ast::function_call()> function_call;
51 qi::rule<Iterator, std::list<ast::expression>()> argument_list;
52 qi::rule<Iterator, std::string()> identifier;
53 qi::rule<Iterator, ast::primary_expr()> primary_expr;