1 // Process TAGGED_ARRAY() macros to emit TAG_STRING index macros.
8 int main(int argc, char *argv[])
17 len = getline(&line, &len, stdin);
19 while (len && isspace(line[len-1])) line[--len]=0;
21 // Very simple parser: If we haven't got a TAG then first line is TAG.
22 // Then look for { followed by "str" (must be on same line, may have
23 // more than one per line), for each one emit #define. Current TAG ended
24 // by ) at start of line.
27 if (!isalpha(*line)) {
28 fprintf(stderr, "bad tag %s\n", line);
37 for (s = line; isspace(*s); s++);
38 if (*s == ')') tag = 0;
42 while (*s && *s != '{') s++;
43 while (*s && *s != '"') s++;
47 while (*s && *s != '"') {
48 if (!isalpha(*s) && !isdigit(*s)) *s = '_';
51 printf("#define %s_%*.*s %d\n", tag, -40, (int)(s-start), start, idx);
52 printf("#define _%s_%*.*s (1%s<<%d)\n", tag, -39, (int)(s-start), start,
53 idx>31 ? "LL": "", idx);