No more polish notation

This commit is contained in:
2026-02-26 08:50:43 +11:00
parent abc9728aa2
commit 1bc4b7fa62
2 changed files with 14 additions and 3 deletions

View File

@@ -149,7 +149,10 @@ static inline ResultType(Nothing, charptr) parseIdentifier(SolsParser* parser) {
} }
static inline ResultType(Nothing, charptr) parseSet(SolsParser* parser) { static inline ResultType(Nothing, charptr) parseSet(SolsParser* parser) {
if (parser->output.children.at[parser->output.children.count - 1].type != SNT_IDENTIFIER) { if (parser->currentParent->children.count < 1) {
return Error(Nothing, charptr, "Expecting identifier before '='");
}
if (parser->currentParent->children.at[parser->output.children.count - 1].type != SNT_IDENTIFIER) {
return Error(Nothing, charptr, "Expecting identifier before '='"); return Error(Nothing, charptr, "Expecting identifier before '='");
} }
@@ -159,6 +162,9 @@ static inline ResultType(Nothing, charptr) parseSet(SolsParser* parser) {
return Error(Nothing, charptr, tokens.as.error); return Error(Nothing, charptr, tokens.as.error);
} }
// Get the identifier (previous node)
SolsNode idNode = parser->currentParent->children.at[parser->currentParent->children.count - 1];
ResultType(SolsToken, Nothing) peek = parserPeek(parser, 0); ResultType(SolsToken, Nothing) peek = parserPeek(parser, 0);
if (peek.error) return Error(Nothing, charptr, "ruh roh"); if (peek.error) return Error(Nothing, charptr, "ruh roh");
@@ -193,11 +199,16 @@ static inline ResultType(Nothing, charptr) parseSet(SolsParser* parser) {
return Error(Nothing, charptr, "Expecting token after '='"); return Error(Nothing, charptr, "Expecting token after '='");
} }
// Copy nodes into the sols node // Copy idnode into set node
addChildToSolsNode(&node.as.success, idNode);
// Copy nodes into the set node
for (size_t i = 0; i < putsParser.as.success.output.children.count; i++) { for (size_t i = 0; i < putsParser.as.success.output.children.count; i++) {
addChildToSolsNode(&node.as.success, putsParser.as.success.output.children.at[i]); addChildToSolsNode(&node.as.success, putsParser.as.success.output.children.at[i]);
} }
// Put the set node where the idNode was
parser->currentParent->children.count--;
addChildToSolsNode(parser->currentParent, node.as.success); addChildToSolsNode(parser->currentParent, node.as.success);
return Success(Nothing, charptr, {}); return Success(Nothing, charptr, {});

View File

@@ -1,5 +1,5 @@
// heheheha comment // heheheha comment
= x 5 x = 5
puts x puts x