summaryrefslogtreecommitdiff
path: root/src/codegen/codegen_decl.c
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-02-01 14:01:51 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-02-01 14:01:51 +0000
commitfbfce63744882d48ea2fc514ab1594000254db80 (patch)
treecc7949dab2149d829d3c04e3d542553ed883593f /src/codegen/codegen_decl.c
parenteafd8c67012ea253436b79f703dc0702046703f8 (diff)
Related to #138
Diffstat (limited to 'src/codegen/codegen_decl.c')
-rw-r--r--src/codegen/codegen_decl.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/codegen/codegen_decl.c b/src/codegen/codegen_decl.c
index 31bd2ee..1623ffc 100644
--- a/src/codegen/codegen_decl.c
+++ b/src/codegen/codegen_decl.c
@@ -1130,12 +1130,23 @@ void print_type_defs(ParserContext *ctx, FILE *out, ASTNode *nodes)
fprintf(out, "typedef struct Tuple_%s Tuple_%s;\nstruct Tuple_%s { ", t->sig, t->sig,
t->sig);
char *s = xstrdup(t->sig);
- char *p = strtok(s, "_");
+ char *current = s;
+ char *next_sep = strstr(current, "__");
int i = 0;
- while (p)
+ while (current)
{
- fprintf(out, "%s v%d; ", p, i++);
- p = strtok(NULL, "_");
+ if (next_sep)
+ {
+ *next_sep = 0;
+ fprintf(out, "%s v%d; ", current, i++);
+ current = next_sep + 2;
+ next_sep = strstr(current, "__");
+ }
+ else
+ {
+ fprintf(out, "%s v%d; ", current, i++);
+ break;
+ }
}
free(s);
fprintf(out, "};\n");