update stuff
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user