90 ss <<
"Variable \033[0m'" << vds.
name <<
"'\033[31m cannot have access modifier outside the module";
97 if (value !=
nullptr) {
99 ss <<
"Variable \033[0m'" << vds.
name <<
"'\033[31m already exists";
104 if (vds.
expr !=
nullptr) {
119 var_val_val = std::get<1>(var_val.
value.
value);
122 var_val_val = std::get<2>(var_val.
value.
value);
125 var_val_val = std::get<3>(var_val.
value.
value);
128 var_val_val = std::get<4>(var_val.
value.
value);
131 switch (var_type.
type) {
145 if (var_val_val >= 0 && var_val_val <= max_val) {
147 var_val.
type = var_type;
149 else if (var_val_val < 0 && std::abs(var_val_val) <= max_val + 1) {
151 var_val.
type = var_type;
154 std::stringstream ss;
155 ss <<
"Value of expression is does not fit into the variable type: \033[0m'" << var_type.
to_str() <<
" (from " << (long)(-(max_val + 1)) <<
" to "
156 << max_val <<
")'\033[31m, passed value: \033[0m'" << var_val_val <<
"'\033[31m";
162 std::stringstream ss;
163 ss <<
"Type mismatch: an expression of the type \033[0m'" << var_val.
type.
to_str() <<
"'\033[31m, but the type is expected \033[0m'" << var_type.
to_str() <<
"'\033[31m";
172 if (var_val ==
nullptr) {
173 std::stringstream ss;
174 ss <<
"Variable \033[0m'" << vas.
name <<
"'\033[31m does not exists";
177 if (var_val->type.is_const) {
178 std::stringstream ss;
179 ss <<
"Variable \033[0m'" << vas.
name <<
"'\033[31m is a constant";
192 new_val_val = std::get<1>(new_val.
value.
value);
195 new_val_val = std::get<2>(new_val.
value.
value);
198 new_val_val = std::get<3>(new_val.
value.
value);
201 new_val_val = std::get<4>(new_val.
value.
value);
204 switch (var_type.
type) {
218 if (new_val_val >= 0 && new_val_val <= max_val) {
220 new_val.
type = var_type;
222 else if (new_val_val < 0 && std::abs(new_val_val) <= max_val + 1) {
224 new_val.
type = var_type;
227 std::stringstream ss;
228 ss <<
"Value of expression is does not fit into the variable type: \033[0m'" << var_type.
to_str() <<
" (from " << (long)(-(max_val + 1)) <<
" to "
229 << max_val <<
")'\033[31m, passed value: \033[0m'" << new_val_val <<
"'\033[31m";
235 std::stringstream ss;
236 ss <<
"Type mismatch: an expression of the type \033[0m'" << new_val.
type.
to_str() <<
"'\033[31m, but the type is expected \033[0m'" << var_type.
to_str() <<
"'\033[31m";
243 std::stringstream ss;
245 for (
size_t i = 0; i < fds.
args.size(); i++) {
246 ss << fds.
args[i].type.to_str();
247 if (i < fds.
args.size() - 1) {
251 ss <<
")'\033[31m cannot have access modifier outside the module";
263 if (!func_candidates.empty()) {
265 for (
auto& candidate : func_candidates) {
266 if (candidate->args.size() != fds.
args.size()) {
270 size_t coincidences = 0;
271 for (
size_t i = 0; i < candidate->args.size(); i++) {
272 if (candidate->args[i].type == fds.
args[i].type) {
276 if (coincidences == candidate->args.size()) {
286 std::stringstream ss;
288 for (
size_t i = 0; i < fds.
args.size(); i++) {
289 ss << fds.
args[i].type.to_str();
290 if (i < fds.
args.size() - 1) {
294 ss <<
")'\033[31m already exists";
301 std::shared_ptr<FunctionInfo> new_func = std::make_shared<FunctionInfo>(ret_type, std::move(fds.
args), std::move(fds.
block));
302 if (func_candidates.empty()) {
308 for (
auto& arg : new_func->args) {
311 bool have_ret_in_global =
false;
312 for (
auto& stmt : new_func->block) {
315 have_ret_in_global =
true;
319 if (val !=
nullptr) {
320 have_ret_in_global =
true;
325 if (val !=
nullptr) {
326 have_ret_in_global =
true;
331 if (val !=
nullptr) {
332 have_ret_in_global =
true;
337 if (val !=
nullptr) {
338 have_ret_in_global =
true;
343 std::stringstream ss;
344 ss <<
"Non-nothing function must be have return statement in the global space in the body of function. Please add or move return statement to the global space in the body of function";
355 if (func_candidates.empty()) {
357 if (func_candidates.empty()) {
358 std::stringstream ss;
360 for (
size_t i = 0; i < fcs.
args.size(); i++) {
362 if (i < fcs.
args.size() - 1) {
366 ss <<
")'\033[31m does not exists";
371 size_t coincidences = 0;
372 for (
auto& candidate : func_candidates) {
373 for (
size_t i = 0; i < candidate->args.size(); i++) {
374 if (fcs.
args.size() != candidate->args.size()) {
382 if (coincidences == candidate->args.size()) {
388 std::stringstream ss;
389 ss <<
"Function \033[0m'" <<
get_mangled_name(fcs.
name) <<
"'\033[31m does not have needed candidate.\nExists candidates:\n\033[0m";
391 for (
auto& candidate : func_candidates) {
393 for (
size_t i = 0; i < candidate->args.size(); i++) {
394 ss << candidate->args[i].type.to_str();
395 if (i < candidate->args.size() - 1) {
400 if (index < func_candidates.size() - 1) {
415 if (rs.
expr !=
nullptr) {
418 std::stringstream ss;
419 ss <<
"Type mismatch: an expression of the type \033[0m'" << val.
type.
to_str() <<
"'\033[31m, but the type is expected \033[0m'" <<
functions_ret_types.top().to_str() <<
"'\033[31m";
433 std::stringstream ss;
434 ss <<
"Type mismatch: the condition of the \033[0m'if'\033[31m operator must be of type \033[0m'bool'\033[31m, but got \033[0m'" << cond_val.
type.
to_str() <<
"'\033[31m";
454 std::stringstream ss;
455 ss <<
"Type mismatch: the condition of the \033[0m'while'\033[31m cycle must be of type \033[0m'bool'\033[31m, but got \033[0m'" << cond_val.
type.
to_str() <<
"'\033[31m";
460 for (
auto& stmt : wcs.
block) {
470 std::stringstream ss;
471 ss <<
"Type mismatch: the condition of the \033[0m'do-while'\033[31m cycle must be of type \033[0m'bool'\033[31m, but got \033[0m'" << cond_val.
type.
to_str() <<
"'\033[31m";
476 for (
auto& stmt : dwcs.
block) {
492 std::stringstream ss;
493 ss <<
"Type mismatch: the condition of the \033[0m'for'\033[31m cycle must be of type \033[0m'bool'\033[31m, but got \033[0m'" << cond_val.
type.
to_str() <<
"'\033[31m";
498 for (
auto& stmt : fcs.
block) {
519 std::stringstream ss;
520 ss <<
"Module \033[0m'" << ms.
name <<
"'\033[31m cannot have access modifier outside the module";
529 std::stringstream ss;
530 ss <<
"Module \033[0m'" << ms.
name <<
"'\033[31m already exists";
536 for (
auto& stmt : ms.
block) {
539 module->modules.emplace(sms->name, std::make_pair(sms->access, new ModuleInfo()));
540 ModuleInfo *submodule =
module->modules.find(sms->name)->second.second;
545 module->functions.emplace(fds->name, std::make_pair(fds->access, get_mangled_name(fds->name)));
556 std::string all_name;
557 for (
size_t i = 0; i < ums.
path.size(); i++) {
558 all_name += ums.
path[i];
559 if (i != ums.
path.size() - 1) {
568 std::filesystem::path path_to_mod_without_ext;
569 for (
size_t i = 0; i < ums.
path.size(); i++) {
570 path_to_mod_without_ext +=
"/" + ums.
path[i];
572 std::filesystem::path path_to_mod_without_ext_in_libs =
libs_path + path_to_mod_without_ext.string();
573 std::string path_to_mod_without_ext_in_libs_as_str = path_to_mod_without_ext_in_libs.string();
575 if (std::filesystem::is_directory(path_to_mod_without_ext_in_libs_as_str)) {
576 if (std::filesystem::exists(path_to_mod_without_ext_in_libs_as_str +
"/main.tp")) {
577 file = std::ifstream(path_to_mod_without_ext_in_libs_as_str +
"/main.tp");
578 if (!file.is_open()) {
579 std::stringstream ss;
580 ss <<
"Module \033[0m'" << all_name <<
"'\033[31m does not exists";
583 std::ostringstream content;
584 content << file.rdbuf();
586 Lexer lex(content.str(), path_to_mod_without_ext_in_libs_as_str +
"/main.tp",
is_debug);
587 std::vector<Token> tokens = lex.
tokenize();
589 std::vector<AST::StmtPtr>
stmts = parser.
parse();
594 std::stringstream ss;
595 ss <<
"File \033[0m'" << path_to_mod_without_ext_in_libs_as_str +
"/main.tp" <<
"'\033[31m does not have a module with name \033[0m'" << all_name <<
"'\033[31m inside";
600 this->modules.emplace(module.first, module.second);
604 for (
auto& func : module.second->functions) {
608 for (
size_t i =
current_path.size() - current_path_size; i > 0; i--) {
613 std::stringstream ss;
614 ss <<
"Module \033[0m'" << all_name <<
"'\033[31m does not exists";
619 std::string path_to_file;
620 for (
const auto& entry : std::filesystem::recursive_directory_iterator(
libs_path)) {
621 if (entry.path().filename() == ums.
path.back() +
".tp" && !std::filesystem::is_directory(entry.path())) {
622 path_to_file = entry.path();
623 file = std::ifstream(path_to_file);
627 if (!file.is_open()) {
628 std::stringstream ss;
629 ss <<
"Module \033[0m'" << all_name <<
"'\033[31m does not exists";
632 std::ostringstream content;
633 content << file.rdbuf();
635 Lexer lex(content.str(), path_to_mod_without_ext_in_libs_as_str +
".tp",
is_debug);
636 std::vector<Token> tokens = lex.
tokenize();
638 std::vector<AST::StmtPtr>
stmts = parser.
parse();
643 std::stringstream ss;
644 ss <<
"File \033[0m'" << path_to_file <<
"'\033[31m does not have a module with name \033[0m'" << all_name <<
"'\033[31m inside";
649 this->modules.emplace(module.first, module.second);
653 for (
auto& func : module.second->functions) {
657 for (
size_t i =
current_path.size() - current_path_size; i > 0; i--) {
663 std::stringstream ss;
664 ss <<
"Module \033[0m'" << ums.
path.back() <<
"'\033[31m already imported";
672 std::stringstream ss;
673 ss <<
"Specified language name for extern calling (\033[0m'" << es.
lang_name_lit <<
"'\033[31m) is unsupported";
676 for (
auto& stmt : es.
block) {
691 else if (
auto ve =
dynamic_cast<AST::VarExpr*
>(&expr)) {
720 std::stringstream ss;
721 ss <<
"Type mismatch: it is not possible to use the binary \033[0m'" << be.
op.
value <<
"'\033[31m operator with \033[0m'" << left_type.
to_str() <<
"'\033[31m and \033[0m'" << right_type.
to_str() <<
"'\033[31m types";
727 std::stringstream ss;
728 ss <<
"Type mismatch: it is not possible to use the binary \033[0m'" << be.
op.
value <<
"'\033[31m operator with \033[0m'" << left_type.
to_str() <<
"'\033[31m and \033[0m'" << right_type.
to_str() <<
"'\033[31m types";
734 #define VALUE(op, type) Value(output_type, static_cast<type>(binary_two_variants(left_val, right_val, op, be.line)), left_val.is_value_unknown || right_val.is_value_unknown, left_val.is_literal && right_val.is_literal)
743 std::stringstream ss;
744 ss <<
"Type mismatch: it is not possible to use the binary \033[0m'" << be.
op.
value <<
"'\033[31m operator with \033[0m'" << left_type.
to_str() <<
"'\033[31m and \033[0m'" << right_type.
to_str() <<
"'\033[31m types";
757 std::stringstream ss;
758 ss <<
"Type mismatch: it is not possible to use the binary \033[0m'" << be.
op.
value <<
"'\033[31m operator with \033[0m'" << left_type.
to_str() <<
"'\033[31m and \033[0m'" << right_type.
to_str() <<
"'\033[31m types";
764 std::stringstream ss;
765 ss <<
"Type mismatch: it is not possible to use the binary \033[0m'" << be.
op.
value <<
"'\033[31m operator with \033[0m'" << left_type.
to_str() <<
"'\033[31m and \033[0m'" << right_type.
to_str() <<
"'\033[31m types";
771 switch (output_type.
type) {
802 #define VALUE(op, needed_type) Value(type, static_cast<needed_type>(unary_two_variants(val, op, ue.line)), val.is_value_unknown, val.is_literal)
805 std::stringstream ss;
806 ss <<
"Type mismatch: it is not possible to use the unary \033[0m'" << ue.
op.
value <<
"'\033[31m operator with \033[0m'" << type.
to_str() <<
"'\033[31m type";
811 std::stringstream ss;
812 ss <<
"Type mismatch: it is not possible to use the unary \033[0m'" << ue.
op.
value <<
"'\033[31m operator with \033[0m'" << type.
to_str() <<
"'\033[31m type";
855 if (var ==
nullptr) {
859 std::stringstream ss;
860 ss <<
"Variable \033[0m'" << ve.
name <<
"'\033[31m does not exists";
868 if (func_candidates.empty()) {
870 if (func_candidates.empty()) {
871 std::stringstream ss;
873 for (
size_t i = 0; i < fce.
args.size(); i++) {
875 if (i < fce.
args.size() - 1) {
879 ss <<
")'\033[31m does not exists";
884 size_t last_score = SIZE_MAX;
885 size_t best_candidate_index = 0;
886 for (
size_t candidate_index = 0; candidate_index < func_candidates.size(); candidate_index++) {
888 size_t coincidences = 0;
889 auto candidate = func_candidates[candidate_index];
890 for (
size_t i = 0; i < candidate->args.size(); i++) {
891 if (fce.
args.size() != candidate->args.size()) {
896 if (arg_val.
type != candidate->args[i].
type) {
919 if (score <= last_score) {
920 best_candidate_index = candidate_index;
923 if (coincidences == candidate->args.size()) {
928 std::stringstream ss;
930 for (
size_t i = 0; i < fce.
args.size(); i++) {
932 if (i < fce.
args.size() - 1) {
936 ss <<
")'\033[31m does not have needed candidate.\nExists candidates:\n\033[0m";
938 for (
auto& candidate : func_candidates) {
940 for (
size_t i = 0; i < candidate->args.size(); i++) {
941 ss << candidate->args[i].type.to_str();
942 if (i < candidate->args.size() - 1) {
947 if (index < func_candidates.size() - 1) {
957 auto best_candidate = func_candidates[best_candidate_index];
958 for (
auto& arg : fce.
args) {
961 std::stringstream ss;
962 ss <<
"In the " << index + 1 <<
"th argument: Type mismatch: an expression of the type \033[0m'" << arg_type.
to_str() <<
"'\033[31m, but the type is expected \033[0m'" << best_candidate->args[index].type.to_str() <<
"'\033[31m";
972 for (
size_t i = 1; i < co.
chain.size(); i++) {
985 if (info ==
nullptr) {
986 std::stringstream ss;
987 ss <<
"Module \033[0m'" << target.
type.
name <<
"'\033[31m does not exists";
991 std::stringstream ss;
993 for (
size_t i = 0; i < fce->args.size(); i++) {
995 if (i < fce->args.size() - 1) {
999 ss <<
")'\033[31m does not exists in module \033[0m'" << target.
type.
name <<
"'\033[31m";
1003 std::stringstream ss;
1005 for (
size_t i = 0; i < fce->args.size(); i++) {
1007 if (i < fce->args.size() - 1) {
1011 ss <<
")'\033[31m in module \033[0m'" << target.
type.
name <<
"'\033[31m is private member";
1020 else if (
auto ve =
dynamic_cast<AST::VarExpr*
>(&obj)) {
1022 if (info ==
nullptr) {
1023 std::stringstream ss;
1024 ss <<
"Module \033[0m'" << target.
type.
name <<
"'\033[31m does not exists";
1029 std::stringstream ss;
1030 ss <<
"Module \033[0m'" << ve->name <<
"'\033[31m in module \033[0m'" << target.
type.
name <<
"'\033[31m is private member";
1033 target.
type.
name +=
"-" + ve->name;
1036 std::stringstream ss;
1037 ss <<
"Module \033[0m'" << ve->name <<
"'\033[31m does not exists in module \033[0m'" << target.
type.
name <<
"'\033[31m";
1041 std::stringstream ss;
1042 ss <<
"Module \033[0m'" << target.
type.
name <<
"'\033[31m does not have passed object type";
1050 for (
size_t i = 0; i < fce.
args.size(); i++) {
1055 variables.top().emplace(func->args[i].name, val);
1057 for (
auto& stmt : func->block) {
1068 if (val !=
nullptr) {
1076 if (val !=
nullptr) {
1084 if (val !=
nullptr) {
1092 if (val !=
nullptr) {
1099 if (!func->block.empty()) {
1100 std::stringstream ss;
1101 ss <<
"Not all paths returns value in function \033[0m'" << fce.
name <<
"'\033[31m. Please add \033[0m'return'\033[31m statement into the end of the function";
1104 return Value(func->ret_type, 0,
true,
false);
1160 for (
auto& stmt : wcs.
block) {
1192 for (
auto& stmt : dwcs.
block) {
1227 for (
auto& stmt : fcs.
block) {
1264 switch (type.
type) {
1280 std::stringstream ss;
1281 ss <<
"Cannot generate default value for \033[0m'" << type.
to_str() <<
"'\033[31m type";
1288 while (!vars.empty()) {
1289 auto vars_it = vars.top().find(name);
1290 if (vars_it != vars.top().end()) {
1291 return std::make_unique<Value>(vars_it->second);
1301 return func_it->second;
1307 if (left == right) {
1338 std::stringstream ss;
1339 ss <<
"Type mismatch: there is no common type for \033[0m'" << left.
to_str() <<
"'\033[31m and \033[0m'" << right.
to_str() <<
"'\033[31m";
1347 double val_from_variant = 0;
1350 val_from_variant = std::get<0>(val.
value.
value);
1353 val_from_variant = std::get<1>(val.
value.
value);
1356 val_from_variant = std::get<2>(val.
value.
value);
1359 val_from_variant = std::get<3>(val.
value.
value);
1362 val_from_variant = std::get<4>(val.
value.
value);
1365 val_from_variant = std::get<5>(val.
value.
value);
1368 val_from_variant = std::get<6>(val.
value.
value);
1371 switch (type.
type) {
1372 #define VALUE(type) static_cast<type>(val_from_variant)
1405 double left_val = 0;
1406 double right_val = 0;
1455 return left_val + right_val;
1457 return left_val - right_val;
1459 return left_val * right_val;
1464 return left_val / right_val;
1466 return std::fmod(left_val, right_val);
1468 return static_cast<bool>(left_val == right_val);
1470 return static_cast<bool>(left_val != right_val);
1472 return static_cast<bool>(left_val > right_val);
1474 return static_cast<bool>(left_val >= right_val);
1476 return static_cast<bool>(left_val < right_val);
1478 return static_cast<bool>(left_val <= right_val);
1480 return static_cast<bool>(left_val && right_val);
1482 return static_cast<bool>(left_val || right_val);
1484 std::stringstream ss;
1485 ss <<
"Unsupported binary operator: \033[0m'" << op <<
"'";
1525 return static_cast<bool>(!val);
1531 std::stringstream ss;
1532 ss <<
"Unsupported unary operator: \033[0m'" << op <<
"'";
1540 while (!path.empty()) {
1543 res = part.
name +
"-" + res;
1546 res = part.
name +
"#" + res;
1550 return res + base_name;
1554 std::vector<PathPart> res;
1556 for (
const char c : mangled_name) {
1561 else if (c ==
'#') {
Binary expression container.
Chain of objects expression container.
std::vector< ExprPtr > chain
Statement of do-while cycle.
std::vector< StmtPtr > block
Base class of expression.
Statement of extern calls.
std::vector< StmtPtr > block
std::string lang_name_lit
std::vector< StmtPtr > block
Function calling expression container.
std::vector< ExprPtr > args
Statement of functions calling.
std::vector< ExprPtr > args
Statement of functions declaration.
std::vector< StmtPtr > block
std::vector< Argument > args
Statement of control flow operator.
std::vector< StmtPtr > else_block
std::vector< StmtPtr > then_block
Statement of module definition.
std::vector< StmtPtr > block
Unary expression container.
Statement of import the module.
std::vector< std::string > path
Statement of assignment of variable.
Statement of variable declaration.
Variable expression container.
Statement of while cycle.
std::vector< StmtPtr > block
std::vector< Token > tokenize()
Method for tokenizing source code.
std::vector< AST::StmtPtr > parse()
Method for parsing tokens into AST tree.
Value * get_function_return_value_from_do_while_cycle(AST::DoWhileCycleStmt &dwcs)
Method for evaluating and returning function returned value from do-while cycle.
std::string get_mangled_name(std::string base_name)
Method for getting mangled name.
Value implicitly_cast(Value val, AST::Type type, uint32_t line)
Method for getting implicitly casted value between two values.
void analyze_break_stmt(AST::BreakStmt &bs)
Method for analyze break statement.
void analyze_return_stmt(AST::ReturnStmt &rs)
Method for analyze 'return' statement.
SemanticAnalyzer(std::vector< AST::StmtPtr > &s, std::string lp, std::string fn, bool id)
Value analyze_unary_expr(AST::UnaryExpr &ue)
Method for analyze unary expression.
std::map< AST::TypeValue, std::vector< AST::TypeValue > > implicitly_cast_allowed_types
void analyze()
Method for analyze all statements.
Value * get_function_return_value_from_for_cycle(AST::ForCycleStmt &fcs)
Method for evaluating and returning function returned value from for cycle.
AST::Value get_default_val_by_type(AST::Type type, uint32_t line)
Method for getting default value by type.
std::map< std::string, ModuleInfo * > modules
std::vector< AST::StmtPtr > & stmts
Value analyze_obj_chain_expr(AST::ChainObjects &co)
Method for analyze chain of objects expression.
void analyze_if_else_stmt(AST::IfElseStmt &ies)
Method for analyze control flow operators.
void analyze_func_decl_stmt(AST::FuncDeclStmt &fds)
Method for analyze function declaration.
void analyze_var_decl_stmt(AST::VarDeclStmt &vds, bool is_func_arg=false)
Method for analyze variable declaration.
std::vector< std::string > allowed_langs_for_extern
void analyze_var_asgn_stmt(AST::VarAsgnStmt &vas)
Method for analyze variable assignment.
void analyze_use_module_stmt(AST::UseModuleStmt &ums)
Method for analyze import the module.
std::unique_ptr< Value > get_variable_value(std::string name)
Method for getting value of variable from view scope of variables table.
std::map< std::string, ModuleInfo * > get_modules() const
Method for getting modules from semantic.
AST::Type get_common_type(AST::Type left, AST::Type right, uint32_t line)
Method for getting common type between two types.
void analyze_extern_stmt(AST::ExternStmt &es)
Method for analyze extern calls.
Value analyze_func_call_expr(AST::FuncCallExpr &fce)
Method for analyze function calling expression.
std::vector< std::shared_ptr< FunctionInfo > > get_function_candidates(std::string name)
Method for getting function candidates from functions table.
std::map< std::string, std::vector< std::shared_ptr< FunctionInfo > > > functions
Value analyze_expr(AST::Expr &expr)
Method for analyze expression.
bool has_common_type(AST::Type left, AST::Type right)
Method for determining whether two types have a common type.
void analyze_do_while_cycle_stmt(AST::DoWhileCycleStmt &dwcs)
Method for analyze do-while cycle.
void analyze_while_cycle_stmt(AST::WhileCycleStmt &wcs)
Method for analyze while cycle.
double binary_two_variants(Value left, Value right, TokenType op, uint32_t line)
Method for evaluating binary operations on two values from std::variant.
Value get_function_return_value(std::shared_ptr< FunctionInfo > func, AST::FuncCallExpr &fce)
Method for evaluating and returning function returned value.
std::stack< PathPart > current_path
void analyze_continue_stmt(AST::ContinueStmt &cs)
Method for analyze continue statement.
void analyze_stmt(AST::Stmt &stmt)
Method for analyze one statement.
Value analyze_literal_expr(AST::Literal &lit)
Method for analyze literal.
std::vector< std::string > names_of_imported_modules
void analyze_for_cycle_stmt(AST::ForCycleStmt &fcs)
Method for analyze for cycle.
Value * get_function_return_value_from_while_cycle(AST::WhileCycleStmt &wcs)
Method for evaluating and returning function returned value from while cycle.
Space
Current space (in global, in module or in function).
void analyze_module_stmt(AST::ModuleStmt &ms)
Method for analyze module definition.
std::map< std::string, std::vector< std::shared_ptr< FunctionInfo > > > get_functions() const
Method for getting functions from semantic.
enum SemanticAnalyzer::Space current_space
std::vector< PathPart > get_resolved_name(std::string mangled_name)
Method for getting resolved name by mangled name.
void analyze_func_call_stmt(AST::FuncCallStmt &fcs)
Method for analyze function calling.
Value analyze_obj_from_chain(Value target, AST::Expr &obj)
Method for analyze object from chain of objects expression.
std::stack< std::map< std::string, Value > > variables
Value * get_function_return_value_from_if_else(AST::IfElseStmt &ies)
Method for evaluating and returning function returned value from control flow operators.
double unary_two_variants(Value value, TokenType op, uint32_t line)
Method for evaluating unary operations on two values from std::variant.
Value analyze_binary_expr(AST::BinaryExpr &be)
Method for analyze binary expression.
Value analyze_var_expr(AST::VarExpr &ve)
Method for analyze variable expression.
std::stack< AST::Type > functions_ret_types
void throw_exception(SubsystemType type, std::string msg, uint32_t line, std::string file_name, bool is_debug)
Function for throwing exception.
Header file for defining thrown exceptions by the compiler.
Header file for defining the lexer.
std::unique_ptr< Stmt > StmtPtr
Header file for defining parser.
Header file for defining semantic analyzer.
Structure for describing the type.
std::string to_str()
Method for convert type to string.
Structure for describing the value.
std::variant< bool, char8_t, int16_t, int32_t, int64_t, float_t, double_t, std::string > value
Structure of information about module.
std::map< std::string, std::pair< AST::AccessModifier, ModuleInfo * > > modules
std::map< std::string, std::pair< AST::AccessModifier, std::string > > functions
Structure of part of path to object.
enum SemanticAnalyzer::PathPart::Object object
TokenType
All tokens types.