diff options
| author | Zuhaitz <zuhaitz.zechhub@gmail.com> | 2026-01-13 14:50:43 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-13 14:50:43 +0000 |
| commit | 7eb91d69beb19da7a7cb7ac84625f701890ce6eb (patch) | |
| tree | 4b86f4ad20a66b0e984feb4d5a2abaf6eaa1227f /src/parser/parser_utils.c | |
| parent | 8fc9c88304fde65d6c3a619c3aee7e6e00540695 (diff) | |
| parent | 856267f36e60211ba537d63a80c5d36aa4436a4f (diff) | |
Merge branch 'main' into pr-34-testing
Diffstat (limited to 'src/parser/parser_utils.c')
| -rw-r--r-- | src/parser/parser_utils.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/parser/parser_utils.c b/src/parser/parser_utils.c index 7733ef7..ba506a0 100644 --- a/src/parser/parser_utils.c +++ b/src/parser/parser_utils.c @@ -1554,7 +1554,7 @@ char *instantiate_function_template(ParserContext *ctx, const char *name, const return mangled; } -char *process_fstring(ParserContext *ctx, const char *content) +char *process_fstring(ParserContext *ctx, const char *content, char ***used_syms, int *count) { (void)ctx; // suppress unused parameter warning char *gen = xmalloc(4096); @@ -1621,6 +1621,36 @@ char *process_fstring(ParserContext *ctx, const char *content) fmt = colon + 1; } + // Analyze usage in expression + { + Lexer lex; + lexer_init(&lex, expr); + Token t; + while ((t = lexer_next(&lex)).type != TOK_EOF) + { + if (t.type == TOK_IDENT) + { + char *name = token_strdup(t); + Symbol *sym = find_symbol_entry(ctx, name); + if (sym) + { + sym->is_used = 1; + } + + if (used_syms && count) + { + *used_syms = xrealloc(*used_syms, sizeof(char *) * (*count + 1)); + (*used_syms)[*count] = name; + (*count)++; + } + else + { + free(name); + } + } + } + } + if (fmt) { strcat(gen, "sprintf(_t, \"%"); |
