mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-06 06:58:45 +00:00
partition syntax changed, interface modifier added
This commit is contained in:
parent
3fca384446
commit
b1aff1935d
22 changed files with 299 additions and 266 deletions
|
|
@ -23,8 +23,6 @@ private:
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void Visit(PartitionSources* node) override;
|
||||
void Visit(Partition* node) override;
|
||||
void Visit(NamespaceSources* node) override;
|
||||
void Visit(Namespace* node) override;
|
||||
|
||||
|
|
@ -38,9 +36,9 @@ private:
|
|||
void Visit(TypeDefinitionStatement* node) override;
|
||||
void Visit(AbstractTypeDefinitionStatement* node) override;
|
||||
void Visit(TypeclassDefinitionStatement* node) override;
|
||||
void Visit(PartitionStatement* node) override;
|
||||
|
||||
void Visit(NamespaceStatement& node) override; // variant
|
||||
void Visit(PartitionStatement& node) override; // variant
|
||||
void Visit(SourceStatement& node) override; // variant
|
||||
|
||||
// Definition parts
|
||||
|
|
@ -101,6 +99,7 @@ private:
|
|||
|
||||
// Name
|
||||
|
||||
void Visit(PartitionName* node) override;
|
||||
void Visit(NameExpression* node) override;
|
||||
void Visit(TupleName* node) override;
|
||||
void Visit(VariantName* node) override;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ private:
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void Visit(PartitionSources* node) override;
|
||||
void Visit(Partition* node) override;
|
||||
void Visit(NamespaceSources* node) override;
|
||||
void Visit(Namespace* node) override;
|
||||
|
||||
|
|
@ -41,6 +39,8 @@ private:
|
|||
void Visit(TypeDefinitionStatement* node) override;
|
||||
void Visit(AbstractTypeDefinitionStatement* node) override;
|
||||
void Visit(TypeclassDefinitionStatement* node) override;
|
||||
void Visit(ExecutableStatement* node) override;
|
||||
void Visit(TestStatement* node) override;
|
||||
|
||||
// Definition parts
|
||||
|
||||
|
|
@ -89,6 +89,7 @@ private:
|
|||
|
||||
// Name
|
||||
|
||||
void Visit(PartitionName* node) override;
|
||||
void Visit(NameExpression* node) override;
|
||||
void Visit(TupleName* node) override;
|
||||
void Visit(VariantName* node) override;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ private:
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
// void Visit(PartitionSources* node) override; // default
|
||||
void Visit(Partition* node) override;
|
||||
// void Visit(NamespaceSources* node) override; // default
|
||||
void Visit(Namespace* node) override;
|
||||
|
||||
|
|
@ -36,6 +34,7 @@ private:
|
|||
void Visit(TypeDefinitionStatement* node) override;
|
||||
void Visit(AbstractTypeDefinitionStatement* node) override;
|
||||
void Visit(TypeclassDefinitionStatement* node) override;
|
||||
void Visit(PartitionStatement* node) override;
|
||||
|
||||
// Definition parts
|
||||
|
||||
|
|
@ -84,6 +83,7 @@ private:
|
|||
|
||||
// Name
|
||||
|
||||
// // void Visit(PartitionName* node) override;
|
||||
// // void Visit(NameExpression* node) override;
|
||||
// // void Visit(TupleName* node) override;
|
||||
// // void Visit(VariantName* node) override;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <asm-generic/errno.h>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
|
@ -11,14 +12,22 @@
|
|||
|
||||
namespace info {
|
||||
|
||||
// TODO: partitions
|
||||
// TODO: better test / executable partitions support (tree, etc.)
|
||||
// TODO: add classes / structs and functions module interface
|
||||
class GlobalInfo {
|
||||
friend class NamespaceVisitor;
|
||||
public:
|
||||
struct PartitionInfo {
|
||||
std::vector<std::string> path;
|
||||
std::string name;
|
||||
interpreter::tokens::PartitionStatement* node = nullptr;
|
||||
};
|
||||
|
||||
class NamespaceVisitor {
|
||||
friend GlobalInfo;
|
||||
NamespaceVisitor() = delete;
|
||||
public:
|
||||
|
||||
struct Path {
|
||||
std::vector<std::optional<utils::IdType>> path_types;
|
||||
definition::Namespace* result;
|
||||
|
|
@ -57,6 +66,10 @@ public:
|
|||
definition::Constructor&& constructor_info,
|
||||
const interpreter::tokens::BaseNode& base_node);
|
||||
|
||||
utils::IdType AddPartition(const std::vector<std::string>& path,
|
||||
const std::string& name,
|
||||
interpreter::tokens::PartitionStatement* node);
|
||||
|
||||
std::optional<definition::Namespace*> FindNamespace(const std::optional<std::vector<std::string>>& path);
|
||||
|
||||
std::optional<utils::IdType> FindFunction(const std::optional<std::vector<std::string>>& path,
|
||||
|
|
@ -145,6 +158,11 @@ public:
|
|||
return constructors_.at(id);
|
||||
}
|
||||
|
||||
// remember about vector realloc
|
||||
const PartitionInfo& GetPartitionInfo(utils::IdType id) {
|
||||
return partitions_.at(id);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::vector<definition::Function> functions_;
|
||||
|
|
@ -156,6 +174,8 @@ private:
|
|||
std::unordered_map<std::string, utils::IdType> name_to_typeclass_;
|
||||
std::unordered_map<std::string, utils::IdType> name_to_abstract_type_;
|
||||
|
||||
std::vector<PartitionInfo> partitions_;
|
||||
|
||||
definition::Namespace global_namespace_;
|
||||
std::vector<definition::Import> imports_;
|
||||
std::unordered_map<std::string, definition::Import> usages_;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ struct SourceFile;
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
struct Partition;
|
||||
struct PartitionSources;
|
||||
struct Namespace;
|
||||
struct NamespaceSources;
|
||||
|
||||
|
|
@ -50,6 +48,7 @@ struct FunctionDefinitionStatement;
|
|||
struct TypeDefinitionStatement;
|
||||
struct AbstractTypeDefinitionStatement;
|
||||
struct TypeclassDefinitionStatement;
|
||||
struct PartitionStatement;
|
||||
|
||||
//
|
||||
using NamespaceStatement = std::variant<
|
||||
|
|
@ -57,17 +56,14 @@ using NamespaceStatement = std::variant<
|
|||
std::unique_ptr<FunctionDeclaration>,
|
||||
std::unique_ptr<FunctionDefinitionStatement>,
|
||||
std::unique_ptr<TypeDefinitionStatement>,
|
||||
std::unique_ptr<PartitionStatement>,
|
||||
std::unique_ptr<Namespace>>;
|
||||
//
|
||||
using PartitionStatement = std::variant<
|
||||
std::unique_ptr<AbstractTypeDefinitionStatement>,
|
||||
std::unique_ptr<TypeclassDefinitionStatement>,
|
||||
std::unique_ptr<NamespaceStatement>>;
|
||||
//
|
||||
using SourceStatement = std::variant<
|
||||
std::unique_ptr<ImportStatement>,
|
||||
std::unique_ptr<Partition>,
|
||||
std::unique_ptr<PartitionStatement>>;
|
||||
std::unique_ptr<AbstractTypeDefinitionStatement>,
|
||||
std::unique_ptr<TypeclassDefinitionStatement>,
|
||||
std::unique_ptr<NamespaceStatement>>;
|
||||
//
|
||||
|
||||
// Definition parts
|
||||
|
|
@ -193,6 +189,13 @@ struct ArrayExpression;
|
|||
|
||||
// Name
|
||||
|
||||
struct PartitionName {
|
||||
BaseNode base;
|
||||
|
||||
std::vector<TypeIdentifier> path;
|
||||
NameIdentifier name;
|
||||
};
|
||||
|
||||
struct NameExpression;
|
||||
struct TupleName;
|
||||
struct VariantName;
|
||||
|
|
@ -268,25 +271,6 @@ struct SourceFile {
|
|||
|
||||
// ----------------- Namespaces, partittions -----------------
|
||||
|
||||
struct PartitionSources {
|
||||
BaseNode base;
|
||||
|
||||
std::vector<PartitionStatement> statements;
|
||||
};
|
||||
|
||||
struct Partition {
|
||||
BaseNode base;
|
||||
|
||||
enum PartitionName {
|
||||
Test,
|
||||
Interface,
|
||||
Code,
|
||||
};
|
||||
|
||||
PartitionName name;
|
||||
PartitionSources scope;
|
||||
};
|
||||
|
||||
struct NamespaceSources {
|
||||
BaseNode base;
|
||||
|
||||
|
|
@ -337,6 +321,7 @@ struct VariableDefinitionStatement {
|
|||
struct FunctionDeclaration {
|
||||
BaseNode base;
|
||||
|
||||
bool is_in_interface = false;
|
||||
ExtendedName name;
|
||||
std::vector<std::unique_ptr<AnnotatedAbstractType>> parameters;
|
||||
std::unique_ptr<FunctionType> type;
|
||||
|
|
@ -347,7 +332,6 @@ struct FunctionDeclaration {
|
|||
struct FunctionDefinitionStatement {
|
||||
BaseNode base;
|
||||
|
||||
bool is_inline;
|
||||
std::unique_ptr<FunctionDefinition> definition;
|
||||
SuperExpression value;
|
||||
|
||||
|
|
@ -357,6 +341,7 @@ struct FunctionDefinitionStatement {
|
|||
struct TypeDefinitionStatement {
|
||||
BaseNode base;
|
||||
|
||||
bool is_in_interface = false;
|
||||
utils::ClassModifier modifier;
|
||||
std::unique_ptr<TypeDefinition> definition;
|
||||
AnyType value;
|
||||
|
|
@ -383,6 +368,16 @@ struct TypeclassDefinitionStatement {
|
|||
utils::IdType typeclass_id_;
|
||||
};
|
||||
|
||||
struct PartitionStatement {
|
||||
BaseNode base;
|
||||
|
||||
utils::PartitionModifier modifier;
|
||||
PartitionName name;
|
||||
SuperExpression value;
|
||||
|
||||
utils::IdType executable_id_;
|
||||
};
|
||||
|
||||
// Definition parts -----------------
|
||||
|
||||
struct FunctionDefinition {
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ private:
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
// // void Visit(PartitionSources* node) override;
|
||||
// // void Visit(Partition* node) override;
|
||||
// // void Visit(NamespaceSources* node) override;
|
||||
void Visit(Namespace* node) override;
|
||||
|
||||
|
|
@ -36,6 +34,7 @@ private:
|
|||
// // void Visit(TypeDefinitionStatement* node) override;
|
||||
// // void Visit(AbstractTypeDefinitionStatement* node) override;
|
||||
// // void Visit(TypeclassDefinitionStatement* node) override;
|
||||
// // void Visit(PartitionStatement* node) override;
|
||||
|
||||
// Definition parts
|
||||
|
||||
|
|
@ -83,6 +82,7 @@ private:
|
|||
|
||||
// Name
|
||||
|
||||
// // void Visit(PartitionName* node) override;
|
||||
// // void Visit(NameExpression* node) override;
|
||||
// // void Visit(TupleName* node) override;
|
||||
// // void Visit(VariantName* node) override;
|
||||
|
|
|
|||
|
|
@ -8,16 +8,12 @@ namespace parser::tokens {
|
|||
|
||||
const std::string SourceFile = "source_file";
|
||||
const std::string SourceStatement = "source_statement";
|
||||
const std::string PartitionSources = "partition_sources";
|
||||
const std::string PartitionStatement = "partition_statement";
|
||||
const std::string NamespaceSources = "namespace_sources";
|
||||
const std::string NamespaceStatement = "namespace_statement";
|
||||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
const std::string Namespace = "namespace";
|
||||
const std::string Partition = "partition";
|
||||
const std::string PartitionName = "partition_name";
|
||||
|
||||
// Definitions -----------------
|
||||
|
||||
|
|
@ -29,6 +25,7 @@ const std::string FunctionDefinitionStatement = "function_definition_statement";
|
|||
const std::string TypeDefinitionStatement = "type_definition_statement";
|
||||
const std::string AbstractTypeDefinitionStatement = "abstract_type_definition_statement";
|
||||
const std::string TypeclassDefinitionStatement = "typeclass_definition_statement";
|
||||
const std::string PartitionStatement = "partition_statement";
|
||||
|
||||
// Definition parts
|
||||
|
||||
|
|
@ -86,6 +83,7 @@ const std::string LoopControlExpression = "loop_control_expression";
|
|||
|
||||
// Name
|
||||
|
||||
const std::string PartitionName = "partition_name";
|
||||
const std::string NameExpression = "name_expression";
|
||||
const std::string TupleName = "tuple_name";
|
||||
const std::string VariantName = "variant_name";
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <ostream>
|
||||
|
||||
// for clangd
|
||||
#include "interpreter_tree.hpp"
|
||||
#include "visitor.hpp"
|
||||
|
||||
namespace interpreter {
|
||||
|
|
@ -18,8 +19,6 @@ private:
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void Visit(PartitionSources* node) override;
|
||||
void Visit(Partition* node) override;
|
||||
void Visit(NamespaceSources* node) override;
|
||||
void Visit(Namespace* node) override;
|
||||
|
||||
|
|
@ -33,6 +32,8 @@ private:
|
|||
void Visit(TypeDefinitionStatement* node) override;
|
||||
void Visit(AbstractTypeDefinitionStatement* node) override;
|
||||
void Visit(TypeclassDefinitionStatement* node) override;
|
||||
void Visit(PartitionStatement* node) override;
|
||||
|
||||
|
||||
// Definition parts
|
||||
|
||||
|
|
@ -81,6 +82,7 @@ private:
|
|||
|
||||
// Name
|
||||
|
||||
void Visit(PartitionName* node) override;
|
||||
void Visit(NameExpression* node) override;
|
||||
void Visit(TupleName* node) override;
|
||||
void Visit(VariantName* node) override;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ private:
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void Visit(PartitionSources* node) override;
|
||||
void Visit(Partition* node) override;
|
||||
void Visit(NamespaceSources* node) override;
|
||||
void Visit(Namespace* node) override;
|
||||
|
||||
|
|
@ -39,6 +37,7 @@ private:
|
|||
void Visit(TypeDefinitionStatement* node) override;
|
||||
void Visit(AbstractTypeDefinitionStatement* node) override;
|
||||
void Visit(TypeclassDefinitionStatement* node) override;
|
||||
void Visit(PartitionStatement* node) override;
|
||||
|
||||
// Definition parts
|
||||
|
||||
|
|
@ -87,6 +86,7 @@ private:
|
|||
|
||||
// Name
|
||||
|
||||
void Visit(PartitionName* node) override;
|
||||
void Visit(NameExpression* node) override;
|
||||
void Visit(TupleName* node) override;
|
||||
void Visit(VariantName* node) override;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ private:
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void Visit(PartitionSources* node) override;
|
||||
void Visit(Partition* node) override;
|
||||
void Visit(NamespaceSources* node) override;
|
||||
void Visit(Namespace* node) override;
|
||||
|
||||
|
|
@ -36,6 +34,7 @@ private:
|
|||
void Visit(TypeDefinitionStatement* node) override;
|
||||
void Visit(AbstractTypeDefinitionStatement* node) override;
|
||||
void Visit(TypeclassDefinitionStatement* node) override;
|
||||
void Visit(PartitionStatement* node) override;
|
||||
|
||||
// Definition parts
|
||||
|
||||
|
|
@ -84,6 +83,7 @@ private:
|
|||
|
||||
// Name
|
||||
|
||||
void Visit(PartitionName* node) override;
|
||||
void Visit(NameExpression* node) override;
|
||||
void Visit(TupleName* node) override;
|
||||
void Visit(VariantName* node) override;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ enum class AssignmentModifier { Assign = 0, Move = 1 };
|
|||
enum class AliasModifier { Alias = 0, Type = 1, Let = 2 };
|
||||
enum class AbstractTypeModifier { Basic = 0, Abstract = 1 };
|
||||
enum class FunctionTypeModifier { Function = 0, Operator = 1 };
|
||||
enum class PartitionModifier { Exec = 0, Test = 1 };
|
||||
|
||||
enum class ValueType { Const = 0, Var = 1, Tmp = 2 };
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ protected:
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
virtual void Visit(PartitionSources* node);
|
||||
virtual void Visit(Partition* node);
|
||||
virtual void Visit(NamespaceSources* node);
|
||||
virtual void Visit(Namespace* node);
|
||||
|
||||
|
|
@ -35,9 +33,9 @@ protected:
|
|||
virtual void Visit(TypeDefinitionStatement* node);
|
||||
virtual void Visit(AbstractTypeDefinitionStatement* node);
|
||||
virtual void Visit(TypeclassDefinitionStatement* node);
|
||||
virtual void Visit(PartitionStatement* node);
|
||||
|
||||
virtual void Visit(NamespaceStatement& node); // variant
|
||||
virtual void Visit(PartitionStatement& node); // variant
|
||||
virtual void Visit(SourceStatement& node); // variant
|
||||
|
||||
// Definition parts
|
||||
|
|
@ -98,6 +96,7 @@ protected:
|
|||
|
||||
// Name
|
||||
|
||||
virtual void Visit(PartitionName* node);
|
||||
virtual void Visit(NameExpression* node);
|
||||
virtual void Visit(TupleName* node);
|
||||
virtual void Visit(VariantName* node);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 60a270ed79f866baae441b823f241cbc032999da
|
||||
Subproject commit 0d034ea18377d25429fe04e768458df2cc00586a
|
||||
|
|
@ -32,43 +32,6 @@ void BuildVisitor::Visit(SourceFile* node) {
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void BuildVisitor::Visit(PartitionSources* node) {
|
||||
SetPosition(node->base, current_node_);
|
||||
|
||||
auto parse_node = current_node_;
|
||||
size_t statement_count = parse_node.NamedChildCount();
|
||||
|
||||
node->statements.resize(statement_count);
|
||||
|
||||
for (size_t i = 0; i < statement_count; ++i) {
|
||||
current_node_ = parse_node.NthNamedChild(i);
|
||||
Visit(node->statements[i]);
|
||||
}
|
||||
|
||||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(Partition* node) {
|
||||
SetPosition(node->base, current_node_);
|
||||
|
||||
auto parse_node = current_node_;
|
||||
|
||||
std::string name = parse_node.ChildByFieldName("name").GetValue();
|
||||
|
||||
if (name == "TEST") {
|
||||
node->name = Partition::Test;
|
||||
} else if (name == "INTERFACE") {
|
||||
node->name = Partition::Interface;
|
||||
} else if (name == "CODE") {
|
||||
node->name = Partition::Code;
|
||||
}
|
||||
|
||||
current_node_ = parse_node.ChildByFieldName("scope");
|
||||
Visit(&node->scope);
|
||||
|
||||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(NamespaceSources* node) {
|
||||
SetPosition(node->base, current_node_);
|
||||
|
||||
|
|
@ -208,6 +171,13 @@ void BuildVisitor::Visit(FunctionDeclaration* node) {
|
|||
|
||||
auto parse_node = current_node_;
|
||||
|
||||
// ['decl'] ['interface'] name
|
||||
if (parse_node.NthChild(0).GetValue() == "decl") {
|
||||
node->is_in_interface = (parse_node.NthChild(1).GetValue() == "interface");
|
||||
} else {
|
||||
node->is_in_interface = false;
|
||||
}
|
||||
|
||||
node->name.name = parse_node.ChildByFieldName("name").GetValue();
|
||||
|
||||
size_t child_count = parse_node.NamedChildCount();
|
||||
|
|
@ -233,8 +203,6 @@ void BuildVisitor::Visit(FunctionDefinitionStatement* node) {
|
|||
|
||||
auto parse_node = current_node_;
|
||||
|
||||
node->is_inline = (parse_node.NthChild(1).GetValue() == "inline");
|
||||
|
||||
current_node_ = parse_node.ChildByFieldName("definition");
|
||||
node->definition = std::make_unique<FunctionDefinition>();
|
||||
Visit(node->definition.get());
|
||||
|
|
@ -257,6 +225,8 @@ void BuildVisitor::Visit(TypeDefinitionStatement* node) {
|
|||
node->modifier = utils::ClassModifier::Struct;
|
||||
}
|
||||
|
||||
node->is_in_interface = (parse_node.NthChild(1).GetValue() == "interface");
|
||||
|
||||
current_node_ = parse_node.ChildByFieldName("definition");
|
||||
node->definition = std::make_unique<TypeDefinition>();
|
||||
Visit(node->definition.get());
|
||||
|
|
@ -310,6 +280,30 @@ void BuildVisitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(PartitionStatement* node) {
|
||||
SetPosition(node->base, current_node_);
|
||||
|
||||
auto parse_node = current_node_;
|
||||
|
||||
std::string partition_modifier = parse_node.NthChild(0).GetValue();
|
||||
|
||||
if (partition_modifier == "exec") {
|
||||
node->modifier = utils::PartitionModifier::Exec;
|
||||
} else if (partition_modifier == "test") {
|
||||
node->modifier = utils::PartitionModifier::Test;
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
|
||||
current_node_ = parse_node.ChildByFieldName("name");
|
||||
Visit(&node->name);
|
||||
|
||||
current_node_ = parse_node.ChildByFieldName("value");
|
||||
Visit(node->value);
|
||||
|
||||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
void BuildVisitor::Visit(NamespaceStatement& node) {
|
||||
|
|
@ -331,6 +325,9 @@ void BuildVisitor::Visit(NamespaceStatement& node) {
|
|||
} else if (current_node_type == parser::tokens::TypeDefinitionStatement) {
|
||||
node = std::make_unique<TypeDefinitionStatement>();
|
||||
Visit(std::get<std::unique_ptr<TypeDefinitionStatement>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::PartitionStatement) {
|
||||
node = std::make_unique<PartitionStatement>();
|
||||
Visit(std::get<std::unique_ptr<PartitionStatement>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::Namespace) {
|
||||
node = std::make_unique<Namespace>();
|
||||
Visit(std::get<std::unique_ptr<Namespace>>(node).get());
|
||||
|
|
@ -341,29 +338,6 @@ void BuildVisitor::Visit(NamespaceStatement& node) {
|
|||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(PartitionStatement& node) {
|
||||
auto parse_node = current_node_;
|
||||
|
||||
current_node_ = parse_node.NthNamedChild(0);
|
||||
|
||||
std::string current_node_type = current_node_.GetType();
|
||||
|
||||
if (current_node_type == parser::tokens::AbstractTypeDefinitionStatement) { // optimize ??
|
||||
node = std::make_unique<AbstractTypeDefinitionStatement>();
|
||||
Visit(std::get<std::unique_ptr<AbstractTypeDefinitionStatement>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::TypeclassDefinitionStatement) {
|
||||
node = std::make_unique<TypeclassDefinitionStatement>();
|
||||
Visit(std::get<std::unique_ptr<TypeclassDefinitionStatement>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::NamespaceStatement) {
|
||||
node = std::make_unique<NamespaceStatement>();
|
||||
Visit(*std::get<std::unique_ptr<NamespaceStatement>>(node));
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
|
||||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(SourceStatement& node) {
|
||||
auto parse_node = current_node_;
|
||||
|
||||
|
|
@ -374,12 +348,15 @@ void BuildVisitor::Visit(SourceStatement& node) {
|
|||
if (current_node_type == parser::tokens::ImportStatement) { // optimize ??
|
||||
node = std::make_unique<ImportStatement>();
|
||||
Visit(std::get<std::unique_ptr<ImportStatement>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::Partition) {
|
||||
node = std::make_unique<Partition>();
|
||||
Visit(std::get<std::unique_ptr<Partition>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::PartitionStatement) {
|
||||
node = std::make_unique<PartitionStatement>();
|
||||
Visit(*std::get<std::unique_ptr<PartitionStatement>>(node));
|
||||
} else if (current_node_type == parser::tokens::AbstractTypeDefinitionStatement) { // optimize ??
|
||||
node = std::make_unique<AbstractTypeDefinitionStatement>();
|
||||
Visit(std::get<std::unique_ptr<AbstractTypeDefinitionStatement>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::TypeclassDefinitionStatement) {
|
||||
node = std::make_unique<TypeclassDefinitionStatement>();
|
||||
Visit(std::get<std::unique_ptr<TypeclassDefinitionStatement>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::NamespaceStatement) {
|
||||
node = std::make_unique<NamespaceStatement>();
|
||||
Visit(*std::get<std::unique_ptr<NamespaceStatement>>(node));
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
|
|
@ -1167,6 +1144,25 @@ void BuildVisitor::Visit(LoopControlExpression& node) {
|
|||
|
||||
// Name
|
||||
|
||||
void BuildVisitor::Visit(PartitionName* node) {
|
||||
SetPosition(node->base, current_node_);
|
||||
|
||||
auto parse_node = current_node_;
|
||||
|
||||
size_t child_count = parse_node.NamedChildCount();
|
||||
|
||||
if (child_count > 1) {
|
||||
node->path.resize(child_count - 1);
|
||||
for (size_t i = 0; i + 1 < child_count; ++i) {
|
||||
node->path[i] = parse_node.NthNamedChild(i).GetValue();
|
||||
}
|
||||
}
|
||||
|
||||
node->name = parse_node.ChildByFieldName("name").GetValue();
|
||||
|
||||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(NameExpression* node) {
|
||||
SetPosition(node->base, current_node_);
|
||||
|
||||
|
|
@ -1176,8 +1172,8 @@ void BuildVisitor::Visit(NameExpression* node) {
|
|||
|
||||
node->names.resize(child_count);
|
||||
for (size_t i = 0; i < child_count; ++i) {
|
||||
current_node_ = parse_node.NthNamedChild(i);
|
||||
Visit(&node->names[i]);
|
||||
current_node_ = parse_node.NthNamedChild(i);
|
||||
Visit(&node->names[i]);
|
||||
}
|
||||
|
||||
current_node_ = parse_node;
|
||||
|
|
|
|||
|
|
@ -15,16 +15,6 @@ void ExecuteVisitor::Visit(SourceFile* node) {
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void ExecuteVisitor::Visit(PartitionSources* node) {
|
||||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
}
|
||||
}
|
||||
|
||||
void ExecuteVisitor::Visit(Partition* node) {
|
||||
Visit(&node->scope);
|
||||
}
|
||||
|
||||
void ExecuteVisitor::Visit(NamespaceSources* node) {
|
||||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
|
|
@ -83,6 +73,16 @@ void ExecuteVisitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
}
|
||||
}
|
||||
|
||||
void ExecuteVisitor::Visit(ExecutableStatement* node) {
|
||||
Visit(&node->name);
|
||||
Visitor::Visit(node->value);
|
||||
}
|
||||
|
||||
void ExecuteVisitor::Visit(TestStatement* node) {
|
||||
Visit(&node->name);
|
||||
Visitor::Visit(node->value);
|
||||
}
|
||||
|
||||
// Definition parts
|
||||
|
||||
void ExecuteVisitor::Visit(FunctionDefinition* node) {
|
||||
|
|
@ -276,6 +276,14 @@ void ExecuteVisitor::Visit(ArrayExpression* node) {
|
|||
|
||||
// Name
|
||||
|
||||
void ExecuteVisitor::Visit(PartitionName* node) {
|
||||
for (auto& path_namespace : node->path) {
|
||||
Visit(&path_namespace);
|
||||
}
|
||||
|
||||
Visit(&node->name);
|
||||
}
|
||||
|
||||
void ExecuteVisitor::Visit(NameExpression* node) {
|
||||
for (auto& name : node->names) {
|
||||
Visit(&name);
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@ namespace interpreter {
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void FindSymbolsVisitor::Visit(Partition* node) {
|
||||
// TODO: separate partitions
|
||||
Visitor::Visit(&node->scope);
|
||||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(Namespace* node) {
|
||||
namespace_visitor_.AddEnterNamespace(node->type, node->modifier);
|
||||
Visitor::Visit(&node->scope);
|
||||
|
|
@ -177,6 +172,15 @@ void FindSymbolsVisitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
is_in_statement_ = false;
|
||||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(PartitionStatement* node) {
|
||||
is_in_statement_ = true;
|
||||
|
||||
node->executable_id_ = namespace_visitor_.AddPartition(node->name.path, node->name.name, node);
|
||||
// TODO: typecheck error on same tests
|
||||
|
||||
is_in_statement_ = false;
|
||||
}
|
||||
|
||||
// Definition parts
|
||||
|
||||
void FindSymbolsVisitor::Visit(AnyAnnotatedType* node) {
|
||||
|
|
|
|||
|
|
@ -223,6 +223,25 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddConstructor(const std::string& co
|
|||
return 0;
|
||||
}
|
||||
|
||||
utils::IdType GlobalInfo::NamespaceVisitor::AddPartition(const std::vector<std::string>& path,
|
||||
const std::string& name,
|
||||
interpreter::tokens::PartitionStatement* node) {
|
||||
PartitionInfo partition;
|
||||
|
||||
partition.path.reserve(current_path_.size() + path.size());
|
||||
partition.path = current_path_;
|
||||
|
||||
for (auto& path_namespace : path) {
|
||||
partition.path.push_back(path_namespace);
|
||||
}
|
||||
|
||||
partition.name = name;
|
||||
partition.node = node;
|
||||
|
||||
global_info_.partitions_.push_back(partition);
|
||||
return global_info_.partitions_.size() - 1;
|
||||
}
|
||||
|
||||
std::optional<definition::Namespace*> GlobalInfo::NamespaceVisitor::FindNamespace(const std::optional<std::vector<std::string>>& path) {
|
||||
return FindSomething<definition::Namespace*>(path,
|
||||
[] (definition::Namespace* current_namespace) -> std::optional<definition::Namespace*> {
|
||||
|
|
|
|||
|
|
@ -15,32 +15,6 @@ void PrintVisitor::Visit(SourceFile* node) {
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void PrintVisitor::Visit(PartitionSources* node) {
|
||||
out_ << "[PartitionSources](\n";
|
||||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
}
|
||||
out_ << ")\n";
|
||||
}
|
||||
|
||||
void PrintVisitor::Visit(Partition* node) {
|
||||
out_ << "[Partition] ";
|
||||
switch (node->name) {
|
||||
case Partition::Test:
|
||||
out_ << "TEST";
|
||||
break;
|
||||
case Partition::Interface:
|
||||
out_ << "INTERFACE";
|
||||
break;
|
||||
case Partition::Code:
|
||||
out_ << "CODE";
|
||||
break;
|
||||
}
|
||||
out_ << " {\n";
|
||||
Visit(&node->scope);
|
||||
out_ << "}\n";
|
||||
}
|
||||
|
||||
void PrintVisitor::Visit(NamespaceSources* node) {
|
||||
out_ << "[NamespaceSources](\n";
|
||||
for (auto& statement : node->statements) {
|
||||
|
|
@ -124,6 +98,9 @@ void PrintVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
|
||||
void PrintVisitor::Visit(FunctionDeclaration* node) {
|
||||
out_ << "[FunctionDeclaration ";
|
||||
if (node->is_in_interface) {
|
||||
out_ << "interface ";
|
||||
}
|
||||
Visit(&node->name);
|
||||
out_ << "] (";
|
||||
for (auto& parameter : node->parameters) {
|
||||
|
|
@ -152,6 +129,9 @@ void PrintVisitor::Visit(TypeDefinitionStatement* node) {
|
|||
out_ << "class";
|
||||
break;
|
||||
}
|
||||
if (node->is_in_interface) {
|
||||
out_ << " interface";
|
||||
}
|
||||
out_ << "] (";
|
||||
Visit(node->definition.get());
|
||||
out_ << ") = (";
|
||||
|
|
@ -188,6 +168,22 @@ void PrintVisitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
out_ << ")\n";
|
||||
}
|
||||
|
||||
void PrintVisitor::Visit(PartitionStatement* node) {
|
||||
out_ << "[Partition ";
|
||||
switch (node->modifier) {
|
||||
case utils::PartitionModifier::Exec:
|
||||
out_ << "exec ";
|
||||
break;
|
||||
case utils::PartitionModifier::Test:
|
||||
out_ << "test ";
|
||||
break;
|
||||
}
|
||||
Visit(&node->name);
|
||||
out_ << "] = (";
|
||||
Visitor::Visit(node->value);
|
||||
out_ << ")\n";
|
||||
}
|
||||
|
||||
// Definition parts
|
||||
|
||||
void PrintVisitor::Visit(FunctionDefinition* node) {
|
||||
|
|
@ -556,6 +552,16 @@ void PrintVisitor::Visit(ArrayExpression* node) {
|
|||
|
||||
// Name
|
||||
|
||||
void PrintVisitor::Visit(PartitionName* node) {
|
||||
out_ << "[PartitionName] (";
|
||||
for (auto& path_namespace : node->path) {
|
||||
Visit(&path_namespace);
|
||||
out_ << "::";
|
||||
}
|
||||
Visit(&node->name);
|
||||
out_ << ')';
|
||||
}
|
||||
|
||||
void PrintVisitor::Visit(NameExpression* node) {
|
||||
out_ << "[NameExpression] (";
|
||||
for (size_t i = 0; i < node->names.size(); ++i) {
|
||||
|
|
|
|||
|
|
@ -23,22 +23,6 @@ void TypeCheckVisitor::Visit(SourceFile* node) {
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void TypeCheckVisitor::Visit(PartitionSources* node) {
|
||||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
}
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(Partition* node) {
|
||||
Visit(&node->scope);
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(NamespaceSources* node) {
|
||||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
|
|
@ -133,7 +117,6 @@ void TypeCheckVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
is_const_definition_ = std::nullopt;
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -156,7 +139,6 @@ void TypeCheckVisitor::Visit(FunctionDeclaration* node) {
|
|||
}
|
||||
Visit(node->type.get());
|
||||
context_manager_.ExitContext();
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
if (!was_in_statement) {
|
||||
|
|
@ -168,7 +150,6 @@ void TypeCheckVisitor::Visit(FunctionDeclaration* node) {
|
|||
|
||||
void TypeCheckVisitor::Visit(FunctionDefinitionStatement* node) {
|
||||
is_in_statement_ = true;
|
||||
|
||||
context_manager_.EnterContext();
|
||||
|
||||
const info::definition::Function& function_info = namespace_visitor_.GetGlobalInfo()->GetFunctionInfo(node->function_id_);
|
||||
|
|
@ -206,15 +187,13 @@ void TypeCheckVisitor::Visit(FunctionDefinitionStatement* node) {
|
|||
Visitor::Visit(*declaration.argument_types.back());
|
||||
utils::IdType return_type = current_type_;
|
||||
|
||||
// Visitor::Visit(node->value);
|
||||
Visitor::Visit(node->value);
|
||||
if (!context_manager_.EqualTypes(return_type, current_type_)) {
|
||||
error_handling::HandleTypecheckError("Wrong function return type", node->base);
|
||||
}
|
||||
|
||||
context_manager_.ExitContext();
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -222,9 +201,7 @@ void TypeCheckVisitor::Visit(FunctionDefinitionStatement* node) {
|
|||
|
||||
void TypeCheckVisitor::Visit(TypeDefinitionStatement* node) {
|
||||
is_in_statement_ = true;
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -247,7 +224,6 @@ void TypeCheckVisitor::Visit(AbstractTypeDefinitionStatement* node) {
|
|||
}
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -255,9 +231,20 @@ void TypeCheckVisitor::Visit(AbstractTypeDefinitionStatement* node) {
|
|||
|
||||
void TypeCheckVisitor::Visit(TypeclassDefinitionStatement* node) {
|
||||
is_in_statement_ = true;
|
||||
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
void TypeCheckVisitor::Visit(PartitionStatement* node) {
|
||||
is_in_statement_ = true;
|
||||
context_manager_.EnterContext();
|
||||
|
||||
Visitor::Visit(node->value);
|
||||
|
||||
context_manager_.ExitContext();
|
||||
current_type_ = context_manager_.AddType(info::type::InternalType::Unit, utils::ValueType::Tmp);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
|
|
@ -1041,6 +1028,8 @@ void TypeCheckVisitor::Visit(ArrayExpression* node) {
|
|||
|
||||
// Name
|
||||
|
||||
void TypeCheckVisitor::Visit(PartitionName* node) {} // Handled in partition ( executable / test )
|
||||
|
||||
void TypeCheckVisitor::Visit(NameExpression* node) {
|
||||
// TODO: move, etc.
|
||||
if (node->names.size() == 0) {
|
||||
|
|
|
|||
|
|
@ -21,44 +21,6 @@ void TypedPrintVisitor::Visit(SourceFile* node) {
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void TypedPrintVisitor::Visit(PartitionSources* node) {
|
||||
out_ << "[PartitionSources : ";
|
||||
|
||||
if (node->base.type_.has_value()) {
|
||||
out_ << context_manager_.GetAnyType(node->base.type_.value())->GetTypeName();
|
||||
}
|
||||
|
||||
out_ << "](\n";
|
||||
for (auto& statement : node->statements) {
|
||||
Visitor::Visit(statement);
|
||||
}
|
||||
out_ << ")\n";
|
||||
}
|
||||
|
||||
void TypedPrintVisitor::Visit(Partition* node) {
|
||||
out_ << "[Partition : ";
|
||||
|
||||
if (node->base.type_.has_value()) {
|
||||
out_ << context_manager_.GetAnyType(node->base.type_.value())->GetTypeName();
|
||||
}
|
||||
|
||||
out_ << "] ";
|
||||
switch (node->name) {
|
||||
case Partition::Test:
|
||||
out_ << "TEST";
|
||||
break;
|
||||
case Partition::Interface:
|
||||
out_ << "INTERFACE";
|
||||
break;
|
||||
case Partition::Code:
|
||||
out_ << "CODE";
|
||||
break;
|
||||
}
|
||||
out_ << " {\n";
|
||||
Visit(&node->scope);
|
||||
out_ << "}\n";
|
||||
}
|
||||
|
||||
void TypedPrintVisitor::Visit(NamespaceSources* node) {
|
||||
out_ << "[NamespaceSources : ";
|
||||
|
||||
|
|
@ -165,7 +127,11 @@ void TypedPrintVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
}
|
||||
|
||||
void TypedPrintVisitor::Visit(FunctionDeclaration* node) {
|
||||
out_ << "[FunctionDeclaration : (";
|
||||
out_ << "[FunctionDeclaration ";
|
||||
if (node->is_in_interface) {
|
||||
out_ << "interface ";
|
||||
}
|
||||
out_ << ": (";
|
||||
|
||||
if (node->base.type_.has_value()) {
|
||||
out_ << context_manager_.GetAnyType(node->base.type_.value())->GetTypeName();
|
||||
|
|
@ -212,6 +178,9 @@ void TypedPrintVisitor::Visit(TypeDefinitionStatement* node) {
|
|||
out_ << "class";
|
||||
break;
|
||||
}
|
||||
if (node->is_in_interface) {
|
||||
out_ << " interface";
|
||||
}
|
||||
out_ << "] (";
|
||||
Visit(node->definition.get());
|
||||
out_ << ") = (";
|
||||
|
|
@ -260,6 +229,28 @@ void TypedPrintVisitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
out_ << ")\n";
|
||||
}
|
||||
|
||||
void TypedPrintVisitor::Visit(PartitionStatement* node) {
|
||||
out_ << "[Partition : (";
|
||||
|
||||
if (node->base.type_.has_value()) {
|
||||
out_ << context_manager_.GetAnyType(node->base.type_.value())->GetTypeName();
|
||||
}
|
||||
|
||||
out_ << ") ";
|
||||
switch (node->modifier) {
|
||||
case utils::PartitionModifier::Exec:
|
||||
out_ << "exec ";
|
||||
break;
|
||||
case utils::PartitionModifier::Test:
|
||||
out_ << "test ";
|
||||
break;
|
||||
}
|
||||
Visit(&node->name);
|
||||
out_ << "] = (";
|
||||
Visitor::Visit(node->value);
|
||||
out_ << ")\n";
|
||||
}
|
||||
|
||||
// Definition parts
|
||||
|
||||
void TypedPrintVisitor::Visit(FunctionDefinition* node) {
|
||||
|
|
@ -783,6 +774,22 @@ void TypedPrintVisitor::Visit(ArrayExpression* node) {
|
|||
|
||||
// Name
|
||||
|
||||
void TypedPrintVisitor::Visit(PartitionName* node) {
|
||||
out_ << "[PartitionName : ";
|
||||
|
||||
if (node->base.type_.has_value()) {
|
||||
out_ << context_manager_.GetAnyType(node->base.type_.value())->GetTypeName();
|
||||
}
|
||||
|
||||
out_ << "] (";
|
||||
for (auto& path_namespace : node->path) {
|
||||
Visit(&path_namespace);
|
||||
out_ << "::";
|
||||
}
|
||||
Visit(&node->name);
|
||||
out_ << ')';
|
||||
}
|
||||
|
||||
void TypedPrintVisitor::Visit(NameExpression* node) {
|
||||
out_ << "[NameExpression : ";
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ void Visitor::Visit(NamespaceStatement& node) {
|
|||
Visit(std::get<std::unique_ptr<TypeDefinitionStatement>>(node).get());
|
||||
break;
|
||||
case 4:
|
||||
Visit(std::get<std::unique_ptr<PartitionStatement>>(node).get());
|
||||
break;
|
||||
case 5:
|
||||
Visit(std::get<std::unique_ptr<Namespace>>(node).get());
|
||||
break;
|
||||
default:
|
||||
|
|
@ -28,33 +31,19 @@ void Visitor::Visit(NamespaceStatement& node) {
|
|||
}
|
||||
}
|
||||
|
||||
void Visitor::Visit(PartitionStatement& node) {
|
||||
switch (node.index()) {
|
||||
case 0:
|
||||
Visit(std::get<std::unique_ptr<AbstractTypeDefinitionStatement>>(node).get());
|
||||
break;
|
||||
case 1:
|
||||
Visit(std::get<std::unique_ptr<TypeclassDefinitionStatement>>(node).get());
|
||||
break;
|
||||
case 2:
|
||||
Visit(*std::get<std::unique_ptr<NamespaceStatement>>(node));
|
||||
break;
|
||||
default:
|
||||
// error
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Visitor::Visit(SourceStatement& node) {
|
||||
switch (node.index()) {
|
||||
case 0:
|
||||
Visit(std::get<std::unique_ptr<ImportStatement>>(node).get());
|
||||
break;
|
||||
case 1:
|
||||
Visit(std::get<std::unique_ptr<Partition>>(node).get());
|
||||
Visit(std::get<std::unique_ptr<AbstractTypeDefinitionStatement>>(node).get());
|
||||
break;
|
||||
case 2:
|
||||
Visit(*std::get<std::unique_ptr<PartitionStatement>>(node));
|
||||
Visit(std::get<std::unique_ptr<TypeclassDefinitionStatement>>(node).get());
|
||||
break;
|
||||
case 3:
|
||||
Visit(*std::get<std::unique_ptr<NamespaceStatement>>(node));
|
||||
break;
|
||||
default:
|
||||
// error
|
||||
|
|
@ -315,16 +304,6 @@ void Visitor::Visit(SourceFile* node) {
|
|||
|
||||
// Namespaces, partitions -----------------
|
||||
|
||||
void Visitor::Visit(PartitionSources* node) {
|
||||
for (auto& statement : node->statements) {
|
||||
Visit(statement);
|
||||
}
|
||||
}
|
||||
|
||||
void Visitor::Visit(Partition* node) {
|
||||
Visit(&node->scope);
|
||||
}
|
||||
|
||||
void Visitor::Visit(NamespaceSources* node) {
|
||||
for (auto& statement : node->statements) {
|
||||
Visit(statement);
|
||||
|
|
@ -383,6 +362,11 @@ void Visitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
}
|
||||
}
|
||||
|
||||
void Visitor::Visit(PartitionStatement* node) {
|
||||
Visit(&node->name);
|
||||
Visit(node->value);
|
||||
}
|
||||
|
||||
// Definition parts
|
||||
|
||||
void Visitor::Visit(FunctionDefinition* node) {
|
||||
|
|
@ -576,6 +560,13 @@ void Visitor::Visit(ArrayExpression* node) {
|
|||
|
||||
// Name
|
||||
|
||||
void Visitor::Visit(PartitionName* node) {
|
||||
for (auto& path_namespace : node->path) {
|
||||
Visit(&path_namespace);
|
||||
}
|
||||
Visit(&node->name);
|
||||
}
|
||||
|
||||
void Visitor::Visit(NameExpression* node) {
|
||||
for (auto& name : node->names) {
|
||||
Visit(&name);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
partition TEST { // or .test.lang filename
|
||||
decl something : Unit -> Unit
|
||||
test All::Dev::Syntax::testing {
|
||||
const a = 31
|
||||
; do_something: a
|
||||
}
|
||||
|
||||
partition INTERFACE { // or .interface.lang filename
|
||||
decl something : Unit -> Unit
|
||||
}
|
||||
|
||||
partition CODE { // or .core.lang filename
|
||||
decl something : Unit -> Unit
|
||||
exec App::exe {
|
||||
const b = 1117
|
||||
; do_something_different: b b
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue