parametrized_type, parametrized_typeclass, function argument, array type fixes

This commit is contained in:
ProgramSnail 2023-05-02 17:30:57 +03:00
parent 0dc8880c58
commit d13faf104d
9 changed files with 32 additions and 153 deletions

View file

@ -69,12 +69,12 @@ using ImportSymbol = AnyIdentifier; // can be extended name
struct FunctionDefinition;
struct TypeDefinition;
struct AnnotatedAbstractType;
struct AnyAnnotatedType;
// TypeIdentifier <-> AbstractTypeIdentifier <-> std::string
using AnnotatedType = AnnotatedAbstractType;
using AnnotatedType = AnyAnnotatedType;
using AnyAnnotatedType = AnnotatedType;
using AnnotatedAbstractType = AnyAnnotatedType;
// Flow control -----------------
@ -225,25 +225,19 @@ struct ExtendedScopedAnyType;
// Typeclass
struct ParametrizedTypeclass;
struct TypeclassExpression;
using TypeclassSubExpression = std::variant<
std::unique_ptr<TypeclassIdentifier>,
std::unique_ptr<ParametrizedTypeclass>>;
// TypeclassSubExpression -> ParametrizedTypeclass
// Typeclass & Type
struct ParametrizedType;
using TypeSubExpression = std::variant<
std::unique_ptr<AnyTypeIdentifier>,
std::unique_ptr<ParametrizedType>>;
// TypeSubExpression -> ParametrizedType
//
using FunctionArgument = std::variant<
SubExpressionToken,
TypeSubExpression>;
std::unique_ptr<TypeExpression>>;
// Comments [IGNORE] -----------------
// Identifiers, constants, etc. -----------------
@ -377,9 +371,9 @@ struct TypeDefinition {
std::vector<std::unique_ptr<AnnotatedAbstractType>> parameters;
};
struct AnnotatedAbstractType {
AbstractTypeIdentifier type;
std::vector<std::unique_ptr<TypeclassExpression>> typeclasses;
struct AnyAnnotatedType {
AnyTypeIdentifier type;
std::vector<std::unique_ptr<ParametrizedTypeclass>> typeclasses;
};
// ----------------- Flow control -----------------
@ -552,9 +546,16 @@ struct VariantType {
std::vector<std::variant<Constructor, std::unique_ptr<TupleType>>> constructors;
};
struct ParametrizedType {
AnyTypeIdentifier type;
std::vector<std::unique_ptr<TypeExpression>> parameters;
std::optional<utils::IdType> type_id_; // std::nullopt, if it is namespace without type
};
struct TypeExpression {
std::vector<TypeSubExpression> path;
TypeSubExpression type;
std::vector<ParametrizedType> path;
ParametrizedType type;
std::optional<size_t> array_size; // if array; 0 - dynamic size
@ -569,24 +570,11 @@ struct ExtendedScopedAnyType {
// Typeclass -----------------
struct TypeclassExpression {
TypeclassSubExpression typeclass;
utils::IdType typeclass_id_;
};
struct ParametrizedTypeclass {
TypeclassIdentifier typeclass;
std::vector<std::unique_ptr<TypeExpression>> parameters;
};
// Typeclass & Type -----------------
struct ParametrizedType {
AnyTypeIdentifier type;
TypeclassIdentifier typeclass;
std::vector<std::unique_ptr<TypeExpression>> parameters;
std::optional<utils::IdType> type_id_; // std::nullopt, if it is namespace without type
utils::IdType typeclass_id_;
};
// ----------------- Comments [IGNORE] -----------------