Type parser

This commit is contained in:
2026-03-05 19:32:31 +11:00
parent f1eee4f6a8
commit 00ef8a7d56
8 changed files with 290 additions and 7 deletions

View File

@@ -6,6 +6,21 @@
#include <groundvm.h>
SolsTokenPrecedence getPrecedence(SolsToken *token) {
static size_t braceCount = 0;
switch (token->type) {
case STT_OPEN_CURLY: {
braceCount++;
return STP_OTHER;
}
case STT_CLOSE_CURLY: {
braceCount--;
return STP_OTHER;
}
default: break;
}
if (braceCount > 0) {
return STP_OTHER;
}
switch (token->type) {
case STT_LINE_END: return STP_NEWLINE;
case STT_KW_PUTS: return STP_PUTS;
@@ -1399,9 +1414,7 @@ static inline ResultType(Nothing, charptr) parseDef(SolsParser* parser) {
SolsNode codeBlock = parser->currentParent->children.at[parser->currentParent->children.count - 1];
parser->currentParent->children.count--;
// We need to get the actual node from the parent to modify it
SolsNode* defNode = &parser->currentParent->children.at[parser->currentParent->children.count - 1];
addChildToSolsNode(defNode, codeBlock);
addChildToSolsNode(&parser->currentParent->children.at[0], parser->currentParent->children.at[1]);
return Success(Nothing, charptr, {});
}