Start work on inline ground

This commit is contained in:
2026-03-01 15:15:25 +11:00
parent 14f852e39b
commit 1ec55565d6
2 changed files with 20 additions and 0 deletions

View File

@@ -975,6 +975,10 @@ ResultType(GroundProgram, charptr) generateUseNode(SolsNode* node, SolsScope* sc
return Success(GroundProgram, charptr, codegen.as.success);
}
ResultType(GroundProgram, charptr) generateInlineGroundNode(SolsNode* node, SolsScope* scope) {
return Success(GroundProgram, charptr, groundParseFile(node->as.inlineGround));
}
ResultType(GroundProgram, charptr) generateCode(SolsNode* node, SolsScope* scope) {
GroundProgram program = groundCreateProgram();
@@ -1026,6 +1030,7 @@ ResultType(GroundProgram, charptr) generateCode(SolsNode* node, SolsScope* scope
case SNT_FUNCTION_CALL: generate(FunctionCall);
case SNT_RETURN: generate(Return);
case SNT_USE: generate(Use);
case SNT_GROUND: generate(InlineGround);
}
return Success(GroundProgram, charptr, program);
}

View File

@@ -1571,6 +1571,20 @@ static inline ResultType(Nothing, charptr) parseUse(SolsParser* parser) {
return Success(Nothing, charptr, {});
}
static inline ResultType(Nothing, charptr) parseInlineGround(SolsParser* parser) {
ResultType(SolsToken, Nothing) token = parserPeek(parser, 0);
if (token.error) {
return Error(Nothing, charptr, "ruh roh");
}
ResultType(SolsNode, charptr) newNode = createSolsNode(SNT_GROUND, token.as.success.as.inlineGround);
if (newNode.error) {
return Error(Nothing, charptr, newNode.as.error);
}
addChildToSolsNode(parser->currentParent, newNode.as.success);
return Success(Nothing, charptr, {});
}
static inline ResultType(Nothing, charptr) parseOpenParen(SolsParser* parser) {
return Error(Nothing, charptr, "WIP");
}
@@ -1593,6 +1607,7 @@ ResultType(Nothing, charptr) parse(SolsParser* parser) {
case STT_KW_PUTS: PARSER_HANDLE(Puts);
case STT_KW_IF: PARSER_HANDLE(If);
case STT_KW_WHILE: PARSER_HANDLE(While);
case STT_KW_GROUND: PARSER_HANDLE(InlineGround);
case STT_KW_LAMBDA: PARSER_HANDLE(Lambda);
case STT_KW_RETURN: PARSER_HANDLE(Return);
case STT_KW_USE: PARSER_HANDLE(Use);