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_CONJURE_EXPRESSION_HPP) 8 #define BOOST_SPIRIT_CONJURE_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 45 ; 46 47 qi::rule<Iterator, ast::operand(), skipper<Iterator> > 48 unary_expr, primary_expr 49 ; 50 51 qi::rule<Iterator, ast::function_call(), skipper<Iterator> > 52 function_call 53 ; 54 55 qi::rule<Iterator, std::list<ast::expression>(), skipper<Iterator> > 56 argument_list 57 ; 58 59 qi::rule<Iterator, std::string(), skipper<Iterator> > 60 identifier 61 ; 62 63 qi::symbols<char, ast::optoken> 64 unary_op, binary_op 65 ; 66 67 qi::symbols<char> 68 keywords 69 ; 70 }; 71 }} 72 73 #endif 74 75 76