132 lines
4.2 KiB
C++
132 lines
4.2 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>
|
|
|
|
namespace arti::lang::ast {
|
|
|
|
namespace nodes {
|
|
/* Forward declaration of types */
|
|
|
|
/* Main declaration node types */
|
|
struct CharLiteral;
|
|
struct NullLiteral;
|
|
struct StringLiteral;
|
|
struct FloatLiteral;
|
|
struct IntegerLiteral;
|
|
struct BooleanLiteral;
|
|
struct StructLiteral;
|
|
struct SliceLiteral;
|
|
|
|
/* Helper declaration node types */
|
|
struct StructLiteralNamedFieldInit;
|
|
struct StructLiteralPositionalInit;
|
|
struct StructLiteralNamedInitializer;
|
|
struct StructLiteralPositionalInitializer;
|
|
|
|
} // namespace nodes
|
|
|
|
/* Public Aliases */
|
|
using CharLtrlNode = Ptr<nodes::CharLiteral>;
|
|
using NullLtrlNode = Ptr<nodes::NullLiteral>;
|
|
using StringLtrlNode = Ptr<nodes::StringLiteral>;
|
|
using FloatLtrlNode = Ptr<nodes::FloatLiteral>;
|
|
using IntegerLtrlNode = Ptr<nodes::IntegerLiteral>;
|
|
using BooleanLtrlNode = Ptr<nodes::BooleanLiteral>;
|
|
using StructLtrlNode = Ptr<nodes::StructLiteral>;
|
|
using SliceLtrlNode = Ptr<nodes::SliceLiteral>;
|
|
|
|
using StructLtrlNamedFieldInitNode =
|
|
Ptr<nodes::StructLiteralNamedFieldInit>;
|
|
using StructLtrlPositionalInitNode =
|
|
Ptr<nodes::StructLiteralPositionalInit>;
|
|
using StructLtrlNamedInitializerNode =
|
|
Ptr<nodes::StructLiteralNamedInitializer>;
|
|
using StructLtrlPositionalInitializerNode =
|
|
Ptr<nodes::StructLiteralPositionalInitializer>;
|
|
|
|
/* Variant nodes */
|
|
using StructLtrlInitializerNode = Variant<
|
|
StructLtrlNamedInitializerNode,
|
|
StructLtrlPositionalInitializerNode
|
|
>;
|
|
|
|
/* Node definitions */
|
|
|
|
struct nodes::CharLiteral {
|
|
SourceLocation location;
|
|
|
|
uint8_t value;
|
|
};
|
|
|
|
struct nodes::NullLiteral {
|
|
SourceLocation location;
|
|
};
|
|
|
|
struct nodes::StringLiteral {
|
|
SourceLocation location;
|
|
|
|
String value;
|
|
};
|
|
|
|
struct nodes::FloatLiteral {
|
|
SourceLocation location;
|
|
|
|
double value;
|
|
};
|
|
|
|
struct nodes::IntegerLiteral {
|
|
SourceLocation location;
|
|
|
|
uint64_t value;
|
|
};
|
|
|
|
struct nodes::BooleanLiteral {
|
|
SourceLocation location;
|
|
|
|
Boolean value;
|
|
};
|
|
|
|
struct nodes::StructLiteral {
|
|
SourceLocation location;
|
|
|
|
TypeNode type;
|
|
Optional<StructLtrlInitializerNode> initializer;
|
|
};
|
|
|
|
struct nodes::SliceLiteral {
|
|
SourceLocation location;
|
|
|
|
TypeNode type;
|
|
Optional<StructLtrlPositionalInitializerNode> initializer;
|
|
};
|
|
|
|
/* INFO: Helper types definitions are on Expressions.hpp
|
|
* due to dependency in ExpressionNode variant. */
|
|
|
|
} // namespace arti::lang::ast
|
|
|
|
|