This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository eshell.

View the commit online.

commit 40279e95e85cb5514256dd7d5b678bb4674da10b
Author: swagtoy <m...@ow.swag.toys>
AuthorDate: Wed Nov 27 18:28:53 2024 -0500

    lexer: Stringify data of some things
---
 escript/include/stringify.h |  2 +-
 escript/src/lexer.c         |  6 +++++-
 escript/src/stringify.c     | 14 +++++++++-----
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/escript/include/stringify.h b/escript/include/stringify.h
index 23129e3..ba87bbf 100644
--- a/escript/include/stringify.h
+++ b/escript/include/stringify.h
@@ -10,7 +10,7 @@
 
 #include "lexer.h"
 
-char* const
+char*
 escript_lexer_data_to_string(struct Escript_Token* data, char* should_free);
 
 char const* const
diff --git a/escript/src/lexer.c b/escript/src/lexer.c
index 0134e53..39dcc2b 100644
--- a/escript/src/lexer.c
+++ b/escript/src/lexer.c
@@ -111,11 +111,15 @@ escript_token_info_str(struct Escript_Token* token)
 {
 	Eina_Strbuf* const res = eina_strbuf_new();
 	char tofree;
+	char* data;
 	eina_strbuf_append_printf(res,
 		"Token: %s\n"
 		"Data: %s",
 		escript_lexer_token_to_string(token->token),
-		escript_lexer_value_to_string(token->data, &tofree));
+		(data = "" &tofree)));
+	
+	if (tofree)
+		free(data);
 	return eina_strbuf_string_steal(res);
 }
 
diff --git a/escript/src/stringify.c b/escript/src/stringify.c
index 51e7032..078a6f6 100644
--- a/escript/src/stringify.c
+++ b/escript/src/stringify.c
@@ -12,7 +12,9 @@
 #include "eina_strbuf.h"
 #include "lexer.h"
 
-char* const
+#define STR_TOK(x) case ELEX_ ## x: return #x;
+
+char*
 escript_lexer_data_to_string(struct Escript_Token* data, char* tofree)
 {
 	char* strdata = NULL;
@@ -20,8 +22,12 @@ escript_lexer_data_to_string(struct Escript_Token* data, char* tofree)
 	*tofree = 0;
 	switch (data->token)
 	{
-	case ELEX_IDENTIFIER:
-		return data->data.d_string.str;
+	case ELEX_IDENTIFIER: return data->data.d_string.str;
+	case ELEX_SEMICOLON: return ";";
+	STR_TOK(WHILE)
+	STR_TOK(IF)
+	STR_TOK(UNLESS)
+	STR_TOK(DO)
 	default:
 		break;
 	}
@@ -32,7 +38,6 @@ escript_lexer_data_to_string(struct Escript_Token* data, char* tofree)
 char const* const
 escript_lexer_token_to_string(enum Escript_Lex_Tokens token)
 {
-#define STR_TOK(x) case ELEX_ ## x: return #x;
 	switch (token)
 	{
 	STR_TOK(WHILE)
@@ -84,5 +89,4 @@ escript_lexer_token_to_string(enum Escript_Lex_Tokens token)
 	default: return "";
 	}
 	return NULL;
-#undef STR_TOK
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to