mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-09 16:38:45 +00:00
going to fix grammar
This commit is contained in:
parent
656f58bcde
commit
1289dda838
2 changed files with 28 additions and 9 deletions
|
|
@ -79,7 +79,13 @@ struct AnyTypeInfo {
|
|||
interpreter::tokens::AnyType* value;
|
||||
};
|
||||
|
||||
struct TypeInfo { std::variant<AbstractTypeInfo, AliasTypeInfo, AnyTypeInfo> type; };
|
||||
struct TypeInfo { std::variant<AbstractTypeInfo, AliasTypeInfo, AnyTypeInfo> type; };
|
||||
|
||||
struct ConstructorInfo {
|
||||
std::string name;
|
||||
size_t order;
|
||||
utils::IdType type_id;
|
||||
};
|
||||
|
||||
struct FunctionDeclarationInfo {
|
||||
std::vector<ParameterInfo> parameters;
|
||||
|
|
|
|||
|
|
@ -392,18 +392,28 @@ void TypeCheckVisitor::Visit(FunctionCallExpression* node) {
|
|||
|
||||
info::type::FunctionType type_value = std::get<info::type::FunctionType>(context_manager_.GetType(current_type_));
|
||||
|
||||
if (type_value.argument_types.size() != node->arguments.size()) {
|
||||
error_handling::HandleTypecheckError("Mismatched argument count in function call expression");
|
||||
}
|
||||
size_t argument_num = 0;
|
||||
size_t paramater_num = 0;
|
||||
|
||||
for (size_t i = 0; i < node->arguments.size(); ++i) {
|
||||
Visitor::Visit(node->arguments[i]);
|
||||
if (std::holds_alternative<std::string>(node->arguments[i])) {
|
||||
} else if (std::holds_alternative<info::type::TupleType>(node->arguments[i])) {
|
||||
if (std::holds_alternative<TypeSubExpression>(node->arguments[i])) {
|
||||
// TODO
|
||||
++paramater_num;
|
||||
} else if (std::holds_alternative<SubExpressionToken>(node->arguments[i])) {
|
||||
if (type_value.argument_types.size() <= argument_num) {
|
||||
error_handling::HandleTypecheckError("Mismatched argument count in function call expression");
|
||||
}
|
||||
|
||||
context_manager_.AddTypeRequirement(current_type_, type_value.argument_types[argument_num]);
|
||||
++argument_num;
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
context_manager_.AddTypeRequirement(current_type_, type_value.argument_types[i]);
|
||||
}
|
||||
|
||||
if (type_value.argument_types.size() != argument_num) {
|
||||
error_handling::HandleTypecheckError("Mismatched argument count in function call expression");
|
||||
}
|
||||
|
||||
current_type_ = type_value.return_type;
|
||||
|
|
@ -581,9 +591,12 @@ void TypeCheckVisitor::Visit(VariantName* node) {
|
|||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(AnnotatedName* node) {
|
||||
context_manager_.DefineVariable(node->name, current_type_);
|
||||
utils::IdType type = current_type_;
|
||||
|
||||
context_manager_.DefineVariable(node->name, type);
|
||||
if (node->type.has_value()) {
|
||||
// TODO: ?? check, that types are equal, add type requirement ??
|
||||
Visitor::Visit(node->type.value());
|
||||
context_manager_.EqualTypes(type, current_type_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue