A categorical programming language
Revision | 68c4802b824e95b44e4e669011899f7e3c3e71cb (tree) |
---|---|
Zeit | 2024-10-30 09:21:36 |
Autor | Corbin <cds@corb...> |
Commiter | Corbin |
bk: Correctly extract templates.
I don't know why the cognitive weight of JSON vs S-expressions is so
heavy, but it really does seem to suck part of my attention at all
times, and I'd like for it to be better.
@@ -109,7 +109,9 @@ def _2to3(v2, v3, author="Unknown"): | ||
109 | 109 | "Total jets:", len(d["jets"])) |
110 | 110 | |
111 | 111 | def getExpr(store, obj): |
112 | - if obj.type_name == b"blob": return obj.as_raw_string().decode("utf-8") | |
112 | + if obj.type_name == b"blob": | |
113 | + s = obj.as_raw_string().decode("utf-8") | |
114 | + return int(s[1:]) if s.startswith("_") else s | |
113 | 115 | elif obj.type_name == b"tree": |
114 | 116 | pieces = {name: getExpr(store, store[sha]) |
115 | 117 | for (name, _, sha) in obj.iteritems()} |
@@ -119,6 +121,7 @@ def getExpr(store, obj): | ||
119 | 121 | |
120 | 122 | def sexpify(x): |
121 | 123 | if isinstance(x, str): return x |
124 | + elif isinstance(x, int): return "@%d" % x | |
122 | 125 | else: return "(" + " ".join(sexpify(v) for v in x) + ")" |
123 | 126 | |
124 | 127 | @cli.command() |