This commit is contained in:
2026-02-06 15:48:13 +11:00
parent d5692369d4
commit 1d1a34acce
3 changed files with 25 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
#include "lexer.h"
#include "SolsToken.h"
#include "../include/error.h"
#include "../include/estr.h"
ResultType(SolsLexer, charptr) createLexer(char* input) {
char* inputcopy = malloc(strlen(input) + 1);
@@ -7,8 +9,15 @@ ResultType(SolsLexer, charptr) createLexer(char* input) {
return Error(SolsLexer, charptr, "Couldn't copy string into lexer (in createLexer() function)");
}
strcpy(inputcopy, input);
ResultType(SolsTokens, charptr) tokens = createSolsTokens();
if (tokens.error) {
Estr e = CREATE_ESTR(tokens.as.error);
APPEND_ESTR(e, " (in createLexer() function)");
return Error(SolsLexer, charptr, e.str);
}
SolsLexer lexer = {
.input = inputcopy,
.output = tokens.as.success,
.current = 0,
};
return Success(SolsLexer, charptr, lexer);