freeSolsToken()
This commit is contained in:
@@ -46,3 +46,18 @@ ResultType(SolsToken, charptr) createSolsToken(SolsTokenType type, ...) {
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
return Success(SolsToken, charptr, token);
|
return Success(SolsToken, charptr, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void freeSolsToken(SolsToken* token) {
|
||||||
|
if (token->type == STT_IDENTIFIER && token->as.idName != NULL) {
|
||||||
|
free(token->as.idName);
|
||||||
|
}
|
||||||
|
if (token->type == STT_KW_GROUND && token->as.inlineGround != NULL) {
|
||||||
|
free(token->as.inlineGround);
|
||||||
|
}
|
||||||
|
if (token->type == STT_LITERAL) {
|
||||||
|
freeSolsLiteral(&token->as.literal);
|
||||||
|
}
|
||||||
|
if (token->type == STT_TYPE) {
|
||||||
|
freeSolsType(&token->as.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ Result(SolsToken, charptr);
|
|||||||
// the token holds. See the SolsToken struct for more information.
|
// the token holds. See the SolsToken struct for more information.
|
||||||
ResultType(SolsToken, charptr) createSolsToken(SolsTokenType type, ...);
|
ResultType(SolsToken, charptr) createSolsToken(SolsTokenType type, ...);
|
||||||
|
|
||||||
|
// Frees a SolsToken, specifically the .as field elements.
|
||||||
|
void freeSolsToken(SolsToken* token);
|
||||||
|
|
||||||
// Represents a Solstice program, seperated into tokens.
|
// Represents a Solstice program, seperated into tokens.
|
||||||
// .at is a pointer to the tokens
|
// .at is a pointer to the tokens
|
||||||
// .count is how many tokens are currently being stored
|
// .count is how many tokens are currently being stored
|
||||||
|
|||||||
Reference in New Issue
Block a user