OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Expression/Parser/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
79
85
91
93 {
95 std::list<function_call_argument> args;
96 };
97
99 {
101 std::list<operation> rest;
102 };
103#if 0
104 // print functions for debugging
105 inline std::ostream& operator<<(std::ostream& out, nil)
106 {
107 out << "nil"; return out;
108 }
109#endif
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
std::list< function_call_argument > args
boost::variant< nil, bool, unsigned int, double, identifier, boost::recursive_wrapper< unary >, boost::recursive_wrapper< function_call >, boost::recursive_wrapper< expression > > operand
std::ostream & operator<<(std::ostream &out, identifier const &id)
boost::variant< expression, quoted_string > function_call_argument
identifier(std::string const &name="")
quoted_string(std::string const &value="")