Skip to content

Commit

Permalink
[fix] exit(1), funcDecl
Browse files Browse the repository at this point in the history
  • Loading branch information
IVIosab committed Apr 30, 2023
1 parent 0c72e48 commit 00a82be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion semantic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace analyzer
node->returnType = ret_type;
routineDeclTable[node->name] = node;
if (routine_return_type && ret_type)
typecheck_types(routine_return_type, ret_type);
typecheck_types(ret_type, routine_return_type);

remove_params_from_scope();
};
Expand Down
8 changes: 4 additions & 4 deletions semantic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ namespace analyzer
ast::Type* current_var_type = nullptr;
void err_second_declaration(std::string name){
std::cout << "Error: second declaration of " << name << " is invalid.\n";
exit(0);
exit(1);
}
void err_undefined_obj(std::string obj)
{
std::cout << "Error: Undefined object: " << obj << '\n';
exit(0);
exit(1);
}

void err_expected_got(std::string expected, std::string got)
{
std::cout << "Error: Expected:\n" << expected << ",\ngot: \n" << got << '\n';
exit(0);
exit(1);
}
void err_wrong_params_number(int expected, int got){
std::cout << "Error: Expected number of params: " << expected << " got: " << got << '\n';
exit(0);
exit(1);
}
void warn_shadow(std::string obj)
{
Expand Down
20 changes: 7 additions & 13 deletions test.crbc
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
routine main () : integer is
var x : record
var a : integer is 5;
var b : integer is 3;
routine main() : integer is
var x : integer is 5;
var y : integer is 3;
var z : record
var x : boolean is false;
var y : integer is 1;
end;
var y : record
var b : integer is 0;
var a : integer is 4;
end;
x := y;
print(x.a);
print(x.b);

return 0;
return z.x;
end

0 comments on commit 00a82be

Please sign in to comment.