erick-alcachofa b99f3586dc
chore(license): Added NOTICE header to all source files
Signed-off-by: erick-alcachofa <erick@artichoke.dev>
2025-12-25 13:12:41 -06:00

228 lines
6.4 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/Literals.hpp>
namespace arti::lang::ast {
namespace nodes {
/* Forward declaration of types */
/* Main declaration node types */
struct IdentifierExpression;
struct UnaryExpression;
struct BinaryExpression;
struct AssignExpression;
struct CompoundAssignExpression;
struct FunctionCallExpression;
struct SliceAccessExpression;
struct SliceRangeExpression;
struct MemberAccessExpression;
struct PointerAccessExpression;
struct ScopeAccessExpression;
struct ReflectionExpression;
struct SliceCreationExpression;
struct SliceLengthExpression;
struct SlicePtrExpression;
} // namespace nodes
/* Public Aliases */
using IdentifierExprNode = Ptr<nodes::IdentifierExpression>;
using UnaryExprNode = Ptr<nodes::UnaryExpression>;
using BinaryExprNode = Ptr<nodes::BinaryExpression>;
using AssignExprNode = Ptr<nodes::AssignExpression>;
using CompoundAssignExprNode = Ptr<nodes::CompoundAssignExpression>;
using FunctionCallExprNode = Ptr<nodes::FunctionCallExpression>;
using SliceAccessExprNode = Ptr<nodes::SliceAccessExpression>;
using SliceRangeExprNode = Ptr<nodes::SliceRangeExpression>;
using MemberAccessExprNode = Ptr<nodes::MemberAccessExpression>;
using PointerAccessExprNode = Ptr<nodes::PointerAccessExpression>;
using ScopeAccessExprNode = Ptr<nodes::ScopeAccessExpression>;
using ReflectionExprNode = Ptr<nodes::ReflectionExpression>;
using SliceCreationExprNode = Ptr<nodes::SliceCreationExpression>;
using SliceLengthExprNode = Ptr<nodes::SliceLengthExpression>;
using SlicePtrExprNode = Ptr<nodes::SlicePtrExpression>;
/* Variant nodes */
using ExpressionNode = Variant<
CharLtrlNode,
NullLtrlNode,
StringLtrlNode,
FloatLtrlNode,
IntegerLtrlNode,
BooleanLtrlNode,
StructLtrlNode,
SliceLtrlNode,
IdentifierExprNode,
UnaryExprNode,
BinaryExprNode,
AssignExprNode,
CompoundAssignExprNode,
FunctionCallExprNode,
SliceAccessExprNode,
SliceRangeExprNode,
MemberAccessExprNode,
PointerAccessExprNode,
ScopeAccessExprNode,
SliceCreationExprNode,
SliceLengthExprNode,
SlicePtrExprNode,
ReflectionExprNode
>;
/* Node definitions */
struct nodes::IdentifierExpression {
SourceLocation location;
String identifierName;
};
struct nodes::UnaryExpression {
SourceLocation location;
UnaryOperator op;
ExpressionNode right;
};
struct nodes::BinaryExpression {
SourceLocation location;
BinaryOperator 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<ExpressionNode> arguments;
};
struct nodes::SliceAccessExpression {
SourceLocation location;
ExpressionNode slice;
ExpressionNode index;
};
struct nodes::SliceRangeExpression {
SourceLocation location;
ExpressionNode slice;
Optional<ExpressionNode> start;
Optional<ExpressionNode> end;
};
struct nodes::MemberAccessExpression {
SourceLocation location;
String memberName;
ExpressionNode object;
};
struct nodes::PointerAccessExpression {
SourceLocation location;
String memberName;
ExpressionNode object;
};
struct nodes::ScopeAccessExpression {
SourceLocation location;
String memberName;
ExpressionNode scope;
Vector<TypeNode> genericParams;
};
struct nodes::ReflectionExpression {
SourceLocation location;
Optional<String> 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::StructLiteralNamedFieldInit {
SourceLocation location;
String fieldName;
ExpressionNode fieldValue;
};
struct nodes::StructLiteralPositionalInit {
SourceLocation location;
ExpressionNode fieldValue;
};
struct nodes::StructLiteralNamedInitializer {
SourceLocation location;
Vector<StructLtrlNamedFieldInitNode> fields;
};
struct nodes::StructLiteralPositionalInitializer {
SourceLocation location;
Vector<StructLtrlPositionalInitNode> fields;
};
} // namespace arti::lang::ast