summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-01-13 04:10:54 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-01-13 04:10:54 +0100
commit68dcaf3c8909ae09e2197a069f0fb84cfd4a5444 (patch)
treeb79457c4739e3dc6251ea3076fb8a9bddaa2d4d5
parent0d7337aef0eb32f49b25ea7ce7b12af727121381 (diff)
feat: Nectar specs V1, introduce LibGL.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--.gitignore2
-rw-r--r--doc/specs/NECTAR_LANG.md6
-rw-r--r--include/CompilerKit/AST.h1
-rw-r--r--include/LibGL/iostream.nhh (renamed from include/LibNectar/iostream.nhh)0
-rw-r--r--include/LibGL/iterator.nhh (renamed from include/LibNectar/iterator.nhh)17
-rw-r--r--src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc10
-rw-r--r--test/test_samples/iostream.ncpp1
-rw-r--r--test/test_samples/return_value.ncpp4
8 files changed, 24 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index f0622a6..8bee682 100644
--- a/.gitignore
+++ b/.gitignore
@@ -240,8 +240,6 @@ nbdist/
## VSCode
.vscode/settings.json
-libgl/
-
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
diff --git a/doc/specs/NECTAR_LANG.md b/doc/specs/NECTAR_LANG.md
index 2dddfd4..cdb760f 100644
--- a/doc/specs/NECTAR_LANG.md
+++ b/doc/specs/NECTAR_LANG.md
@@ -24,4 +24,10 @@
- `let` Pointer/Reference variable declaration.
- `const` const `let` declaration.
+===================================
+
+# 2: Concepts
+
+===================================
+Nectar runs using the Generics Library (GL) -- it contains foundational code to run nectar applications and systems.
diff --git a/include/CompilerKit/AST.h b/include/CompilerKit/AST.h
index 6136721..b991bd0 100644
--- a/include/CompilerKit/AST.h
+++ b/include/CompilerKit/AST.h
@@ -29,7 +29,6 @@ enum struct KeywordKind {
kKeywordKindFunctionStart,
kKeywordKindFunctionEnd,
kKeywordKindVariable,
- kKeywordKindType,
kKeywordKindExpressionBegin,
kKeywordKindExpressionEnd,
kKeywordKindArgSeparator,
diff --git a/include/LibNectar/iostream.nhh b/include/LibGL/iostream.nhh
index 9e14174..9e14174 100644
--- a/include/LibNectar/iostream.nhh
+++ b/include/LibGL/iostream.nhh
diff --git a/include/LibNectar/iterator.nhh b/include/LibGL/iterator.nhh
index 5b760ed..a038421 100644
--- a/include/LibNectar/iterator.nhh
+++ b/include/LibGL/iterator.nhh
@@ -8,19 +8,24 @@
struct iterator_traits
{
- let begin(let collection)
+ let begin(let it)
{
- return collection._begin;
+ let end := it._begin;
+ return end;
}
- let end(let collection)
+ let end(let it)
{
- return collection._begin + collection._size;
+ let end := it._begin;
+ end += it._end;
+
+ return end;
}
- let size(let collection)
+ let size(let it)
{
- return collection._size;
+ let sz := it._size;
+ return sz;
}
};
diff --git a/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc b/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
index 56ae555..825c5c2 100644
--- a/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
+++ b/src/CompilerKit/src/Compilers/NectarCompiler+AMD64.cc
@@ -568,7 +568,7 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile(
valueOfVar = text.substr(text.find("-=") + 2);
} else if (keyword.first.fKeywordKind ==
CompilerKit::KeywordKind::kKeywordKindVariableAssign) {
- valueOfVar = text.substr(text.find(":=") + 2);
+ valueOfVar = text.substr(text.find(keyword.first.fKeywordName) + keyword.first.fKeywordName.size());
} else if (keyword.first.fKeywordKind == CompilerKit::KeywordKind::kKeywordKindEndInstr) {
break;
}
@@ -591,7 +591,7 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile(
varName.erase(varName.find("-="));
} else if (keyword.first.fKeywordKind ==
CompilerKit::KeywordKind::kKeywordKindVariableAssign) {
- varName.erase(varName.find(":="));
+ varName.erase(varName.find(keyword.first.fKeywordName));
} else if (keyword.first.fKeywordKind == CompilerKit::KeywordKind::kKeywordKindEndInstr) {
varName.erase(varName.find(";"));
}
@@ -599,7 +599,7 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile(
static bool typeFound = false;
for (auto& keyword : kKeywords) {
- if (keyword.fKeywordKind == CompilerKit::KeywordKind::kKeywordKindType) {
+ if (keyword.fKeywordKind == CompilerKit::KeywordKind::kKeywordKindVariable) {
if (text.find(keyword.fKeywordName) != CompilerKit::STLString::npos) {
if (text[text.find(keyword.fKeywordName)] == ' ') {
typeFound = false;
@@ -625,7 +625,7 @@ CompilerKit::SyntaxLeafList::SyntaxLeaf CompilerFrontendNectarAMD64::Compile(
}
if (keyword.second > 0 && kKeywords[keyword.second - 1].fKeywordKind ==
- CompilerKit::KeywordKind::kKeywordKindType) {
+ CompilerKit::KeywordKind::kKeywordKindVariable) {
syntax_tree.fUserValue += "\n";
continue;
}
@@ -1222,13 +1222,13 @@ NECTAR_MODULE(CompilerNectarAMD64) {
kKeywords.emplace_back("struct", CompilerKit::KeywordKind::kKeywordKindClass);
kKeywords.emplace_back("{", CompilerKit::KeywordKind::kKeywordKindBodyStart);
kKeywords.emplace_back("}", CompilerKit::KeywordKind::kKeywordKindBodyEnd);
- kKeywords.emplace_back("let", CompilerKit::KeywordKind::kKeywordKindType);
kKeywords.emplace_back("(", CompilerKit::KeywordKind::kKeywordKindFunctionStart);
kKeywords.emplace_back(")", CompilerKit::KeywordKind::kKeywordKindFunctionEnd);
kKeywords.emplace_back(":=", CompilerKit::KeywordKind::kKeywordKindVariableAssign);
kKeywords.emplace_back("+=", CompilerKit::KeywordKind::kKeywordKindVariableInc);
kKeywords.emplace_back("-=", CompilerKit::KeywordKind::kKeywordKindVariableDec);
kKeywords.emplace_back("const", CompilerKit::KeywordKind::kKeywordKindConstant);
+ kKeywords.emplace_back("let", CompilerKit::KeywordKind::kKeywordKindVariable);
kKeywords.emplace_back("->", CompilerKit::KeywordKind::kKeywordKindPtrAccess);
kKeywords.emplace_back(".", CompilerKit::KeywordKind::kKeywordKindAccess);
kKeywords.emplace_back(",", CompilerKit::KeywordKind::kKeywordKindArgSeparator);
diff --git a/test/test_samples/iostream.ncpp b/test/test_samples/iostream.ncpp
index a432896..9f46fa6 100644
--- a/test/test_samples/iostream.ncpp
+++ b/test/test_samples/iostream.ncpp
@@ -1,3 +1,4 @@
+#include "../../include/LibGL/iostream.nhh"
let main()
{
diff --git a/test/test_samples/return_value.ncpp b/test/test_samples/return_value.ncpp
index 812743a..0144df9 100644
--- a/test/test_samples/return_value.ncpp
+++ b/test/test_samples/return_value.ncpp
@@ -1,8 +1,6 @@
-#include "../../include/LibNectar/iostream.nhh"
let main()
{
- let six_seven = 67;
-
+ let six_seven := 67;
return six_seven;
}