Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/herb.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ void herb_lex_to_buffer(const char* source, hb_buffer_T* output) {
for (size_t i = 0; i < hb_array_size(tokens); i++) {
token_T* token = hb_array_get(tokens, i);

char* type = token_to_string(token);
hb_buffer_append(output, type);
free(type);
hb_string_T type = token_to_string(token);
hb_buffer_append_string(output, type);
free(type.data);

hb_buffer_append(output, "\n");
}
Expand Down
3 changes: 2 additions & 1 deletion src/include/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include "lexer_struct.h"
#include "position.h"
#include "token_struct.h"
#include "util/hb_string.h"

token_T* token_init(const char* value, token_type_T type, lexer_T* lexer);
char* token_to_string(const token_T* token);
hb_string_T token_to_string(const token_T* token);
const char* token_type_to_string(token_type_T type);

token_T* token_copy(token_T* token);
Expand Down
4 changes: 2 additions & 2 deletions src/token.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const char* token_type_to_string(const token_type_T type) {
return "Unknown token_type_T";
}

char* token_to_string(const token_T* token) {
hb_string_T token_to_string(const token_T* token) {
const char* type_string = token_type_to_string(token->type);
const char* template = "#<Herb::Token type=\"%s\" value=\"%.*s\" range=[%u, %u] start=(%u:%u) end=(%u:%u)>";

Expand Down Expand Up @@ -112,7 +112,7 @@ char* token_to_string(const token_T* token) {

free(escaped.data);

return string;
return hb_string(string);
}

token_T* token_copy(token_T* token) {
Expand Down
Loading