Handle backslashes in token names when printing DOT debug graphs
This commit is contained in:
parent
04381dcea3
commit
3ac36b0cbe
4 changed files with 28 additions and 19 deletions
|
|
@ -283,6 +283,31 @@ static inline void ts_language_aliases_for_symbol(
|
|||
}
|
||||
}
|
||||
|
||||
static inline void ts_language_write_symbol_as_dot_string(
|
||||
const TSLanguage *self,
|
||||
FILE *f,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
const char *name = ts_language_symbol_name(self, symbol);
|
||||
for (const char *c = name; *c; c++) {
|
||||
switch (*c) {
|
||||
case '"':
|
||||
case '\\':
|
||||
fputc('\\', f);
|
||||
fputc(*c, f);
|
||||
break;
|
||||
case '\n':
|
||||
fputs("\\n", f);
|
||||
break;
|
||||
case '\t':
|
||||
fputs("\\n", f);
|
||||
break;
|
||||
default:
|
||||
fputc(*c, f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue