Signed-off-by: erick-alcachofa <erick@artichoke.dev> This commit adds `Uninitialized` to several enums in `Common.hpp` to ensure they are properly initialized. It also adds missing binary operators like `BitAnd`, `BitXor`, `Adition`, and `Multiplication`. This change improves the robustness and functionality of the AST parser.
101 lines
1.6 KiB
C++
101 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <memory>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <variant>
|
|
#include <optional>
|
|
|
|
namespace arti::lang::ast {
|
|
|
|
struct SourceLocation {
|
|
std::size_t line;
|
|
std::size_t column;
|
|
};
|
|
|
|
enum class Mutability {
|
|
Uninitialized,
|
|
Mutable,
|
|
Constant,
|
|
};
|
|
|
|
enum class TypeQualifier {
|
|
Uninitialized,
|
|
Pointer,
|
|
Slice,
|
|
Mutable,
|
|
Optional,
|
|
};
|
|
|
|
enum class UnaryOperator {
|
|
Uninitialized,
|
|
Not,
|
|
Minus,
|
|
BitNot,
|
|
Ampersand,
|
|
Star,
|
|
};
|
|
|
|
enum class BinaryOperator {
|
|
Uninitialized,
|
|
Equal,
|
|
NotEqual,
|
|
GreaterThan,
|
|
LessThan,
|
|
GreaterEqual,
|
|
LessEqual,
|
|
BitAnd,
|
|
BitXor,
|
|
BitOr,
|
|
LeftShift,
|
|
RightShift,
|
|
Adition,
|
|
Substraction,
|
|
Multiplication,
|
|
Division,
|
|
Modulo,
|
|
BoolAnd,
|
|
BoolOr,
|
|
};
|
|
|
|
enum class CompoundAssignOperator {
|
|
Uninitialized,
|
|
Addition,
|
|
Substraction,
|
|
Multiplication,
|
|
Division,
|
|
Modulo,
|
|
BitAnd,
|
|
BitOr,
|
|
LeftShift,
|
|
RightShift,
|
|
BoolAnd,
|
|
BoolOr,
|
|
};
|
|
|
|
/* Alising of types for consistency */
|
|
|
|
using Boolean = bool;
|
|
using String = std::string;
|
|
|
|
template <typename T>
|
|
using Ptr = std::unique_ptr<T>;
|
|
|
|
template <typename T>
|
|
using Optional = std::optional<T>;
|
|
|
|
template <typename... T>
|
|
using Variant = std::variant<T...>;
|
|
|
|
template <typename T>
|
|
using Vector = std::vector<T>;
|
|
|
|
template <typename Node>
|
|
concept ASTNodePtr = requires {
|
|
typename Node::element_type;
|
|
requires std::is_same_v<std::unique_ptr<typename Node::element_type>, Node>;
|
|
};
|
|
|
|
} // namespace arti::lang::ast
|