diff options
| author | Mistivia <i@mistivia.com> | 2025-06-21 10:45:36 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-21 10:45:36 +0800 |
| commit | 86742c415b34ae063bf8597d9228e9d37f0d7294 (patch) | |
| tree | 297b2ae6a8b20bf74c9e54ec6628799c02425c0d /scripts | |
| parent | 0afe446fa6e893448da949b1b6882c87b3b2701c (diff) | |
tail call optimazation
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/genprelude.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/genprelude.py b/scripts/genprelude.py new file mode 100644 index 0000000..555485d --- /dev/null +++ b/scripts/genprelude.py @@ -0,0 +1,31 @@ +def escape_c_string(s): + escape_chars = { + '\n': '\\n', + '\t': '\\t', + '\r': '\\r', + '\"': '\\"', + '\'': '\\\'', + '\\': '\\\\', + '\b': '\\b', + '\a': '\\a', + '\v': '\\v', + '\f': '\\f', + } + result = [] + for c in s: + if c in escape_chars: + result.append(escape_chars[c]) + else: + result.append(c) + return ''.join(result) + +import sys + +content = sys.stdin.read() +escaped = escape_c_string(content) +print(f""" +#include "prelude.h" + +const char *prelude = "{escaped}"; + +""") |
