AALanguage
The best language for those who have nothing to do
Loading...
Searching...
No Matches
Semantic.h
Go to the documentation of this file.
1#pragma once
2
3#include <stack>
4#include "TableIdentifiers.h"
5#include "LexicalAnalyzer.h"
6
8class Semantic {
9public:
17 ExprType string_to_type(std::string str);
27 bool is_convertible(Type first, Type second, bool is_func = false);
36 Type calc_expr_type(Type first, Type second);
44 std::string type_to_string(Type type);
53 void add_identifier(Identifier* ident, bool is_global = false);
64 Identifier* get_identifier(std::string name);
68 void del_table();
74 void create_table(bool new_func = false);
87 void create_function(std::string name, Type type, int pref, std::vector<int> inits, std::vector<Identifier*> ptrs, int ptr);
98 Function get_function(std::string name, std::vector<Type> params);
107 void init_array(ExprType type, int size, void*& value, std::string name);
117 bool check_operation(Type f, Type s, std::string operation);
126 Type literal_to_type(LexicalAnalyzer& lex, Token current_token);
127
129 std::stack<std::pair<Type, bool>> exprs;
131 std::stack<int*> break_ptr;
133 std::stack<int*> continue_ptr;
135 std::vector<Identifier*> params_ptrs;
143 std::vector<int> function_params_init;
145 std::unordered_map<Function, TableIdentifiers*, FunctionHasher> funcs;
148private:
151};