summaryrefslogtreecommitdiffhomepage
path: root/include/CompilerKit/AST.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-18 01:57:41 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-18 01:57:41 +0100
commit228479a454d325340326f4fd23e13d780884fd2a (patch)
treeee35d5eecde396e674d1a0e11c5372352a49fac4 /include/CompilerKit/AST.h
parent80de28e3472613e8f6aa8b2730d56b5307f4fb9a (diff)
chore & feat: New DLLLoader API and AST API improvements.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/CompilerKit/AST.h')
-rw-r--r--include/CompilerKit/AST.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/include/CompilerKit/AST.h b/include/CompilerKit/AST.h
index aee3ff1..a1819b1 100644
--- a/include/CompilerKit/AST.h
+++ b/include/CompilerKit/AST.h
@@ -70,7 +70,7 @@ enum KeywordKind {
/// \brief Compiler keyword information struct.
/// =========================================================== ///
struct SyntaxKeyword {
- SyntaxKeyword(STLString name, KeywordKind kind) : fKeywordName(name), fKeywordKind(kind) {}
+ SyntaxKeyword(const STLString& name, KeywordKind kind) : fKeywordName(name), fKeywordKind(kind) {}
STLString fKeywordName{""};
KeywordKind fKeywordKind{kKeywordKindInvalid};
@@ -78,10 +78,15 @@ struct SyntaxKeyword {
struct SyntaxLeafList final {
struct SyntaxLeaf final {
- Int32 fUserType{0U};
+ // \brief User data type.
+ Int32 fUserType{0U};
+ // \brief User data buffer.
SyntaxKeyword fUserData{"", kKeywordKindInvalid};
- STLString fUserValue{""};
+ // \brief User data value
+ STLString fUserValue{""};
+
+ // \brief Next user data on list.
struct SyntaxLeaf* fNext{nullptr};
};
@@ -90,8 +95,14 @@ struct SyntaxLeafList final {
ArrayType fLeafList;
SizeType fNumLeafs{0};
- SizeType NumLeafs() { return fNumLeafs; }
- ArrayType& Get() { return fLeafList; }
+ public:
+ const SizeType& NumLeafs() { return fNumLeafs; }
+ const SizeType& NumLeafs() const { return fNumLeafs; }
+ const ArrayType& Get() const { return fLeafList; }
+ ArrayType& Get() { return fLeafList; }
+ // \brief You can't get a reference of a leaf in a const context.
+ const SyntaxLeaf& At(const SizeType& index) const = delete;
+ // \breif Grab leaf from index.
SyntaxLeaf& At(const SizeType& index) { return fLeafList[index]; }
};
@@ -131,7 +142,7 @@ class ICompilerFrontend {
//! @brief Compile a syntax tree ouf of the text.
//! Also takes the source file name for metadata.
/// =========================================================== ///
- virtual SyntaxLeafList::SyntaxLeaf Compile(STLString text, STLString file) = 0;
+ virtual SyntaxLeafList::SyntaxLeaf Compile(STLString text, STLString file) { return {}; }
/// =========================================================== ///
//! @brief What language are we dealing with?
@@ -145,4 +156,4 @@ class ICompilerFrontend {
};
} // namespace CompilerKit
-#include <CompilerKit/AST.inl> \ No newline at end of file
+#include <CompilerKit/AST.inl>