mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-25 13:07:13 +00:00
parametrized_type, parametrized_typeclass, function argument, array type fixes
This commit is contained in:
parent
0dc8880c58
commit
d13faf104d
9 changed files with 32 additions and 153 deletions
|
|
@ -126,17 +126,12 @@ private:
|
|||
|
||||
// Typeclass
|
||||
|
||||
void Visit(TypeclassExpression* node) override;
|
||||
void Visit(ParametrizedTypeclass* node) override;
|
||||
|
||||
void Visit(TypeclassSubExpression& node) override; // variant
|
||||
|
||||
// Typeclass & Type
|
||||
|
||||
void Visit(ParametrizedType* node) override;
|
||||
|
||||
void Visit(TypeSubExpression& node) override; // variant
|
||||
|
||||
// Identifiers, constants, etc. -----------------
|
||||
|
||||
void Visit(ExtendedName* node) override;
|
||||
|
|
|
|||
|
|
@ -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] -----------------
|
||||
|
|
|
|||
|
|
@ -107,18 +107,13 @@ const std::string ExtendedScopedAnyType = "extended_scoped_any_type";
|
|||
|
||||
// Typeclass
|
||||
|
||||
const std::string TypeclassExpression = "typeclass_expression";
|
||||
const std::string ParametrizedTypeclass = "parametrized_typeclass";
|
||||
|
||||
const std::string TypeclassSubExpression = "typeclass_subexpression";
|
||||
|
||||
|
||||
// Typeclass & Type
|
||||
|
||||
const std::string ParametrizedType = "parametrized_type";
|
||||
|
||||
const std::string TypeSubExpression = "type_subexpression";
|
||||
|
||||
// Identifiers, constants, etc. -----------------
|
||||
|
||||
const std::string ExtendedName = "extended_name";
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ private:
|
|||
|
||||
// Typeclass
|
||||
|
||||
void Visit(TypeclassExpression* node) override;
|
||||
void Visit(ParametrizedTypeclass* node) override;
|
||||
|
||||
// Typeclass & Type
|
||||
|
|
|
|||
|
|
@ -123,17 +123,12 @@ protected:
|
|||
|
||||
// Typeclass
|
||||
|
||||
virtual void Visit(TypeclassExpression* node);
|
||||
virtual void Visit(ParametrizedTypeclass* node);
|
||||
|
||||
virtual void Visit(TypeclassSubExpression& node); // variant
|
||||
|
||||
// Typeclass & Type
|
||||
|
||||
virtual void Visit(ParametrizedType* node);
|
||||
|
||||
virtual void Visit(TypeSubExpression& node); // variant
|
||||
|
||||
// Identifiers, constants, etc. -----------------
|
||||
|
||||
virtual void Visit(ExtendedName* node);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue