Detect alias cycles

This commit is contained in:
2025-06-21 22:32:34 +02:00
parent 67a8d2c057
commit a187e5e62a
10 changed files with 84 additions and 66 deletions

View File

@ -659,10 +659,9 @@ namespace elna::boot
public:
const std::vector<conditional_statements *> branches;
const std::vector<statement *> *alternative;
while_statement(const struct position position, conditional_statements *body,
std::vector<conditional_statements *>&& branches, std::vector<statement *> *alternative = nullptr);
std::vector<conditional_statements *>&& branches);
void accept(parser_visitor *visitor) override;
conditional_statements& body();

View File

@ -53,7 +53,7 @@ namespace elna::boot
const std::string field_name;
public:
field_duplication_error(const std::string& field_name, const char *path, const struct position);
field_duplication_error(const std::string& field_name, const char *path, const struct position position);
std::string what() const override;
};
@ -63,7 +63,8 @@ namespace elna::boot
const std::vector<std::string> cycle;
public:
cyclic_declaration_error(const std::vector<std::string>& cycle, const char *path, const struct position);
cyclic_declaration_error(const std::vector<std::string>& cycle,
const char *path, const struct position position);
std::string what() const override;
};
@ -82,6 +83,9 @@ namespace elna::boot
procedure_type build_procedure(procedure_type_expression& type_expression);
std::vector<type_field> build_composite_type(const std::vector<field_declaration>& fields);
bool check_unresolved_symbol(std::shared_ptr<alias_type> alias,
std::vector<std::string>& path);
public:
explicit name_analysis_visitor(const char *path, std::shared_ptr<symbol_table> symbols,
std::unordered_map<std::string, std::shared_ptr<alias_type>>&& unresolved);

View File

@ -30,11 +30,10 @@ namespace elna::gcc
void init_ttree();
std::shared_ptr<symbol_table> builtin_symbol_table();
void do_semantic_analysis(std::shared_ptr<boot::symbol_table> info_table, std::shared_ptr<symbol_table> symbols);
void rewrite_symbol_table(std::shared_ptr<boot::symbol_table> info_table, std::shared_ptr<symbol_table> symbols);
tree handle_symbol(const std::string& symbol_name, std::shared_ptr<boot::alias_type> reference,
std::shared_ptr<symbol_table> symbols, std::vector<std::string>& path);
tree get_inner_alias(const boot::type& type, std::shared_ptr<symbol_table> symbols,
std::vector<std::string>& path);
std::shared_ptr<symbol_table> symbols);
tree get_inner_alias(const boot::type& type, std::shared_ptr<symbol_table> symbols);
void declare_procedure(const std::string& name, const boot::procedure_info& info,
std::shared_ptr<symbol_table> symbols);
}