OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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
15#include <list>
16#include <ostream>
17#include <string>
18
19namespace client { namespace ast
20{
21 struct tagged
22 {
23 int id; // Used to annotate the AST with the iterator position.
24 // This id is used as a key to a map<int, Iterator>
25 // (not really part of the AST.)
26 };
27
28 struct nil {};
29 struct unary;
30 struct function_call;
31 struct expression;
32
34 {
35 identifier(std::string const& name = "") : name(name) {}
36 std::string name;
37 };
38
40 {
41 quoted_string(std::string const& value = "") : value(value) {}
42 std::string value;
43 };
44
45 typedef boost::variant<
46 nil
47 , bool
48 , unsigned int
49 , double
51 , boost::recursive_wrapper<unary>
52 , boost::recursive_wrapper<function_call>
53 , boost::recursive_wrapper<expression>
54 >
56
57 typedef boost::variant<
60 >
62
81
87
93
95 {
97 std::list<function_call_argument> args;
98 };
99
101 {
103 std::list<operation> rest;
104 };
105#if 0
106 // print functions for debugging
107 inline std::ostream& operator<<(std::ostream& out, nil)
108 {
109 out << "nil"; return out;
110 }
111#endif
112 inline std::ostream& operator<<(std::ostream& out, identifier const& id)
113 {
114 out << id.name; return out;
115 }
116}}
117
120 (client::ast::optoken, operator_)
121 (client::ast::operand, operand_)
122)
123
126 (client::ast::optoken, operator_)
127 (client::ast::operand, operand_)
128)
129
132 (client::ast::identifier, function_name)
133 (std::list<client::ast::function_call_argument>, args)
134)
135
138 (client::ast::operand, first)
139 (std::list<client::ast::operation>, rest)
140)
141
142#endif
BOOST_FUSION_ADAPT_STRUCT(SDDS::column,(std::optional< std::string >, name_m)(std::optional< SDDS::ast::datatype >, type_m)(std::optional< std::string >, units_m)(std::optional< std::string >, description_m)(SDDS::ast::variant_t, value_m)) namespace SDDS
Definition column.hpp:184
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:55
@ op_plus
Definition ast.hpp:65
@ op_not_equal
Definition ast.hpp:73
@ op_less
Definition ast.hpp:74
@ op_equal
Definition ast.hpp:72
@ op_times
Definition ast.hpp:67
@ op_minus
Definition ast.hpp:66
@ op_less_equal
Definition ast.hpp:75
@ op_greater
Definition ast.hpp:76
@ op_greater_equal
Definition ast.hpp:77
@ op_positive
Definition ast.hpp:69
@ op_negative
Definition ast.hpp:70
@ op_divide
Definition ast.hpp:68
std::ostream & operator<<(std::ostream &out, identifier const &id)
Definition ast.hpp:112
boost::variant< expression, quoted_string > function_call_argument
Definition ast.hpp:61
std::string name
Definition ast.hpp:36
identifier(std::string const &name="")
Definition ast.hpp:35
quoted_string(std::string const &value="")
Definition ast.hpp:41
operand operand_
Definition ast.hpp:85
optoken operator_
Definition ast.hpp:84
std::list< function_call_argument > args
Definition ast.hpp:97
identifier function_name
Definition ast.hpp:96
std::list< operation > rest
Definition ast.hpp:103