#include "lexer.h"
#include "../include/error.h"
ResultType(SolsLexer, charptr) createLexer(char* input) {
char* inputcopy = malloc(strlen(input) + 1);
if (inputcopy == NULL) {
return Error(SolsLexer, charptr, "Couldn't copy string into lexer (in createLexer() function)");
}
strcpy(inputcopy, input);
SolsLexer lexer = {
.input = inputcopy,
.current = 0,
};
return Success(SolsLexer, charptr, lexer);
ResultType(voidptr, charptr) lex(SolsLexer* lexer) {
if (lexer->input == NULL) {
return Error(voidptr, charptr, "Lexer is not initialised");
lexer->current = 0;
return Success(voidptr, charptr, NULL);