Changed the FNV include path
[fridhskrift.git] / fridh / function.hpp
blobf6d69a35178f577dcfd5842858b009c2ef841795
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;
129 union
131 variable * variable_pointer;
132 parse_tree_symbol * symbol_pointer;
133 parse_tree_unary_operator_node * unary_operator_pointer;
134 parse_tree_binary_operator_node * binary_operator_pointer;
135 parse_tree_call * call_pointer;
136 parse_tree_array * array_pointer;
139 parse_tree_node();
140 parse_tree_node(parse_tree_node const & other);
141 ~parse_tree_node();
143 parse_tree_node & operator=(parse_tree_node const & other);
145 void copy(parse_tree_node const & other);
146 void destroy();
148 parse_tree_node(parse_tree_node_type::type type);
149 parse_tree_node(variable * variable_pointer);
150 parse_tree_node(unary_operator_type::type unary_operator);
151 parse_tree_node(binary_operator_type::type binary_operator);
152 parse_tree_node(parse_tree_nodes & elements);
154 void is_call();
155 bool is_post_fix() const;
156 std::string to_string() const;
157 bool is_call_node() const;
160 struct parse_tree_symbol
162 std::string name;
163 symbol_prefix::type type;
165 parse_tree_symbol();
168 struct parse_tree_unary_operator_node
170 unary_operator_type::type type;
171 parse_tree_node argument;
174 struct parse_tree_binary_operator_node
176 binary_operator_type::type type;
177 parse_tree_node
178 left_argument,
179 right_argument;
182 struct parse_tree_call
184 parse_tree_node function;
185 parse_tree_nodes arguments;
188 struct parse_tree_array
190 parse_tree_nodes elements;
193 struct if_statement
195 parse_tree_node conditional_term;
196 executable_units body;
199 struct if_else_statement
201 parse_tree_node conditional_term;
202 executable_units
203 if_body,
204 else_body;
207 struct for_each_statement
209 parse_tree_node container;
210 executable_units body;
213 struct for_statement
215 parse_tree_node
216 initialisation,
217 conditional,
218 iteration;
219 executable_units body;
222 struct while_statement
224 parse_tree_node conditional_term;
225 executable_units body;
228 struct executable_unit
230 executable_unit_type::type type;
232 union
234 parse_tree_node * statement_pointer;
235 if_statement * if_pointer;
236 if_else_statement * if_else_pointer;
237 for_each_statement * for_each_pointer;
238 for_statement * for_pointer;
239 while_statement * while_pointer;
242 executable_unit();
243 executable_unit(executable_unit const & other);
244 ~executable_unit();
246 executable_unit & operator=(executable_unit const & other);
248 void copy(executable_unit const & other);
249 void destroy();
252 struct function
254 string_vector arguments;
255 executable_units body;