| 52 | static const unsigned num_keywords = sizeof(keywords)/sizeof(keywords[0]); |
| 53 | |
| 54 | static void emit(const char *s, unsigned line, unsigned col) |
| 55 | { |
| 56 | if (output_layout) { |
| 57 | switch (mode) { |
| 58 | case RAW: |
| 59 | fprintf(stdout, "#%s#\n", s); |
| 60 | break; |
| 61 | case PLAIN: |
| 62 | fprintf(stdout, "(%4u,%3u) layout: %s\n", line, col, s); |
| 63 | break; |
| 64 | case CSV: |
| 65 | fprintf(stdout, "%u,%u,layout,%s\n", line, col, s); |
| 66 | break; |
| 67 | case JSON: |
| 68 | case JSONL: |
| 69 | if (first_time) |
| 70 | first_time = 0; |
| 71 | else { |
| 72 | if (mode == JSON) fputc(',', stdout); |
| 73 | fputc('\n', stdout); |
| 74 | } |
| 75 | fprintf(stdout, "{ \"line\": %u, \"column\": %u, " |
| 76 | "\"class\": \"layout\", \"token\": \"%s\" }", line, col, s); |
| 77 | break; |
| 78 | case XML: |
| 79 | fprintf(stdout, |
| 80 | "<token line=\"%u\" column=\"%u\" class=\"layout\">%s</token>\n", |
| 81 | line, col, s); |
| 82 | break; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // Fixed size stack of indentations; hard check for overflow! |
| 88 | #define MAX_INDENTS 128 |
no outgoing calls
no test coverage detected