grammar refactoring: printer_visitor fixed

This commit is contained in:
ProgramSnail 2023-04-09 16:01:07 +03:00
parent 77c7ac0b2f
commit 2d2bb9ec65
3 changed files with 344 additions and 317 deletions

View file

@ -255,7 +255,7 @@ struct Sources {
// ----------------- Namespaces, partittions -----------------
struct Namespace {
bool is_const;
enum { Const, Var } modifier;
std::optional<ExtendedName> name;
TypeIdentifier type;
std::unique_ptr<Sources> scope;
@ -284,6 +284,7 @@ struct ImportStatement {
};
struct AliasDefinitionStatement {
enum {Alias, Type, Let} modifier;
TypeIdentifier type;
std::vector<AbstractTypeIdentifier> parameters;
std::unique_ptr<ParametrizedType> value;
@ -338,7 +339,7 @@ struct TypeDefinition {
struct DefinitionParameter {
AbstractTypeIdentifier type;
std::vector<std::unique_ptr<TypeclassUsage>> typeclasses;
std::vector<TypeclassUsage> typeclasses;
};
// ----------------- Flow control -----------------
@ -410,10 +411,10 @@ struct UnaryOperatorExpression {
struct ReferenceExpression {
std::vector<ReferenceType> references;
ScopedStatement expression;
std::unique_ptr<ScopedStatement> expression;
};
// Simple Expressions -----------------
// Other Expressions -----------------
struct FunctionCallExpression {
std::unique_ptr<NameExpression> name;
@ -455,19 +456,19 @@ struct NameExpression {
};
struct TupleName {
std::vector<std::unique_ptr<ScopedAnyName>> names;
std::vector<ScopedAnyName> names;
};
struct VariantName {
std::vector<std::unique_ptr<ScopedAnyName>> names;
std::vector<ScopedAnyName> names;
};
struct AnnotatedName {
NameIdentifier name;
std::optional<std::unique_ptr<ScopedAnyType>> type;
std::optional<ScopedAnyType> type;
};
// TODO ?? mark all optional fields ??
// ----------------- Type, typeclass, etc. -----------------
// Type -----------------
@ -477,7 +478,7 @@ struct FunctionType {
struct TupleType {
std::optional<Constructor> type;
std::vector<std::pair<std::optional<ExtendedName>, ExtendedScopedAnyType>> entities;
std::vector<std::pair<std::optional<ExtendedName>, std::unique_ptr<ExtendedScopedAnyType>>> entities;
};
struct VariantType {
@ -487,7 +488,7 @@ struct VariantType {
struct AnnotatedType {
std::unique_ptr<TypeExpression> type_expression;
std::vector<std::unique_ptr<TypeclassUsage>> annotations;
std::vector<TypeclassUsage> annotations;
};
struct ParametrizedType {