162 lines
4.7 KiB
C++
162 lines
4.7 KiB
C++
//============================================================================//
|
|
// //
|
|
// artichoke programming language //
|
|
// //
|
|
// Copyright (C) 2025 Erick Saul Guzman Ramos, whoami.artichoke.dev //
|
|
// //
|
|
// //
|
|
// This program is free software: you can redistribute it and/or modify //
|
|
// it under the terms of the GNU Affero General Public License as published //
|
|
// by the Free Software Foundation, either version 3 of the License, or //
|
|
// (at your option) any later version. //
|
|
// //
|
|
// This program is distributed in the hope that it will be useful, //
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
// GNU Affero General Public License for more details. //
|
|
// //
|
|
// You should have received a copy of the GNU Affero General Public License //
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
|
// //
|
|
//============================================================================//
|
|
|
|
#pragma once
|
|
|
|
#include <artichoke/Parser/AST/Common.hpp>
|
|
#include <artichoke/Parser/AST/Types.hpp>
|
|
#include <artichoke/Parser/AST/Statements.hpp>
|
|
|
|
namespace arti::lang::ast {
|
|
|
|
namespace nodes {
|
|
/* Forward declaration of types */
|
|
|
|
/* Main declaration node types */
|
|
struct ModuleDeclaration;
|
|
struct StructDeclaration;
|
|
struct EnumDeclaration;
|
|
struct FunctionDeclaration;
|
|
struct ImportDeclaration;
|
|
struct AliasDeclaration;
|
|
|
|
/* Helper declaration node types */
|
|
struct EnumMember;
|
|
struct StructMember;
|
|
struct GenericParam;
|
|
struct FunctionParam;
|
|
|
|
} // namespace nodes
|
|
|
|
/* Public Aliases */
|
|
using ModuleDeclNode = Ptr<nodes::ModuleDeclaration>;
|
|
using StructDeclNode = Ptr<nodes::StructDeclaration>;
|
|
using EnumDeclNode = Ptr<nodes::EnumDeclaration>;
|
|
using FunctionDeclNode = Ptr<nodes::FunctionDeclaration>;
|
|
using ImportDeclNode = Ptr<nodes::ImportDeclaration>;
|
|
using AliasDeclNode = Ptr<nodes::AliasDeclaration>;
|
|
using GenericParamNode = Ptr<nodes::GenericParam>;
|
|
using FunctionParamNode = Ptr<nodes::FunctionParam>;
|
|
using EnumMemberNode = Ptr<nodes::EnumMember>;
|
|
using StructMemberNode = Ptr<nodes::StructMember>;
|
|
|
|
/* Variant nodes */
|
|
using TopLevelDeclNode = Variant<
|
|
ModuleDeclNode,
|
|
StructDeclNode,
|
|
EnumDeclNode,
|
|
FunctionDeclNode,
|
|
ImportDeclNode,
|
|
AliasDeclNode
|
|
>;
|
|
|
|
using ModuleInnerDeclNode = Variant<
|
|
StructDeclNode,
|
|
EnumDeclNode,
|
|
FunctionDeclNode
|
|
>;
|
|
|
|
/* Node definitions */
|
|
|
|
struct nodes::ModuleDeclaration {
|
|
SourceLocation location;
|
|
|
|
Boolean isExported;
|
|
NamespacedIdentifierNode name;
|
|
Vector<ModuleDeclNode> childModules;
|
|
Vector<ModuleInnerDeclNode> innerDeclarations;
|
|
Vector<AliasDeclNode> aliasDeclarations;
|
|
};
|
|
|
|
struct nodes::StructDeclaration {
|
|
SourceLocation location;
|
|
|
|
Boolean isExported;
|
|
String name;
|
|
Vector<GenericParamNode> genericParams;
|
|
Vector<StructMemberNode> structMembers;
|
|
};
|
|
|
|
struct nodes::EnumDeclaration {
|
|
SourceLocation location;
|
|
|
|
Boolean isExported;
|
|
String name;
|
|
Vector<GenericParamNode> genericParams;
|
|
Vector<EnumMemberNode> enumMembers;
|
|
};
|
|
|
|
struct nodes::FunctionDeclaration {
|
|
SourceLocation location;
|
|
|
|
Boolean isExported;
|
|
String name;
|
|
Optional<TypeNode> returnType;
|
|
Vector<GenericParamNode> genericParams;
|
|
Vector<FunctionParamNode> functionParams;
|
|
CodeBlockStmtNode functionBody;
|
|
};
|
|
|
|
struct nodes::ImportDeclaration {
|
|
SourceLocation location;
|
|
|
|
Boolean importAll;
|
|
NamespacedIdentifierNode importTarget;
|
|
};
|
|
|
|
struct nodes::AliasDeclaration {
|
|
SourceLocation location;
|
|
|
|
String alias;
|
|
TypeNode target;
|
|
};
|
|
|
|
struct nodes::StructMember {
|
|
SourceLocation location;
|
|
|
|
String name;
|
|
TypeNode type;
|
|
};
|
|
|
|
struct nodes::EnumMember {
|
|
SourceLocation location;
|
|
|
|
String name;
|
|
Optional<TypeNode> type;
|
|
};
|
|
|
|
struct nodes::GenericParam {
|
|
SourceLocation location;
|
|
|
|
String name;
|
|
};
|
|
|
|
struct nodes::FunctionParam {
|
|
SourceLocation location;
|
|
|
|
Boolean isThis;
|
|
String name;
|
|
TypeNode type;
|
|
};
|
|
|
|
} // namespace arti::lang::ast
|