1 /*=============================================================================
2     Copyright (c) 2001-2014 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_X3_CALC7_AST_HPP)
8 #define BOOST_SPIRIT_X3_CALC7_AST_HPP
9 
10 #include <boost/spirit/home/x3/support/ast/variant.hpp>
11 #include <boost/spirit/home/x3/support/ast/position_tagged.hpp>
12 #include <boost/fusion/include/io.hpp>
13 #include <list>
14 
15 namespace client { namespace ast
16 {
17     namespace x3 = boost::spirit::x3;
18 
19     ///////////////////////////////////////////////////////////////////////////
20     //  The AST
21     ///////////////////////////////////////////////////////////////////////////
22     struct nil {};
23     struct signed_;
24     struct expression;
25 
26     struct operand : x3::variant<
27             nil
28           , unsigned int
29           , x3::forward_ast<signed_>
30           , x3::forward_ast<expression>
31         >
32     {
33         using base_type::base_type;
34         using base_type::operator=;
35     };
36 
37     struct signed_
38     {
39         char sign;
40         operand operand_;
41     };
42 
43     struct operation
44     {
45         char operator_;
46         operand operand_;
47     };
48 
49     struct expression
50     {
51         operand first;
52         std::list<operation> rest;
53     };
54 
55     // print function for debugging
operator <<(std::ostream & out,nil)56     inline std::ostream& operator<<(std::ostream& out, nil)
57     {
58         out << "nil";
59         return out;
60     }
61 }}
62 
63 #endif
64