The call operator parsing looks alright to me
[fridhskrift.git] / fridh / function.hpp
blob751dbab8c5fdd3cec849d77e3f21c5172cef30f2
1 #pragma once
3 #include <vector>
4 #include <string>
6 #include <ail/types.hpp>
8 #include <fridh/construction.hpp>
10 namespace fridh
12 namespace executable_unit_type
14 enum type
16 uninitialised,
18 statement,
19 return_statement,
20 if_statement,
21 if_else_statement,
22 for_each_statement,
23 for_statement,
24 while_statement,
28 namespace unary_operator_type
30 enum type
32 negation,
33 logical_not,
34 binary_not,
36 increment,
37 decrement,
41 namespace binary_operator_type
43 enum type
45 addition,
46 subtraction,
47 multiplication,
48 division,
49 modulo,
50 exponentiation,
52 less_than,
53 less_than_or_equal,
54 greater_than,
55 greater_than_or_equal,
56 not_equal,
57 equal,
59 logical_and,
60 logical_or,
62 shift_left,
63 shift_right,
65 binary_and,
66 binary_or,
67 binary_xor,
69 selection,
71 assignment,
72 addition_assignment,
73 subtraction_assignment,
74 multiplication_assignment,
75 division_assignment,
76 modulo_assignment,
77 exponentiation_assignment,
81 namespace parse_tree_node_type
83 enum type
85 uninitialised,
87 variable,
88 symbol,
89 unary_operator_node,
90 binary_operator_node,
91 call,
92 array,
94 call_operator,
95 spaced_call_operator,
97 iterator,
101 namespace symbol_prefix
103 enum type
105 none,
106 scope_operator,
107 class_operator,
111 struct parse_tree_node;
112 struct parse_tree_symbol;
113 struct executable_unit;
115 typedef std::vector<parse_tree_node> parse_tree_nodes;
116 typedef std::vector<parse_tree_symbol> parse_tree_symbols;
117 typedef std::vector<executable_unit> executable_units;
119 struct parse_tree_symbol;
120 struct parse_tree_unary_operator_node;
121 struct parse_tree_binary_operator_node;
122 struct parse_tree_call;
123 struct parse_tree_array;
125 struct parse_tree_node
127 parse_tree_node_type::type type;
128 union
130 variable * variable_pointer;
131 parse_tree_symbol * symbol_pointer;
132 parse_tree_unary_operator_node * unary_operator_pointer;
133 parse_tree_binary_operator_node * binary_operator_pointer;
134 parse_tree_call * call_pointer;
135 parse_tree_array * array_pointer;
138 parse_tree_node();
139 parse_tree_node(parse_tree_node const & other);
140 ~parse_tree_node();
142 parse_tree_node & operator=(parse_tree_node const & other);
144 void copy(parse_tree_node const & other);
145 void destroy();
147 parse_tree_node(parse_tree_node_type::type type);
148 parse_tree_node(variable * variable_pointer);
149 parse_tree_node(unary_operator_type::type unary_operator);
150 parse_tree_node(binary_operator_type::type binary_operator);
151 parse_tree_node(parse_tree_nodes & elements);
153 void is_call();
154 bool is_post_fix() const;
155 std::string to_string() const;
156 bool is_call_node() const;
159 struct parse_tree_symbol
161 std::string name;
162 symbol_prefix::type type;
164 parse_tree_symbol();
167 struct parse_tree_unary_operator_node
169 unary_operator_type::type type;
170 parse_tree_node argument;
173 struct parse_tree_binary_operator_node
175 binary_operator_type::type type;
176 parse_tree_node
177 left_argument,
178 right_argument;
181 struct parse_tree_call
183 parse_tree_node function;
184 parse_tree_nodes arguments;
186 bool initialised;
188 parse_tree_call();
191 struct parse_tree_array
193 parse_tree_nodes elements;
196 struct if_statement
198 parse_tree_node conditional_term;
199 executable_units body;
202 struct if_else_statement
204 parse_tree_node conditional_term;
205 executable_units
206 if_body,
207 else_body;
210 struct for_each_statement
212 parse_tree_node container;
213 executable_units body;
216 struct for_statement
218 parse_tree_node
219 initialisation,
220 conditional,
221 iteration;
222 executable_units body;
225 struct while_statement
227 parse_tree_node conditional_term;
228 executable_units body;
231 struct executable_unit
233 executable_unit_type::type type;
235 union
237 parse_tree_node * statement_pointer;
238 if_statement * if_pointer;
239 if_else_statement * if_else_pointer;
240 for_each_statement * for_each_pointer;
241 for_statement * for_pointer;
242 while_statement * while_pointer;
245 executable_unit();
246 executable_unit(executable_unit const & other);
247 ~executable_unit();
249 executable_unit & operator=(executable_unit const & other);
251 void copy(executable_unit const & other);
252 void destroy();
255 struct function
257 string_vector arguments;
258 executable_units body;