//============================================================================//
// //
// 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 . //
// //
//============================================================================//
#pragma once
#include
#include
namespace arti::lang::ast {
namespace nodes {
/* Forward declaration of types */
/* Main declaration node types */
struct IdentifierExpression;
struct PrefixExpression;
struct InfixExpression;
struct AssignExpression;
struct CompoundAssignExpression;
struct FunctionCallExpression;
struct SliceAccessExpression;
struct SliceRangeExpression;
struct MemberAccessExpression;
struct PointerMemberAccessExpression;
struct GenericExpression;
struct ModuleAccessExpression;
struct ReflectionExpression;
struct SliceCreationExpression;
struct SliceLengthExpression;
struct SlicePtrExpression;
struct TypeExpression;
} // namespace nodes
/* Public Aliases */
using IdentifierExprNode = Ptr;
using PrefixExprNode = Ptr;
using InfixExprNode = Ptr;
using AssignExprNode = Ptr;
using CompoundAssignExprNode = Ptr;
using FunctionCallExprNode = Ptr;
using SliceAccessExprNode = Ptr;
using SliceRangeExprNode = Ptr;
using MemberAccessExprNode = Ptr;
using PointerMemberAccessExprNode = Ptr;
using GenericExprNode = Ptr;
using ModuleAccessExprNode = Ptr;
using ReflectionExprNode = Ptr;
using SliceCreationExprNode = Ptr;
using SliceLengthExprNode = Ptr;
using SlicePtrExprNode = Ptr;
using TypeExprNode = Ptr;
/* Variant nodes */
using ExpressionNode = Variant<
CharLtrlNode,
NullLtrlNode,
StringLtrlNode,
FloatLtrlNode,
IntegerLtrlNode,
BooleanLtrlNode,
ObjectLtrlNode,
IdentifierExprNode,
PrefixExprNode,
InfixExprNode,
AssignExprNode,
CompoundAssignExprNode,
FunctionCallExprNode,
SliceAccessExprNode,
SliceRangeExprNode,
MemberAccessExprNode,
PointerMemberAccessExprNode,
GenericExprNode,
ModuleAccessExprNode,
SliceCreationExprNode,
SliceLengthExprNode,
SlicePtrExprNode,
ReflectionExprNode,
TypeExprNode
>;
/* Node definitions */
struct nodes::IdentifierExpression {
SourceLocation location;
String identifierName;
};
struct nodes::PrefixExpression {
SourceLocation location;
PrefixOperator op;
ExpressionNode right;
};
struct nodes::InfixExpression {
SourceLocation location;
InfixOperator op;
ExpressionNode left;
ExpressionNode right;
};
struct nodes::AssignExpression {
SourceLocation location;
ExpressionNode left;
ExpressionNode right;
};
struct nodes::CompoundAssignExpression {
SourceLocation location;
CompoundAssignOperator op;
ExpressionNode left;
ExpressionNode right;
};
struct nodes::FunctionCallExpression {
SourceLocation location;
ExpressionNode callee;
Vector arguments;
};
struct nodes::SliceAccessExpression {
SourceLocation location;
ExpressionNode slice;
ExpressionNode index;
};
struct nodes::SliceRangeExpression {
SourceLocation location;
ExpressionNode slice;
Optional start;
Optional end;
};
struct nodes::MemberAccessExpression {
SourceLocation location;
ExpressionNode member;
ExpressionNode object;
};
struct nodes::PointerMemberAccessExpression {
SourceLocation location;
ExpressionNode member;
ExpressionNode object;
};
struct nodes::ModuleAccessExpression {
SourceLocation location;
ExpressionNode left;
ExpressionNode right;
};
struct nodes::GenericExpression {
SourceLocation location;
ExpressionNode typeNode;
std::vector genericArgs;
};
struct nodes::ReflectionExpression {
SourceLocation location;
Optional attribute;
ExpressionNode object;
};
struct nodes::SliceCreationExpression {
SourceLocation location;
ExpressionNode object;
ExpressionNode length;
};
struct nodes::SliceLengthExpression {
SourceLocation location;
ExpressionNode object;
};
struct nodes::SlicePtrExpression {
SourceLocation location;
ExpressionNode object;
};
struct nodes::ObjectLiteralNamedFieldInit {
SourceLocation location;
String fieldName;
ExpressionNode fieldValue;
};
struct nodes::ObjectLiteralNamedInitializer {
SourceLocation location;
Vector fields;
};
struct nodes::ObjectLiteralPositionalInitializer {
SourceLocation location;
Vector fields;
};
struct nodes::ObjectLiteral {
SourceLocation location;
ExpressionNode type;
Optional initializer;
};
struct nodes::TypeExpression {
SourceLocation location;
TypeNode type;
};
} // namespace arti::lang::ast