OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
ast.hpp
Go to the documentation of this file.
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(AST_HPP)
8#define AST_HPP
9
10#include <boost/config/warning_disable.hpp>
11#include <boost/variant/recursive_variant.hpp>
12#include <boost/fusion/include/adapt_struct.hpp>
13#include <boost/fusion/include/io.hpp>
14#include <boost/optional.hpp>
15#include <list>
16
17namespace client { namespace ast
18{
19 struct tagged
20 {
21 int id; // Used to annotate the AST with the iterator position.
22 // This id is used as a key to a map<int, Iterator>
23 // (not really part of the AST.)
24 };
25
26 struct nil {};
27 struct unary;
28 struct function_call;
29 struct expression;
30
32 {
33 identifier(std::string const& name = "") : name(name) {}
34 std::string name;
35 };
36
38 {
39 quoted_string(std::string const& value = "") : value(value) {}
40 std::string value;
41 };
42
43 typedef boost::variant<
44 nil
45 , bool
46 , unsigned int
47 , double
49 , boost::recursive_wrapper<unary>
50 , boost::recursive_wrapper<function_call>
51 , boost::recursive_wrapper<expression>
52 >
54
55 typedef boost::variant<
58 >
60
62 {
77 op_or
78 };
79
80 struct unary
81 {
84 };
85
86 struct operation
87 {
90 };
91
93 {
95 std::list<function_call_argument> args;
96 };
97
99 {
101 std::list<operation> rest;
102 };
103
104 // print functions for debugging
105 inline std::ostream& operator<<(std::ostream& out, nil)
106 {
107 out << "nil"; return out;
108 }
109
110 inline std::ostream& operator<<(std::ostream& out, identifier const& id)
111 {
112 out << id.name; return out;
113 }
114}}
115
118 (client::ast::optoken, operator_)
119 (client::ast::operand, operand_)
120)
121
124 (client::ast::optoken, operator_)
125 (client::ast::operand, operand_)
126)
127
130 (client::ast::identifier, function_name)
131 (std::list<client::ast::function_call_argument>, args)
132)
133
136 (client::ast::operand, first)
137 (std::list<client::ast::operation>, rest)
138)
139
140#endif
BOOST_FUSION_ADAPT_STRUCT(SDDS::column,(boost::optional< std::string >, name_m)(boost::optional< SDDS::ast::datatype >, type_m)(boost::optional< std::string >, units_m)(boost::optional< std::string >, description_m)(SDDS::ast::variant_t, value_m)) namespace SDDS
Definition: column.hpp:181
boost::variant< nil, bool, unsigned int, double, identifier, boost::recursive_wrapper< unary >, boost::recursive_wrapper< function_call >, boost::recursive_wrapper< expression > > operand
Definition: ast.hpp:53
@ op_plus
Definition: ast.hpp:63
@ op_not
Definition: ast.hpp:69
@ op_not_equal
Definition: ast.hpp:71
@ op_or
Definition: ast.hpp:77
@ op_less
Definition: ast.hpp:72
@ op_equal
Definition: ast.hpp:70
@ op_times
Definition: ast.hpp:65
@ op_and
Definition: ast.hpp:76
@ op_minus
Definition: ast.hpp:64
@ op_less_equal
Definition: ast.hpp:73
@ op_greater
Definition: ast.hpp:74
@ op_greater_equal
Definition: ast.hpp:75
@ op_positive
Definition: ast.hpp:67
@ op_negative
Definition: ast.hpp:68
@ op_divide
Definition: ast.hpp:66
boost::variant< expression, quoted_string > function_call_argument
Definition: ast.hpp:59
std::ostream & operator<<(std::ostream &out, nil)
Definition: ast.hpp:105
std::string name
Definition: ast.hpp:34
identifier(std::string const &name="")
Definition: ast.hpp:33
std::string value
Definition: ast.hpp:40
quoted_string(std::string const &value="")
Definition: ast.hpp:39
operand operand_
Definition: ast.hpp:83
optoken operator_
Definition: ast.hpp:82
operand operand_
Definition: ast.hpp:89
optoken operator_
Definition: ast.hpp:88
std::list< function_call_argument > args
Definition: ast.hpp:95
identifier function_name
Definition: ast.hpp:94
std::list< operation > rest
Definition: ast.hpp:101