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 2999bb15a9764ad12d4e5cfc4e31fcbca471ab19
Author: swagtoy <m...@ow.swag.toys>
AuthorDate: Sat Nov 30 17:59:54 2024 -0500
lexer: (basic) string parsing
---
escript/src/lexer.c | 17 +++++++++++------
escript/src/stringify.c | 1 +
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/escript/src/lexer.c b/escript/src/lexer.c
index 60e65d2..12a1d1c 100644
--- a/escript/src/lexer.c
+++ b/escript/src/lexer.c
@@ -124,18 +124,19 @@ escript_token_info_str(struct Escript_Token* token)
return eina_strbuf_string_steal(res);
}
-static inline char*
+static inline Eina_Strbuf* const
tokenize_string(struct Escript_Lexer* const lex, char const end)
{
size_t i;
// This is probably slow?
- Eina_Strbuf* const buf = eina_strbuf_new();
- for (i = 0; at(i) != end && !eol(lex, 0); ++i)
+ Eina_Strbuf* buf = eina_strbuf_new();
+ for (i = 1; at(i) != end && !eol(lex, i); ++i)
{
if (at(i) != '\\') // todo
eina_strbuf_append_char(buf, at(i));
}
- return eina_strbuf_string_steal(buf);
+ step_char(lex, i);
+ return buf;
}
// Will clean this up later
@@ -175,10 +176,14 @@ escript_lexer_step(struct Escript_Lexer* lex)
case '"':
{
- char* res = tokenize_string(lex, '"');
+ size_t len;
+ Eina_Strbuf* res = tokenize_string(lex, '"');
if (res != NULL)
{
- free(res);
+ token.token = ELEX_STRING;
+ token.data.d_string.len = eina_strbuf_length_get(res);
+ token.data.d_string.str = eina_strbuf_string_steal(res);
+ PUSH_TOKEN;
}
// else { BAD }
}
diff --git a/escript/src/stringify.c b/escript/src/stringify.c
index 078a6f6..6759756 100644
--- a/escript/src/stringify.c
+++ b/escript/src/stringify.c
@@ -22,6 +22,7 @@ escript_lexer_data_to_string(struct Escript_Token* data, char* tofree)
*tofree = 0;
switch (data->token)
{
+ case ELEX_STRING: // fall through
case ELEX_IDENTIFIER: return data->data.d_string.str;
case ELEX_SEMICOLON: return ";";
STR_TOK(WHILE)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.